mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 18:37:42 +01:00
Option to make doors require redstone
This commit is contained in:
committed by
granny
parent
434ace14d3
commit
0e04be6f1b
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/level/block/DoorBlock.java
|
||||
+++ b/net/minecraft/world/level/block/DoorBlock.java
|
||||
@@ -206,6 +_,7 @@
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
||||
if (!this.type.canOpenByHand()) {
|
||||
return InteractionResult.PASS;
|
||||
+ } else if (requiresRedstone(level, state, pos)) { return InteractionResult.CONSUME; // Purpur - Option to make doors require redstone
|
||||
} else {
|
||||
state = state.cycle(OPEN);
|
||||
level.setBlock(pos, state, 10);
|
||||
@@ -294,4 +_,18 @@
|
||||
public static boolean isWoodenDoor(BlockState state) {
|
||||
return state.getBlock() instanceof DoorBlock doorBlock && doorBlock.type().canOpenByHand();
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Option to make doors require redstone
|
||||
+ public static boolean requiresRedstone(Level level, BlockState state, BlockPos pos) {
|
||||
+ if (level.purpurConfig.doorRequiresRedstone.contains(state.getBlock())) {
|
||||
+ // force update client
|
||||
+ BlockPos otherPos = pos.relative(state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? Direction.UP : Direction.DOWN);
|
||||
+ BlockState otherState = level.getBlockState(otherPos);
|
||||
+ level.sendBlockUpdated(pos, state, state, 3);
|
||||
+ level.sendBlockUpdated(otherPos, otherState, otherState, 3);
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Purpur end - Option to make doors require redstone
|
||||
}
|
||||
Reference in New Issue
Block a user