diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/ObserverBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/ObserverBlock.java.patch | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ObserverBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ObserverBlock.java.patch new file mode 100644 index 0000000000..25266b57d5 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ObserverBlock.java.patch @@ -0,0 +1,189 @@ +--- a/net/minecraft/world/level/block/ObserverBlock.java ++++ b/net/minecraft/world/level/block/ObserverBlock.java +@@ -10,129 +10,128 @@ + 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 +- @Override + public MapCodec<ObserverBlock> codec() { + return ObserverBlock.CODEC; + } + +- public ObserverBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(ObserverBlock.FACING, Direction.SOUTH)).setValue(ObserverBlock.POWERED, false)); ++ public ObserverBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(ObserverBlock.FACING, Direction.SOUTH)).setValue(ObserverBlock.POWERED, false)); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(ObserverBlock.FACING, ObserverBlock.POWERED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(ObserverBlock.FACING, ObserverBlock.POWERED); + } + + @Override +- @Override +- public BlockState rotate(BlockState blockstate, Rotation rotation) { +- return (BlockState) blockstate.setValue(ObserverBlock.FACING, rotation.rotate((Direction) blockstate.getValue(ObserverBlock.FACING))); ++ public IBlockData rotate(IBlockData state, Rotation rot) { ++ return (IBlockData) state.setValue(ObserverBlock.FACING, rot.rotate((Direction) state.getValue(ObserverBlock.FACING))); + } + + @Override +- @Override +- public BlockState mirror(BlockState blockstate, Mirror mirror) { +- return blockstate.rotate(mirror.getRotation((Direction) blockstate.getValue(ObserverBlock.FACING))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return state.rotate(mirror.getRotation((Direction) state.getValue(ObserverBlock.FACING))); + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- if ((Boolean) blockstate.getValue(ObserverBlock.POWERED)) { +- serverlevel.setBlock(blockpos, (BlockState) blockstate.setValue(ObserverBlock.POWERED, 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 { +- serverlevel.setBlock(blockpos, (BlockState) blockstate.setValue(ObserverBlock.POWERED, true), 2); +- serverlevel.scheduleTick(blockpos, (Block) 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(serverlevel, blockpos, blockstate); ++ this.updateNeighborsInFront(level, pos, state); + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if (blockstate.getValue(ObserverBlock.FACING) == direction && !(Boolean) blockstate.getValue(ObserverBlock.POWERED)) { +- this.startSignal(levelaccessor, blockpos); ++ 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); + } + +- return super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + +- private void startSignal(LevelAccessor levelaccessor, BlockPos blockpos) { +- if (!levelaccessor.isClientSide() && !levelaccessor.getBlockTicks().hasScheduledTick(blockpos, this)) { +- levelaccessor.scheduleTick(blockpos, (Block) this, 2); ++ private void startSignal(LevelAccessor level, BlockPos pos) { ++ if (!level.isClientSide() && !level.getBlockTicks().hasScheduledTick(pos, this)) { ++ level.scheduleTick(pos, (Block) this, 2); + } + + } + +- protected void updateNeighborsInFront(Level level, BlockPos blockpos, BlockState blockstate) { +- Direction direction = (Direction) blockstate.getValue(ObserverBlock.FACING); +- BlockPos blockpos1 = blockpos.relative(direction.getOpposite()); ++ protected void updateNeighborsInFront(Level level, BlockPos pos, IBlockData state) { ++ Direction enumdirection = (Direction) state.getValue(ObserverBlock.FACING); ++ BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); + +- level.neighborChanged(blockpos1, this, blockpos); +- level.updateNeighborsAtExceptFromFacing(blockpos1, this, direction); ++ level.neighborChanged(blockposition1, this, pos); ++ level.updateNeighborsAtExceptFromFacing(blockposition1, this, enumdirection); + } + + @Override +- @Override +- public boolean isSignalSource(BlockState blockstate) { ++ public boolean isSignalSource(IBlockData state) { + return true; + } + + @Override +- @Override +- public int getDirectSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return blockstate.getSignal(blockgetter, blockpos, direction); ++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return blockState.getSignal(blockAccess, pos, side); + } + + @Override +- @Override +- public int getSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return (Boolean) blockstate.getValue(ObserverBlock.POWERED) && blockstate.getValue(ObserverBlock.FACING) == direction ? 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 +- @Override +- public void onPlace(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate.is(blockstate1.getBlock())) { +- if (!level.isClientSide() && (Boolean) blockstate.getValue(ObserverBlock.POWERED) && !level.getBlockTicks().hasScheduledTick(blockpos, this)) { +- BlockState blockstate2 = (BlockState) blockstate.setValue(ObserverBlock.POWERED, false); ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { ++ if (!state.is(oldState.getBlock())) { ++ if (!level.isClientSide() && (Boolean) state.getValue(ObserverBlock.POWERED) && !level.getBlockTicks().hasScheduledTick(pos, this)) { ++ IBlockData iblockdata2 = (IBlockData) state.setValue(ObserverBlock.POWERED, false); + +- level.setBlock(blockpos, blockstate2, 18); +- this.updateNeighborsInFront(level, blockpos, blockstate2); ++ level.setBlock(pos, iblockdata2, 18); ++ this.updateNeighborsInFront(level, pos, iblockdata2); + } + + } + } + + @Override +- @Override +- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate.is(blockstate1.getBlock())) { +- if (!level.isClientSide && (Boolean) blockstate.getValue(ObserverBlock.POWERED) && level.getBlockTicks().hasScheduledTick(blockpos, this)) { +- this.updateNeighborsInFront(level, blockpos, (BlockState) blockstate.setValue(ObserverBlock.POWERED, false)); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) { ++ if (!state.is(newState.getBlock())) { ++ if (!level.isClientSide && (Boolean) state.getValue(ObserverBlock.POWERED) && level.getBlockTicks().hasScheduledTick(pos, this)) { ++ this.updateNeighborsInFront(level, pos, (IBlockData) state.setValue(ObserverBlock.POWERED, false)); + } + + } + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- return (BlockState) this.defaultBlockState().setValue(ObserverBlock.FACING, blockplacecontext.getNearestLookingDirection().getOpposite().getOpposite()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(ObserverBlock.FACING, context.getNearestLookingDirection().getOpposite().getOpposite()); + } + } |