From 7bfc7fe32079a9adc9302135681c8d76339dcc21 Mon Sep 17 00:00:00 2001 From: John Hoffman Date: Tue, 30 Jun 2026 01:32:09 -0600 Subject: [PATCH] Fix copper doors, trapdoors on contraptions and door, trapdoor, fence block sounds --- .../create/AllInteractionBehaviours.java | 17 +++++++++++++++-- .../behaviour/DoorMovingInteraction.java | 16 ++++++++++++---- .../behaviour/FenceGateMovingInteraction.java | 6 +++--- .../behaviour/TrapdoorMovingInteraction.java | 15 +++++++++++++-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllInteractionBehaviours.java b/src/main/java/com/simibubi/create/AllInteractionBehaviours.java index e666d1144a..b6bcedbcfb 100644 --- a/src/main/java/com/simibubi/create/AllInteractionBehaviours.java +++ b/src/main/java/com/simibubi/create/AllInteractionBehaviours.java @@ -3,9 +3,11 @@ import com.simibubi.create.api.behaviour.interaction.MovingInteractionBehaviour; import com.simibubi.create.api.registry.SimpleRegistry; import com.simibubi.create.content.contraptions.behaviour.DoorMovingInteraction; +import com.simibubi.create.content.contraptions.behaviour.FenceGateMovingInteraction; import com.simibubi.create.content.contraptions.behaviour.LeverMovingInteraction; import com.simibubi.create.content.contraptions.behaviour.TrapdoorMovingInteraction; +import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.Blocks; @@ -13,8 +15,19 @@ public class AllInteractionBehaviours { static void registerDefaults() { MovingInteractionBehaviour.REGISTRY.register(Blocks.LEVER, new LeverMovingInteraction()); - MovingInteractionBehaviour.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(BlockTags.WOODEN_DOORS, new DoorMovingInteraction())); + MovingInteractionBehaviour.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(BlockTags.MOB_INTERACTABLE_DOORS, new DoorMovingInteraction())); MovingInteractionBehaviour.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(BlockTags.WOODEN_TRAPDOORS, new TrapdoorMovingInteraction())); - MovingInteractionBehaviour.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(BlockTags.FENCE_GATES, new TrapdoorMovingInteraction())); + MovingInteractionBehaviour.REGISTRY.registerProvider(SimpleRegistry.Provider.forBlockTag(BlockTags.FENCE_GATES, new FenceGateMovingInteraction())); + + TrapdoorMovingInteraction copperTrapdoorInteraction = + new TrapdoorMovingInteraction(SoundEvents.COPPER_TRAPDOOR_OPEN, SoundEvents.COPPER_TRAPDOOR_CLOSE); + MovingInteractionBehaviour.REGISTRY.register(Blocks.COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.EXPOSED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.WEATHERED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.OXIDIZED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.WAXED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.WAXED_EXPOSED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.WAXED_WEATHERED_COPPER_TRAPDOOR, copperTrapdoorInteraction); + MovingInteractionBehaviour.REGISTRY.register(Blocks.WAXED_OXIDIZED_COPPER_TRAPDOOR, copperTrapdoorInteraction); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/DoorMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/DoorMovingInteraction.java index b7762b9100..bfbd7be063 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/DoorMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/DoorMovingInteraction.java @@ -22,9 +22,17 @@ protected BlockState handle(Player player, Contraption contraption, BlockPos pos if (!(currentState.getBlock() instanceof DoorBlock)) return currentState; - boolean trainDoor = currentState.getBlock() instanceof SlidingDoorBlock; - SoundEvent sound = currentState.getValue(DoorBlock.OPEN) ? trainDoor ? null : SoundEvents.WOODEN_DOOR_CLOSE - : trainDoor ? SoundEvents.IRON_DOOR_OPEN : SoundEvents.WOODEN_DOOR_OPEN; + DoorBlock doorBlock = (DoorBlock) currentState.getBlock(); + boolean slidingDoor = doorBlock instanceof SlidingDoorBlock; + boolean open = currentState.getValue(DoorBlock.OPEN); + + SoundEvent sound = null; + if (slidingDoor) { + if (!open) + sound = SoundEvents.IRON_DOOR_OPEN; + } else { + sound = open ? doorBlock.type().doorClose() : doorBlock.type().doorOpen(); + } BlockPos otherPos = currentState.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? pos.above() : pos.below(); StructureBlockInfo info = contraption.getBlocks() @@ -38,7 +46,7 @@ protected BlockState handle(Player player, Contraption contraption, BlockPos pos if (player != null) { - if (trainDoor) { + if (slidingDoor) { DoorHingeSide hinge = currentState.getValue(SlidingDoorBlock.HINGE); Direction facing = currentState.getValue(SlidingDoorBlock.FACING); BlockPos doublePos = diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java index 8d897014fb..3a885872ac 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java @@ -4,7 +4,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvent; -import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.state.BlockState; @@ -13,8 +12,9 @@ public class FenceGateMovingInteraction extends SimpleBlockMovingInteraction { @Override protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) { - SoundEvent sound = currentState.getValue(FenceGateBlock.OPEN) ? SoundEvents.FENCE_GATE_CLOSE - : SoundEvents.FENCE_GATE_OPEN; + FenceGateBlock fenceGateBlock = (FenceGateBlock) currentState.getBlock(); + SoundEvent sound = currentState.getValue(FenceGateBlock.OPEN) ? fenceGateBlock.closeSound + : fenceGateBlock.openSound; float pitch = player.level().random.nextFloat() * 0.1F + 0.9F; playSound(player, sound, pitch); return currentState.cycle(FenceGateBlock.OPEN); diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/TrapdoorMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/TrapdoorMovingInteraction.java index 374abc1004..205afde22d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/TrapdoorMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/TrapdoorMovingInteraction.java @@ -11,10 +11,21 @@ public class TrapdoorMovingInteraction extends SimpleBlockMovingInteraction { + private final SoundEvent openSound; + private final SoundEvent closeSound; + + public TrapdoorMovingInteraction() { + this(SoundEvents.WOODEN_TRAPDOOR_OPEN, SoundEvents.WOODEN_TRAPDOOR_CLOSE); + } + + public TrapdoorMovingInteraction(SoundEvent openSound, SoundEvent closeSound) { + this.openSound = openSound; + this.closeSound = closeSound; + } + @Override protected BlockState handle(Player player, Contraption contraption, BlockPos pos, BlockState currentState) { - SoundEvent sound = currentState.getValue(TrapDoorBlock.OPEN) ? SoundEvents.WOODEN_TRAPDOOR_CLOSE - : SoundEvents.WOODEN_TRAPDOOR_OPEN; + SoundEvent sound = currentState.getValue(TrapDoorBlock.OPEN) ? closeSound : openSound; float pitch = player.level().random.nextFloat() * 0.1F + 0.9F; playSound(player, sound, pitch); return currentState.cycle(TrapDoorBlock.OPEN);