aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch167
1 files changed, 167 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch
new file mode 100644
index 0000000000..e1ac8ed0d4
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ObserverBlock.java.patch
@@ -0,0 +1,167 @@
+--- a/net/minecraft/world/level/block/ObserverBlock.java
++++ b/net/minecraft/world/level/block/ObserverBlock.java
+@@ -10,55 +10,67 @@
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.block.state.BlockBehaviour;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.block.state.StateDefinition;
+ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
+ import net.minecraft.world.level.block.state.properties.BooleanProperty;
++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
+-public class ObserverBlock extends DirectionalBlock {
++public class ObserverBlock extends BlockDirectional {
++
+ public static final MapCodec<ObserverBlock> CODEC = simpleCodec(ObserverBlock::new);
+ public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
+
+ @Override
+ public MapCodec<ObserverBlock> codec() {
+- return CODEC;
++ return ObserverBlock.CODEC;
+ }
+
+ public ObserverBlock(BlockBehaviour.Properties properties) {
+ super(properties);
+- this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.SOUTH).setValue(POWERED, Boolean.valueOf(false)));
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(ObserverBlock.FACING, Direction.SOUTH)).setValue(ObserverBlock.POWERED, false));
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(FACING, POWERED);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(ObserverBlock.FACING, ObserverBlock.POWERED);
+ }
+
+ @Override
+- public BlockState rotate(BlockState state, Rotation rot) {
+- return state.setValue(FACING, rot.rotate(state.getValue(FACING)));
++ public IBlockData rotate(IBlockData state, Rotation rot) {
++ return (IBlockData) state.setValue(ObserverBlock.FACING, rot.rotate((Direction) state.getValue(ObserverBlock.FACING)));
+ }
+
+ @Override
+- public BlockState mirror(BlockState state, Mirror mirror) {
+- return state.rotate(mirror.getRotation(state.getValue(FACING)));
++ public IBlockData mirror(IBlockData state, Mirror mirror) {
++ return state.rotate(mirror.getRotation((Direction) state.getValue(ObserverBlock.FACING)));
+ }
+
+ @Override
+- public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
+- if (state.getValue(POWERED)) {
+- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(false)), 2);
++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
++ if ((Boolean) state.getValue(ObserverBlock.POWERED)) {
++ // CraftBukkit start
++ if (CraftEventFactory.callRedstoneChange(level, pos, 15, 0).getNewCurrent() != 0) {
++ return;
++ }
++ // CraftBukkit end
++ level.setBlock(pos, (IBlockData) state.setValue(ObserverBlock.POWERED, false), 2);
+ } else {
+- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 2);
+- level.scheduleTick(pos, this, 2);
++ // CraftBukkit start
++ if (CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) {
++ return;
++ }
++ // CraftBukkit end
++ level.setBlock(pos, (IBlockData) state.setValue(ObserverBlock.POWERED, true), 2);
++ level.scheduleTick(pos, (Block) this, 2);
+ }
+
+ this.updateNeighborsInFront(level, pos, state);
+ }
+
+ @Override
+- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
+- if (state.getValue(FACING) == facing && !state.getValue(POWERED)) {
++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
++ if (state.getValue(ObserverBlock.FACING) == facing && !(Boolean) state.getValue(ObserverBlock.POWERED)) {
+ this.startSignal(level, currentPos);
+ }
+
+@@ -67,54 +79,59 @@
+
+ private void startSignal(LevelAccessor level, BlockPos pos) {
+ if (!level.isClientSide() && !level.getBlockTicks().hasScheduledTick(pos, this)) {
+- level.scheduleTick(pos, this, 2);
++ level.scheduleTick(pos, (Block) this, 2);
+ }
++
+ }
+
+- protected void updateNeighborsInFront(Level level, BlockPos pos, BlockState state) {
+- Direction direction = state.getValue(FACING);
+- BlockPos blockPos = pos.relative(direction.getOpposite());
+- level.neighborChanged(blockPos, this, pos);
+- level.updateNeighborsAtExceptFromFacing(blockPos, this, direction);
++ protected void updateNeighborsInFront(Level level, BlockPos pos, IBlockData state) {
++ Direction enumdirection = (Direction) state.getValue(ObserverBlock.FACING);
++ BlockPos blockposition1 = pos.relative(enumdirection.getOpposite());
++
++ level.neighborChanged(blockposition1, this, pos);
++ level.updateNeighborsAtExceptFromFacing(blockposition1, this, enumdirection);
+ }
+
+ @Override
+- public boolean isSignalSource(BlockState state) {
++ public boolean isSignalSource(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- public int getDirectSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
+ return blockState.getSignal(blockAccess, pos, side);
+ }
+
+ @Override
+- public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
+- return blockState.getValue(POWERED) && blockState.getValue(FACING) == side ? 15 : 0;
++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ return (Boolean) blockState.getValue(ObserverBlock.POWERED) && blockState.getValue(ObserverBlock.FACING) == side ? 15 : 0;
+ }
+
+ @Override
+- public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) {
+ if (!state.is(oldState.getBlock())) {
+- if (!level.isClientSide() && state.getValue(POWERED) && !level.getBlockTicks().hasScheduledTick(pos, this)) {
+- BlockState blockState = state.setValue(POWERED, Boolean.valueOf(false));
+- level.setBlock(pos, blockState, 18);
+- this.updateNeighborsInFront(level, pos, blockState);
++ if (!level.isClientSide() && (Boolean) state.getValue(ObserverBlock.POWERED) && !level.getBlockTicks().hasScheduledTick(pos, this)) {
++ IBlockData iblockdata2 = (IBlockData) state.setValue(ObserverBlock.POWERED, false);
++
++ level.setBlock(pos, iblockdata2, 18);
++ this.updateNeighborsInFront(level, pos, iblockdata2);
+ }
++
+ }
+ }
+
+ @Override
+- public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) {
+ if (!state.is(newState.getBlock())) {
+- if (!level.isClientSide && state.getValue(POWERED) && level.getBlockTicks().hasScheduledTick(pos, this)) {
+- this.updateNeighborsInFront(level, pos, state.setValue(POWERED, Boolean.valueOf(false)));
++ if (!level.isClientSide && (Boolean) state.getValue(ObserverBlock.POWERED) && level.getBlockTicks().hasScheduledTick(pos, this)) {
++ this.updateNeighborsInFront(level, pos, (IBlockData) state.setValue(ObserverBlock.POWERED, false));
+ }
++
+ }
+ }
+
+ @Override
+- public BlockState getStateForPlacement(BlockPlaceContext context) {
+- return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection().getOpposite().getOpposite());
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ return (IBlockData) this.defaultBlockState().setValue(ObserverBlock.FACING, context.getNearestLookingDirection().getOpposite().getOpposite());
+ }
+ }