mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Fence Gates on Trains
fixes Creators-of-Create#6354
This commit is contained in:
parent
d66170c8fe
commit
5ad844daf9
@ -3,6 +3,8 @@ package com.simibubi.create;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.contraptions.behaviour.FenceGateMovingInteraction;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.content.contraptions.behaviour.DoorMovingInteraction;
|
||||
@ -75,6 +77,15 @@ public class AllInteractionBehaviours {
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
FenceGateMovingInteraction fenceGateBehavior = new FenceGateMovingInteraction();
|
||||
registerBehaviourProvider(state -> {
|
||||
if (state.is(BlockTags.FENCE_GATES)) {
|
||||
return fenceGateBehavior;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public interface BehaviourProvider {
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.simibubi.create.content.contraptions.behaviour;
|
||||
|
||||
import com.simibubi.create.content.contraptions.Contraption;
|
||||
|
||||
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.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
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;
|
||||
float pitch = player.level.random.nextFloat() * 0.1F + 0.9F;
|
||||
playSound(player, sound, pitch);
|
||||
return currentState.cycle(FenceGateBlock.OPEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateColliders() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user