Fix baby skeletons having the wrong eye height and move speed values.
package mekanism.additions.common.entity;
import java.util.UUID;
+import javax.annotation.Nonnull;
+import net.minecraft.entity.EntitySize;
import net.minecraft.entity.EntityType;
+import net.minecraft.entity.Pose;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.AttributeModifier.Operation;
@@ -16,23 +19,28 @@ import net.minecraft.world.World;
public class EntityBabySkeleton extends SkeletonEntity {
private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
- private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, Operation.ADDITION);
+ private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, Operation.MULTIPLY_BASE);
private static final DataParameter<Boolean> IS_CHILD = EntityDataManager.createKey(EntityBabySkeleton.class, DataSerializers.BOOLEAN);
public EntityBabySkeleton(EntityType<EntityBabySkeleton> type, World world) {
super(type, world);
- dataManager.register(IS_CHILD, false);
setChild(true);
}
+ @Override
+ protected void registerData() {
+ super.registerData();
+ this.getDataManager().register(IS_CHILD, false);
+ }
+
@Override
public boolean isChild() {
- return dataManager.get(IS_CHILD);
+ return getDataManager().get(IS_CHILD);
}
public void setChild(boolean child) {
- dataManager.set(IS_CHILD, child);
+ getDataManager().set(IS_CHILD, child);
if (world != null && !world.isRemote) {
IAttributeInstance iattributeinstance = this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
iattributeinstance.removeModifier(babySpeedBoostModifier);
@@ -40,30 +48,31 @@ public class EntityBabySkeleton extends SkeletonEntity {
iattributeinstance.applyModifier(babySpeedBoostModifier);
}
}
- //TODO: Update size?
- //updateChildSize(child);
+ }
+
+ @Override
+ public void notifyDataManagerChange(@Nonnull DataParameter<?> key) {
+ if (IS_CHILD.equals(key)) {
+ this.recalculateSize();
+ }
+ super.notifyDataManagerChange(key);
}
@Override
protected int getExperiencePoints(PlayerEntity player) {
if (isChild()) {
- experienceValue = (int) ((float) experienceValue * 2.5F);
+ experienceValue = (int) (experienceValue * 2.5F);
}
return super.getExperiencePoints(player);
}
- //TODO
- /*public void updateChildSize(boolean child) {
- updateSize(child ? 0.5F : 1.0F);
- }
-
- protected final void updateSize(float size) {
- super.setSize(size, size + 0.4F);
+ @Override
+ public double getYOffset() {
+ return this.isChild() ? 0.0D : super.getYOffset();
}
- //copied from base entity, as abstractskeleton overrides it
@Override
- public float getEyeHeight() {
- return getSize(getPose()).height * 0.85F;
- }*/
+ protected float getStandingEyeHeight(Pose pose, EntitySize size) {
+ return this.isChild() ? 0.93F : super.getStandingEyeHeight(pose, size);
+ }
}
\ No newline at end of file
