Merge pull request #6446 from IThundxr/mc1.18/fix-contraption-step-sounds

Fix contraption step sounds
This commit is contained in:
simibubi 2024-07-17 11:22:33 +02:00 committed by GitHub
commit c3cf3b56e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,7 +8,6 @@ import java.util.stream.Stream;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.logging.log4j.util.TriConsumer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -82,7 +81,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid
}
@Unique
private void forCollision(Vec3 worldPos, TriConsumer<Contraption, BlockState, BlockPos> action) {
private void create$forCollision(Vec3 worldPos, TriConsumer<Contraption, BlockState, BlockPos> action) {
create$getIntersectingContraptions().forEach(cEntity -> {
Vec3 localPos = ContraptionCollider.worldToLocalPos(worldPos, cEntity);
@ -100,12 +99,12 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid
// involves block step sounds on contraptions
// IFNE line 661 injecting before `!blockstate.isAir(this.world, blockpos)`
@Inject(method = "move", at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 7))
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;isAir()Z", ordinal = 0))
private void create$contraptionStepSounds(MoverType mover, Vec3 movement, CallbackInfo ci) {
Vec3 worldPos = position.add(0, -0.2, 0);
MutableBoolean stepped = new MutableBoolean(false);
forCollision(worldPos, (contraption, state, pos) -> {
create$forCollision(worldPos, (contraption, state, pos) -> {
playStepSound(pos, state);
stepped.setTrue();
});
@ -136,7 +135,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid
if (info == null)
return false;
cEntity.registerColliding(self);
return true;
});
@ -155,7 +154,7 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid
Vec3 worldPos = position.add(0, -0.2, 0);
BlockPos particlePos = new BlockPos(worldPos); // pos where particles are spawned
forCollision(worldPos, (contraption, state, pos) -> {
create$forCollision(worldPos, (contraption, state, pos) -> {
if (!state.addRunningEffects(level, pos, self)
&& state.getRenderShape() != RenderShape.INVISIBLE) {
Vec3 speed = self.getDeltaMovement();