mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
Fence Gates on Trains
fixes Creators-of-Create#6354
This commit is contained in:
parent
d66170c8fe
commit
5ad844daf9
2 changed files with 40 additions and 0 deletions
|
@ -3,6 +3,8 @@ package com.simibubi.create;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.contraptions.behaviour.FenceGateMovingInteraction;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.simibubi.create.content.contraptions.behaviour.DoorMovingInteraction;
|
import com.simibubi.create.content.contraptions.behaviour.DoorMovingInteraction;
|
||||||
|
@ -75,6 +77,15 @@ public class AllInteractionBehaviours {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FenceGateMovingInteraction fenceGateBehavior = new FenceGateMovingInteraction();
|
||||||
|
registerBehaviourProvider(state -> {
|
||||||
|
if (state.is(BlockTags.FENCE_GATES)) {
|
||||||
|
return fenceGateBehavior;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface BehaviourProvider {
|
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 a new issue