fix keypad door not staying open when signal length is set to 0
@@ -44,9 +44,13 @@ public class KeypadDoorBlock extends SpecialDoorBlock
}
public static void activate(World world, BlockPos pos, BlockState state, int signalLength){
- world.playEvent(null, 1005, pos, 0);
- world.setBlockState(pos, state.with(OPEN, true));
+ boolean open = !state.get(OPEN);
+
+ world.playEvent(null, open ? 1005 : 1011, pos, 0);
+ world.setBlockState(pos, state.with(OPEN, open));
world.notifyNeighborsOfStateChange(pos, SCContent.KEYPAD_DOOR.get());
+
+ if(open && signalLength > 0)
world.getPendingBlockTicks().scheduleTick(pos, SCContent.KEYPAD_DOOR.get(), signalLength);
}
