From 97f2eda35188d7669561ce86a5e0daf8d3e6461b Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 28 Sep 2020 21:13:20 +0200 Subject: [PATCH] Fixed sounds spam when disguised as bees and minecarts --- .../unicopia/entity/behaviour/BeeBehaviour.java | 6 +++--- .../minelittlepony/unicopia/entity/behaviour/Disguise.java | 6 +++--- .../unicopia/entity/behaviour/EntityBehaviour.java | 2 +- .../unicopia/entity/behaviour/FallingBlockBehaviour.java | 4 ++-- .../unicopia/entity/behaviour/MinecartBehaviour.java | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java index 2c3c013b..d6a2bc17 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java @@ -9,9 +9,9 @@ import net.minecraft.entity.passive.BeeEntity; public class BeeBehaviour extends EntityBehaviour { @Override - public BeeEntity onCreate(BeeEntity entity, Disguise context) { - super.onCreate(entity, context); - if (entity.world.isClient) { + public BeeEntity onCreate(BeeEntity entity, Disguise context, boolean replaceOld) { + super.onCreate(entity, context, replaceOld); + if (replaceOld && entity.world.isClient) { MinecraftClient.getInstance().getSoundManager().playNextTick( entity.hasAngerTime() ? new AggressiveBeeSoundInstance(entity) : new PassiveBeeSoundInstance(entity) ); 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 3e5be153..a6591b94 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/Disguise.java @@ -130,11 +130,11 @@ public class Disguise implements NbtSerialisable { } catch (Exception ignored) { // Mojang pls } - entity = EntityBehaviour.forEntity(entity).onCreate(entity, this); + entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, true); } } else { entity = EntityType.loadEntityWithPassengers(nbt, source.getWorld(), e -> { - return EntityBehaviour.forEntity(e).onCreate(e, this); + return EntityBehaviour.forEntity(e).onCreate(e, this, true); }); } } @@ -249,7 +249,7 @@ public class Disguise implements NbtSerialisable { } attachments.clear(); - entity = EntityBehaviour.forEntity(entity).onCreate(entity, this); + entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, false); } } } 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 b2030742..ce2358c8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -30,7 +30,7 @@ public class EntityBehaviour { } - public T onCreate(T entity, Disguise context) { + public T onCreate(T entity, Disguise context, boolean wasNew) { entity.extinguish(); return entity; } 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 75657063..ee8fb6be 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -30,8 +30,8 @@ public class FallingBlockBehaviour extends EntityBehaviour { private static final Vec3d UP = Vec3d.of(Direction.UP.getVector()); @Override - public FallingBlockEntity onCreate(FallingBlockEntity entity, Disguise context) { - super.onCreate(entity, context); + public FallingBlockEntity onCreate(FallingBlockEntity entity, Disguise context, boolean replaceOld) { + super.onCreate(entity, context, replaceOld); BlockState state = entity.getBlockState(); Block block = state.getBlock(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java index b0e71383..0115025d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java @@ -11,9 +11,9 @@ import net.minecraft.entity.vehicle.AbstractMinecartEntity; public class MinecartBehaviour extends EntityBehaviour { @Override - public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, Disguise context) { - super.onCreate(entity, context); - if (entity.world.isClient) { + public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, Disguise context, boolean replaceOld) { + super.onCreate(entity, context, replaceOld); + if (replaceOld && entity.world.isClient) { MinecraftClient.getInstance().getSoundManager().play(new MovingMinecartSoundInstance(entity)); } return entity;