Skip to content

Commit

Permalink
Turkey display while attacking
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Nov 22, 2019
1 parent 20a9f8b commit 2f9e947
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,39 @@ public void setRotationAngles(T entityIn, float limbSwing, float limbSwingAmount
} 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class EntityTurkey extends EntityAnimalWithTypes {

protected static final DataParameter<Integer> PECK_TIME = EntityDataManager.<Integer>createKey(EntityTurkey.class, DataSerializers.VARINT);
protected static final DataParameter<Boolean> ATTACKING = EntityDataManager.<Boolean>createKey(EntityTurkey.class, DataSerializers.BOOLEAN);
public float wingRotation;
public float destPos;
public float oFlapSpeed;
Expand Down Expand Up @@ -115,6 +116,20 @@ protected void registerAttributes() {
this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1D);
}

@Override
public void setAttackTarget(LivingEntity entity) {
this.setAttackingOnClient(entity != null);
super.setAttackTarget(entity);
}

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) {
Expand Down Expand Up @@ -150,7 +165,7 @@ public void livingTick() {

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);
}
Expand Down Expand Up @@ -210,15 +225,16 @@ protected ResourceLocation getLootTable() {
@Override
protected void registerData() {
super.registerData();
this.dataManager.register(EntityTurkey.PECK_TIME, Integer.valueOf(0));
this.dataManager.register(PECK_TIME, Integer.valueOf(0));
this.dataManager.register(ATTACKING, Boolean.valueOf(false));
}

public int getPeckTime() {
return this.dataManager.get(EntityTurkey.PECK_TIME).intValue();
return this.dataManager.get(PECK_TIME).intValue();
}

public int setPeckTime(int time) {
this.dataManager.set(EntityTurkey.PECK_TIME, Integer.valueOf(time));
this.dataManager.set(PECK_TIME, Integer.valueOf(time));
return time;
}

Expand Down

0 comments on commit 2f9e947

Please sign in to comment.