diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java index 9c9ac695..8665ed5c 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java @@ -89,7 +89,7 @@ public class Disguise implements NbtSerialisable { public void remove() { attachments.clear(); if (entity != null) { - entity.remove(); + EntityBehaviour.forEntity(entity).onDestroy(entity); entity = null; } if (blockEntity != null) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index 5c1d5279..2662ef70 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -51,6 +51,12 @@ public class EntityBehaviour { return entity; } + public void onDestroy(T entity) { + entity.setInvulnerable(false); + entity.setNoGravity(false); + entity.remove(); + } + public Optional getDimensions(T entity, Optional current) { if (entity == null) { return Optional.empty(); @@ -231,7 +237,7 @@ public class EntityBehaviour { static { register(FallingBlockBehaviour::new, EntityType.FALLING_BLOCK); register(MobBehaviour::new, EntityType.RAVAGER, EntityType.IRON_GOLEM); - register(RabbitBehaviour::new, EntityType.RABBIT); + register(HoppingBehaviour::new, EntityType.RABBIT, EntityType.SLIME, EntityType.MAGMA_CUBE); register(TraderBehaviour::new, EntityType.VILLAGER, EntityType.WANDERING_TRADER); register(SheepBehaviour::new, EntityType.SHEEP); register(BeeBehaviour::new, EntityType.BEE); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java index ddf0717e..a52588ff 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -24,18 +24,27 @@ import net.minecraft.state.property.Properties; import net.minecraft.tag.BlockTags; import net.minecraft.util.Tickable; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Direction.Axis; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.shape.VoxelShape; public class FallingBlockBehaviour extends EntityBehaviour { private static final Vec3d UP = Vec3d.of(Direction.UP.getVector()); - private static final Optional FULL_BLOCK = Optional.of(EntityDimensions.changing(1, 0.9F)); - + // private static final Optional FULL_BLOCK = Optional.of(EntityDimensions.changing(0.6F, 0.9F)); @Override public Optional getDimensions(FallingBlockEntity entity, Optional current) { - return FULL_BLOCK; + + VoxelShape shape = entity.getBlockState().getCollisionShape(entity.world, entity.getBlockPos()); + float height = (float)shape.getMax(Axis.Y); + + if (!current.isPresent() || current.get().height != height) { + return Optional.of(EntityDimensions.changing(0.6F, height)); + } + + return current; } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RabbitBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java similarity index 56% rename from src/main/java/com/minelittlepony/unicopia/entity/behaviour/RabbitBehaviour.java rename to src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java index 55927d2c..ebf74be6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RabbitBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/HoppingBehaviour.java @@ -4,19 +4,24 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.RabbitEntity; -public class RabbitBehaviour extends EntityBehaviour { +public class HoppingBehaviour extends EntityBehaviour { @Override - public void update(Pony player, RabbitEntity entity, DisguiseSpell spell) { + public void update(Pony player, LivingEntity entity, DisguiseSpell spell) { if (player.getEntity().isOnGround()) { if (Entity.squaredHorizontalLength(player.getEntity().getVelocity()) > 0.01) { player.getOwner().jump(); - entity.startJump(); + if (entity instanceof RabbitEntity) { + ((RabbitEntity)entity).startJump(); + } } } else if (player.landedChanged()) { - entity.startJump(); + if (entity instanceof RabbitEntity) { + ((RabbitEntity)entity).startJump(); + } } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java index 27acfbe2..3bdd46bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java @@ -12,8 +12,13 @@ public class MobBehaviour extends EntityBehaviour { private MobEntity dummy; @Override - public void update(Pony player, MobEntity entity, DisguiseSpell spell) { + public void onDestroy(MobEntity entity) { + entity.setAiDisabled(false); + super.onDestroy(entity); + } + @Override + public void update(Pony player, MobEntity entity, DisguiseSpell spell) { if (player.sneakingChanged() && isSneakingOnGround(player)) { LivingEntity target = RayTraceHelper.findEntity(player.getEntity(), 6, 1,