Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =======================================================================================================================================
- PinkChickenEntity
- public class PinkChickenEntity extends AnimalEntity {
- private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS);
- public float wingRotation;
- public float destPos;
- public float oFlapSpeed;
- public float oFlap;
- public float wingRotDelta = 1.0F;
- public int timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
- public boolean chickenJockey;
- public PinkChickenEntity(EntityType<? extends AnimalEntity> type, World worldIn) {
- super(type, worldIn);
- this.setPathPriority(PathNodeType.WATER, 0.0F);
- }
- @Override
- protected void registerGoals() {
- this.goalSelector.addGoal(0, new SwimGoal(this));
- this.goalSelector.addGoal(1, new PanicGoal(this, 1.4D));
- this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
- this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, false, TEMPTATION_ITEMS));
- this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));
- this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
- this.goalSelector.addGoal(6, new LookAtGoal(this, PlayerEntity.class, 6.0F));
- this.goalSelector.addGoal(7, new LookRandomlyGoal(this));
- }
- @Override
- protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) {
- return this.isChild() ? sizeIn.height * 0.85F : sizeIn.height * 0.92F;
- }
- @Override
- protected void registerAttributes() {
- super.registerAttributes();
- this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(4.0D);
- this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
- }
- public void livingTick() {
- super.livingTick();
- this.oFlap = this.wingRotation;
- this.oFlapSpeed = this.destPos;
- this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D);
- this.destPos = MathHelper.clamp(this.destPos, 0.0F, 1.0F);
- if (!this.onGround && this.wingRotDelta < 1.0F) {
- this.wingRotDelta = 1.0F;
- }
- this.wingRotDelta = (float)((double)this.wingRotDelta * 0.9D);
- Vec3d vec3d = this.getMotion();
- if (!this.onGround && vec3d.y < 0.0D) {
- this.setMotion(vec3d.mul(1.0D, 0.6D, 1.0D));
- }
- this.wingRotation += this.wingRotDelta * 2.0F;
- if (!this.world.isRemote && this.isAlive() && !this.isChild() && !this.isChickenJockey() && --this.timeUntilNextEgg <= 0) {
- this.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
- this.entityDropItem(ModItem.PINK_EGG.get());
- this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
- }
- }
- @Override
- public boolean onLivingFall(float distance, float damageMultiplier) {
- return false;
- }
- @Override
- protected SoundEvent getAmbientSound() {
- return SoundEvents.ENTITY_CHICKEN_AMBIENT;
- }
- @Override
- protected SoundEvent getHurtSound(DamageSource damageSourceIn) {
- return SoundEvents.ENTITY_CHICKEN_HURT;
- }
- @Override
- protected SoundEvent getDeathSound() {
- return SoundEvents.ENTITY_CHICKEN_DEATH;
- }
- @Override
- protected void playStepSound(BlockPos pos, BlockState blockIn) {
- this.playSound(SoundEvents.ENTITY_CHICKEN_STEP, 0.15F, 1.0F);
- }
- @Nullable
- @Override
- public PinkChickenEntity createChild(AgeableEntity ageable) {
- return ModEntity.PINK_CHICKEN.get().create(this.world);
- }
- @Override
- public boolean isBreedingItem(ItemStack stack) {
- return TEMPTATION_ITEMS.test(stack);
- }
- @Override
- protected int getExperiencePoints(PlayerEntity player) {
- return this.isChickenJockey() ? 10 : super.getExperiencePoints(player);
- }
- @Override
- public void readAdditional(CompoundNBT compound) {
- super.readAdditional(compound);
- this.chickenJockey = compound.getBoolean("IsChickenJockey");
- if (compound.contains("EggLayTime")) {
- this.timeUntilNextEgg = compound.getInt("EggLayTime");
- }
- }
- @Override
- public void writeAdditional(CompoundNBT compound) {
- super.writeAdditional(compound);
- compound.putBoolean("IsChickenJockey", this.chickenJockey);
- compound.putInt("EggLayTime", this.timeUntilNextEgg);
- }
- @Override
- public boolean canDespawn(double distanceToClosestPlayer) {
- return this.isChickenJockey() && !this.isBeingRidden();
- }
- @Override
- public void updatePassenger(Entity passenger) {
- super.updatePassenger(passenger);
- float f = MathHelper.sin(this.renderYawOffset * ((float)Math.PI / 180F));
- float f1 = MathHelper.cos(this.renderYawOffset * ((float)Math.PI / 180F));
- float f2 = 0.1F;
- float f3 = 0.0F;
- passenger.setPosition(this.getPosX() + (double)(0.1F * f), this.getPosYHeight(0.5D) + passenger.getYOffset() + 0.0D, this.getPosZ() - (double)(0.1F * f1));
- if (passenger instanceof LivingEntity) {
- ((LivingEntity)passenger).renderYawOffset = this.renderYawOffset;
- }
- }
- public boolean isChickenJockey() {
- return this.chickenJockey;
- }
- public void setChickenJockey(boolean jockey) {
- this.chickenJockey = jockey;
- }
- }
- =======================================================================================================================================
- PinkChickenModel
- @OnlyIn(Dist.CLIENT)
- public class PinkChickenModel<T extends PinkChickenEntity> extends AgeableModel<T> {
- private final ModelRenderer head;
- private final ModelRenderer body;
- private final ModelRenderer rightLeg;
- private final ModelRenderer leftLeg;
- private final ModelRenderer rightWing;
- private final ModelRenderer leftWing;
- private final ModelRenderer bill;
- private final ModelRenderer chin;
- public PinkChickenModel() {
- int i = 16;
- this.head = new ModelRenderer(this, 0, 0);
- this.head.addBox(-2.0F, -6.0F, -2.0F, 4.0F, 6.0F, 3.0F, 0.0F);
- this.head.setRotationPoint(0.0F, 15.0F, -4.0F);
- this.bill = new ModelRenderer(this, 14, 0);
- this.bill.addBox(-2.0F, -4.0F, -4.0F, 4.0F, 2.0F, 2.0F, 0.0F);
- this.bill.setRotationPoint(0.0F, 15.0F, -4.0F);
- this.chin = new ModelRenderer(this, 14, 4);
- this.chin.addBox(-1.0F, -2.0F, -3.0F, 2.0F, 2.0F, 2.0F, 0.0F);
- this.chin.setRotationPoint(0.0F, 15.0F, -4.0F);
- this.body = new ModelRenderer(this, 0, 9);
- this.body.addBox(-3.0F, -4.0F, -3.0F, 6.0F, 8.0F, 6.0F, 0.0F);
- this.body.setRotationPoint(0.0F, 16.0F, 0.0F);
- this.rightLeg = new ModelRenderer(this, 26, 0);
- this.rightLeg.addBox(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F);
- this.rightLeg.setRotationPoint(-2.0F, 19.0F, 1.0F);
- this.leftLeg = new ModelRenderer(this, 26, 0);
- this.leftLeg.addBox(-1.0F, 0.0F, -3.0F, 3.0F, 5.0F, 3.0F);
- this.leftLeg.setRotationPoint(1.0F, 19.0F, 1.0F);
- this.rightWing = new ModelRenderer(this, 24, 13);
- this.rightWing.addBox(0.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F);
- this.rightWing.setRotationPoint(-4.0F, 13.0F, 0.0F);
- this.leftWing = new ModelRenderer(this, 24, 13);
- this.leftWing.addBox(-1.0F, 0.0F, -3.0F, 1.0F, 4.0F, 6.0F);
- this.leftWing.setRotationPoint(4.0F, 13.0F, 0.0F);
- }
- @Override
- protected Iterable<ModelRenderer> getHeadParts() {
- return ImmutableList.of(this.head, this.bill, this.chin);
- }
- @Override
- protected Iterable<ModelRenderer> getBodyParts() {
- return ImmutableList.of(this.body, this.rightLeg, this.leftLeg, this.rightWing, this.leftWing);
- }
- public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
- this.head.rotateAngleX = headPitch * ((float)Math.PI / 180F);
- this.head.rotateAngleY = netHeadYaw * ((float)Math.PI / 180F);
- this.bill.rotateAngleX = this.head.rotateAngleX;
- this.bill.rotateAngleY = this.head.rotateAngleY;
- this.chin.rotateAngleX = this.head.rotateAngleX;
- this.chin.rotateAngleY = this.head.rotateAngleY;
- this.body.rotateAngleX = ((float)Math.PI / 2F);
- this.rightLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
- this.leftLeg.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float)Math.PI) * 1.4F * limbSwingAmount;
- this.rightWing.rotateAngleZ = ageInTicks;
- this.leftWing.rotateAngleZ = -ageInTicks;
- }
- }
- =======================================================================================================================================
- PinkChickenRenderer
- @OnlyIn(Dist.CLIENT)
- public class PinkChickenRenderer extends MobRenderer<PinkChickenEntity, PinkChickenModel<PinkChickenEntity>> {
- private static final ResourceLocation PINK_CHICKEN_TEXTURES = new ResourceLocation(MysticsBiomes.MOD_ID, "textures/entity/pink_chicken.png");
- public PinkChickenRenderer(EntityRendererManager renderManagerIn) {
- super(renderManagerIn, new PinkChickenModel<>(),0.7F);
- }
- @Override
- public ResourceLocation getEntityTexture(PinkChickenEntity entity) {
- return PINK_CHICKEN_TEXTURES;
- }
- protected float handleRotationFloat(ChickenEntity livingBase, float partialTicks) {
- float f = MathHelper.lerp(partialTicks, livingBase.oFlap, livingBase.wingRotation);
- float f1 = MathHelper.lerp(partialTicks, livingBase.oFlapSpeed, livingBase.destPos);
- return (MathHelper.sin(f) + 1.0F) * f1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement