From b1ee1a2c7cbe3329841575465f389d12c26b5847 Mon Sep 17 00:00:00 2001 From: itsmeow Date: Tue, 19 Nov 2019 22:16:14 -0500 Subject: [PATCH] Turkey display while attacking --- .../client/model/ModelTurkey.java | 33 +++++++++++++++++++ .../common/entity/EntityTurkey.java | 18 +++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/main/java/its_meow/betteranimalsplus/client/model/ModelTurkey.java b/src/main/java/its_meow/betteranimalsplus/client/model/ModelTurkey.java index ad3d6cf8..ba4b8d4b 100644 --- a/src/main/java/its_meow/betteranimalsplus/client/model/ModelTurkey.java +++ b/src/main/java/its_meow/betteranimalsplus/client/model/ModelTurkey.java @@ -294,6 +294,39 @@ public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageI } else { this.neck.rotateAngleX = -1.0471975511965976F; } + if(ent.isAttackingFromServer()) { + this.setRotateAngle(tail01, 0.9424777960769379F, 0.0F, 0.0F); + this.setRotateAngle(rTailFeather01, 0.0F, -0.06981317007977318F, 0.0F); + this.setRotateAngle(lTailFeather04, 0.0F, 1.0471975511965976F, 0.0F); + this.setRotateAngle(tail02, 0.45378560551852565F, 0.0F, 0.0F); + this.setRotateAngle(rTailFeather05, 0.0F, -1.3089969389957472F, 0.0F); + this.setRotateAngle(lTailFeather02, 0.0F, 0.296705972839036F, 0.0F); + this.setRotateAngle(rTailFeather02, 0.0F, -0.296705972839036F, 0.0F); + this.setRotateAngle(rTailFeather03, 0.0F, -0.6981317007977318F, 0.0F); + this.setRotateAngle(hackles, 0.7330382858376184F, 0.0F, 0.0F); + this.setRotateAngle(lTailFeather03, 0.0F, 0.6981317007977318F, 0.0F); + this.setRotateAngle(lTailFeather05, 0.0F, 1.3089969389957472F, 0.0F); + this.setRotateAngle(lTailFeather01, 0.0F, 0.06981317007977318F, 0.0F); + this.setRotateAngle(rTailFeather04, 0.0F, -1.0471975511965976F, 0.0F); + } else { + this.setRotateAngle(rTailFeather04, 0.0F, -0.17453292519943295F, 0.0F); + this.setRotateAngle(lTailFeather01, 0.0F, 0.017453292519943295F, 0.0F); + this.setRotateAngle(lTailFeather05, 0.0F, 0.2617993877991494F, 0.0F); + this.setRotateAngle(lTailFeather03, 0.0F, 0.12217304763960307F, 0.0F); + this.setRotateAngle(hackles, 0.17453292519943295F, 0.0F, 0.0F); + this.setRotateAngle(rTailFeather03, 0.0F, -0.12217304763960307F, 0.0F); + this.setRotateAngle(rTailFeather02, 0.0F, -0.05235987755982988F, 0.0F); + this.setRotateAngle(lTailFeather02, 0.0F, 0.05235987755982988F, 0.0F); + this.setRotateAngle(rTailFeather05, 0.0F, -0.2617993877991494F, 0.0F); + this.setRotateAngle(tail02, 0.12217304763960307F, 0.0F, 0.0F); + this.setRotateAngle(lTailFeather04, 0.0F, 0.17453292519943295F, 0.0F); + this.setRotateAngle(rTailFeather02, 0.0F, -0.05235987755982988F, 0.0F); + this.setRotateAngle(lTailFeather02, 0.0F, 0.05235987755982988F, 0.0F); + this.setRotateAngle(tail02, 0.12217304763960307F, 0.0F, 0.0F); + this.setRotateAngle(lTailFeather04, 0.0F, 0.17453292519943295F, 0.0F); + this.setRotateAngle(rTailFeather01, 0.0F, -0.017453292519943295F, 0.0F); + this.setRotateAngle(tail01, 0.0F, 0.0F, 0.0F); + } } this.head.rotateAngleX = headPitch * 0.017453292F + 0.2617993877991494F; this.rLeg01.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount; diff --git a/src/main/java/its_meow/betteranimalsplus/common/entity/EntityTurkey.java b/src/main/java/its_meow/betteranimalsplus/common/entity/EntityTurkey.java index 71e23f8e..d91ef922 100644 --- a/src/main/java/its_meow/betteranimalsplus/common/entity/EntityTurkey.java +++ b/src/main/java/its_meow/betteranimalsplus/common/entity/EntityTurkey.java @@ -36,6 +36,7 @@ public class EntityTurkey extends EntityAnimalWithTypes { protected static final DataParameter PECK_TIME = EntityDataManager.createKey(EntityTurkey.class, DataSerializers.VARINT); + protected static final DataParameter ATTACKING = EntityDataManager.createKey(EntityTurkey.class, DataSerializers.BOOLEAN); public float wingRotation; public float destPos; public float oFlapSpeed; @@ -111,6 +112,20 @@ protected void applyEntityAttributes() { this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1D); } + + @Override + public void setAttackTarget(EntityLivingBase entitylivingbaseIn) { + this.setAttackingOnClient(entitylivingbaseIn != null); + super.setAttackTarget(entitylivingbaseIn); + } + + public boolean isAttackingFromServer() { + return this.dataManager.get(ATTACKING).booleanValue(); + } + + public void setAttackingOnClient(boolean in) { + this.dataManager.set(ATTACKING, Boolean.valueOf(in)); + } @Override public boolean attackEntityAsMob(Entity entityIn) { @@ -151,7 +166,7 @@ public void onLivingUpdate() { this.wingRotation += this.wingRotDelta * 2.0F; - if(!this.onGround || this.getMoveHelper().isUpdating()) { + if(!this.onGround || this.getMoveHelper().isUpdating() || this.getAttackTarget() != null) { if(this.getPeckTime() <= 61) { this.setPeckTime(80); } @@ -212,6 +227,7 @@ protected ResourceLocation getLootTable() { protected void entityInit() { super.entityInit(); this.dataManager.register(PECK_TIME, Integer.valueOf(0)); + this.dataManager.register(ATTACKING, Boolean.valueOf(false)); } public int getPeckTime() {