mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed sounds spam when disguised as bees and minecarts
This commit is contained in:
parent
b6004bcd05
commit
97f2eda351
5 changed files with 12 additions and 12 deletions
|
@ -9,9 +9,9 @@ import net.minecraft.entity.passive.BeeEntity;
|
||||||
|
|
||||||
public class BeeBehaviour extends EntityBehaviour<BeeEntity> {
|
public class BeeBehaviour extends EntityBehaviour<BeeEntity> {
|
||||||
@Override
|
@Override
|
||||||
public BeeEntity onCreate(BeeEntity entity, Disguise context) {
|
public BeeEntity onCreate(BeeEntity entity, Disguise context, boolean replaceOld) {
|
||||||
super.onCreate(entity, context);
|
super.onCreate(entity, context, replaceOld);
|
||||||
if (entity.world.isClient) {
|
if (replaceOld && entity.world.isClient) {
|
||||||
MinecraftClient.getInstance().getSoundManager().playNextTick(
|
MinecraftClient.getInstance().getSoundManager().playNextTick(
|
||||||
entity.hasAngerTime() ? new AggressiveBeeSoundInstance(entity) : new PassiveBeeSoundInstance(entity)
|
entity.hasAngerTime() ? new AggressiveBeeSoundInstance(entity) : new PassiveBeeSoundInstance(entity)
|
||||||
);
|
);
|
||||||
|
|
|
@ -130,11 +130,11 @@ public class Disguise implements NbtSerialisable {
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// Mojang pls
|
// Mojang pls
|
||||||
}
|
}
|
||||||
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this);
|
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entity = EntityType.loadEntityWithPassengers(nbt, source.getWorld(), e -> {
|
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();
|
attachments.clear();
|
||||||
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this);
|
entity = EntityBehaviour.forEntity(entity).onCreate(entity, this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T onCreate(T entity, Disguise context) {
|
public T onCreate(T entity, Disguise context, boolean wasNew) {
|
||||||
entity.extinguish();
|
entity.extinguish();
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
||||||
private static final Vec3d UP = Vec3d.of(Direction.UP.getVector());
|
private static final Vec3d UP = Vec3d.of(Direction.UP.getVector());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FallingBlockEntity onCreate(FallingBlockEntity entity, Disguise context) {
|
public FallingBlockEntity onCreate(FallingBlockEntity entity, Disguise context, boolean replaceOld) {
|
||||||
super.onCreate(entity, context);
|
super.onCreate(entity, context, replaceOld);
|
||||||
|
|
||||||
BlockState state = entity.getBlockState();
|
BlockState state = entity.getBlockState();
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
|
@ -11,9 +11,9 @@ import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
||||||
public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
|
public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, Disguise context) {
|
public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, Disguise context, boolean replaceOld) {
|
||||||
super.onCreate(entity, context);
|
super.onCreate(entity, context, replaceOld);
|
||||||
if (entity.world.isClient) {
|
if (replaceOld && entity.world.isClient) {
|
||||||
MinecraftClient.getInstance().getSoundManager().play(new MovingMinecartSoundInstance(entity));
|
MinecraftClient.getInstance().getSoundManager().play(new MovingMinecartSoundInstance(entity));
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
|
|
Loading…
Reference in a new issue