aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch370
1 files changed, 370 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch
new file mode 100644
index 0000000000..d2d0babfe9
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireHookBlock.java.patch
@@ -0,0 +1,370 @@
+--- a/net/minecraft/world/level/block/TripWireHookBlock.java
++++ b/net/minecraft/world/level/block/TripWireHookBlock.java
+@@ -20,7 +20,7 @@
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.LevelReader;
+ 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;
+@@ -28,6 +28,10 @@
+ import net.minecraft.world.level.gameevent.GameEvent;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++// CraftBukkit start
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.event.block.BlockRedstoneEvent;
++// CraftBukkit end
+
+ public class TripWireHookBlock extends Block {
+
+@@ -45,20 +49,18 @@
+ protected static final VoxelShape EAST_AABB = Block.box(0.0D, 0.0D, 5.0D, 6.0D, 10.0D, 11.0D);
+
+ @Override
+- @Override
+ public MapCodec<TripWireHookBlock> codec() {
+ return TripWireHookBlock.CODEC;
+ }
+
+- public TripWireHookBlock(BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
+- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(TripWireHookBlock.FACING, Direction.NORTH)).setValue(TripWireHookBlock.POWERED, false)).setValue(TripWireHookBlock.ATTACHED, false));
++ public TripWireHookBlock(BlockBehaviour.Properties properties) {
++ super(properties);
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(TripWireHookBlock.FACING, Direction.NORTH)).setValue(TripWireHookBlock.POWERED, false)).setValue(TripWireHookBlock.ATTACHED, false));
+ }
+
+ @Override
+- @Override
+- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) {
+- switch ((Direction) blockstate.getValue(TripWireHookBlock.FACING)) {
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ switch ((Direction) state.getValue(TripWireHookBlock.FACING)) {
+ case EAST:
+ default:
+ return TripWireHookBlock.EAST_AABB;
+@@ -72,41 +74,38 @@
+ }
+
+ @Override
+- @Override
+- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) {
+- Direction direction = (Direction) blockstate.getValue(TripWireHookBlock.FACING);
+- BlockPos blockpos1 = blockpos.relative(direction.getOpposite());
+- BlockState blockstate1 = levelreader.getBlockState(blockpos1);
++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) {
++ Direction enumdirection = (Direction) state.getValue(TripWireHookBlock.FACING);
++ BlockPos blockposition1 = pos.relative(enumdirection.getOpposite());
++ IBlockData iblockdata1 = level.getBlockState(blockposition1);
+
+- return direction.getAxis().isHorizontal() && blockstate1.isFaceSturdy(levelreader, blockpos1, direction);
++ return enumdirection.getAxis().isHorizontal() && iblockdata1.isFaceSturdy(level, blockposition1, enumdirection);
+ }
+
+ @Override
+- @Override
+- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) {
+- return direction.getOpposite() == blockstate.getValue(TripWireHookBlock.FACING) && !blockstate.canSurvive(levelaccessor, blockpos) ? Blocks.AIR.defaultBlockState() : super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1);
++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
++ return facing.getOpposite() == state.getValue(TripWireHookBlock.FACING) && !state.canSurvive(level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
+ }
+
+ @Nullable
+ @Override
+- @Override
+- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) {
+- BlockState blockstate = (BlockState) ((BlockState) this.defaultBlockState().setValue(TripWireHookBlock.POWERED, false)).setValue(TripWireHookBlock.ATTACHED, false);
+- Level level = blockplacecontext.getLevel();
+- BlockPos blockpos = blockplacecontext.getClickedPos();
+- Direction[] adirection = blockplacecontext.getNearestLookingDirections();
+- Direction[] adirection1 = adirection;
+- int i = adirection.length;
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ IBlockData iblockdata = (IBlockData) ((IBlockData) this.defaultBlockState().setValue(TripWireHookBlock.POWERED, false)).setValue(TripWireHookBlock.ATTACHED, false);
++ Level world = context.getLevel();
++ BlockPos blockposition = context.getClickedPos();
++ Direction[] aenumdirection = context.getNearestLookingDirections();
++ Direction[] aenumdirection1 = aenumdirection;
++ int i = aenumdirection.length;
+
+ for (int j = 0; j < i; ++j) {
+- Direction direction = adirection1[j];
++ Direction enumdirection = aenumdirection1[j];
+
+- if (direction.getAxis().isHorizontal()) {
+- Direction direction1 = direction.getOpposite();
++ if (enumdirection.getAxis().isHorizontal()) {
++ Direction enumdirection1 = enumdirection.getOpposite();
+
+- blockstate = (BlockState) blockstate.setValue(TripWireHookBlock.FACING, direction1);
+- if (blockstate.canSurvive(level, blockpos)) {
+- return blockstate;
++ iblockdata = (IBlockData) iblockdata.setValue(TripWireHookBlock.FACING, enumdirection1);
++ if (iblockdata.canSurvive(world, blockposition)) {
++ return iblockdata;
+ }
+ }
+ }
+@@ -115,52 +114,51 @@
+ }
+
+ @Override
+- @Override
+- public void setPlacedBy(Level level, BlockPos blockpos, BlockState blockstate, LivingEntity livingentity, ItemStack itemstack) {
+- calculateState(level, blockpos, blockstate, false, false, -1, (BlockState) null);
++ public void setPlacedBy(Level level, BlockPos pos, IBlockData state, LivingEntity placer, ItemStack stack) {
++ calculateState(level, pos, state, false, false, -1, (IBlockData) null);
+ }
+
+- public static void calculateState(Level level, BlockPos blockpos, BlockState blockstate, boolean flag, boolean flag1, int i, @Nullable BlockState blockstate1) {
+- Optional<Direction> optional = blockstate.getOptionalValue(TripWireHookBlock.FACING);
++ public static void calculateState(Level world, BlockPos level, IBlockData pos, boolean hookState, boolean attaching, int shouldNotifyNeighbours, @Nullable IBlockData searchRange) {
++ Optional<Direction> optional = pos.getOptionalValue(TripWireHookBlock.FACING);
+
+ if (optional.isPresent()) {
+- Direction direction = (Direction) optional.get();
+- boolean flag2 = (Boolean) blockstate.getOptionalValue(TripWireHookBlock.ATTACHED).orElse(false);
+- boolean flag3 = (Boolean) blockstate.getOptionalValue(TripWireHookBlock.POWERED).orElse(false);
+- Block block = blockstate.getBlock();
+- boolean flag4 = !flag;
++ Direction enumdirection = (Direction) optional.get();
++ boolean flag2 = (Boolean) pos.getOptionalValue(TripWireHookBlock.ATTACHED).orElse(false);
++ boolean flag3 = (Boolean) pos.getOptionalValue(TripWireHookBlock.POWERED).orElse(false);
++ Block block = pos.getBlock();
++ boolean flag4 = !hookState;
+ boolean flag5 = false;
+ int j = 0;
+- BlockState[] ablockstate = new BlockState[42];
++ IBlockData[] aiblockdata = new IBlockData[42];
+
+- BlockPos blockpos1;
++ BlockPos blockposition1;
+
+ for (int k = 1; k < 42; ++k) {
+- blockpos1 = blockpos.relative(direction, k);
+- BlockState blockstate2 = level.getBlockState(blockpos1);
++ blockposition1 = level.relative(enumdirection, k);
++ IBlockData iblockdata2 = world.getBlockState(blockposition1);
+
+- if (blockstate2.is(Blocks.TRIPWIRE_HOOK)) {
+- if (blockstate2.getValue(TripWireHookBlock.FACING) == direction.getOpposite()) {
++ if (iblockdata2.is(Blocks.TRIPWIRE_HOOK)) {
++ if (iblockdata2.getValue(TripWireHookBlock.FACING) == enumdirection.getOpposite()) {
+ j = k;
+ }
+ break;
+ }
+
+- if (!blockstate2.is(Blocks.TRIPWIRE) && k != i) {
+- ablockstate[k] = null;
++ if (!iblockdata2.is(Blocks.TRIPWIRE) && k != shouldNotifyNeighbours) {
++ aiblockdata[k] = null;
+ flag4 = false;
+ } else {
+- if (k == i) {
+- blockstate2 = (BlockState) MoreObjects.firstNonNull(blockstate1, blockstate2);
++ if (k == shouldNotifyNeighbours) {
++ iblockdata2 = (IBlockData) MoreObjects.firstNonNull(searchRange, iblockdata2);
+ }
+
+- boolean flag6 = !(Boolean) blockstate2.getValue(TripWireBlock.DISARMED);
+- boolean flag7 = (Boolean) blockstate2.getValue(TripWireBlock.POWERED);
++ boolean flag6 = !(Boolean) iblockdata2.getValue(TripWireBlock.DISARMED);
++ boolean flag7 = (Boolean) iblockdata2.getValue(TripWireBlock.POWERED);
+
+ flag5 |= flag6 && flag7;
+- ablockstate[k] = blockstate2;
+- if (k == i) {
+- level.scheduleTick(blockpos, block, 10);
++ aiblockdata[k] = iblockdata2;
++ if (k == shouldNotifyNeighbours) {
++ world.scheduleTick(level, block, 10);
+ flag4 &= flag6;
+ }
+ }
+@@ -168,33 +166,42 @@
+
+ flag4 &= j > 1;
+ flag5 &= flag4;
+- BlockState blockstate3 = (BlockState) ((BlockState) block.defaultBlockState().trySetValue(TripWireHookBlock.ATTACHED, flag4)).trySetValue(TripWireHookBlock.POWERED, flag5);
++ IBlockData iblockdata3 = (IBlockData) ((IBlockData) block.defaultBlockState().trySetValue(TripWireHookBlock.ATTACHED, flag4)).trySetValue(TripWireHookBlock.POWERED, flag5);
+
+ if (j > 0) {
+- blockpos1 = blockpos.relative(direction, j);
+- Direction direction1 = direction.getOpposite();
++ blockposition1 = level.relative(enumdirection, j);
++ Direction enumdirection1 = enumdirection.getOpposite();
+
+- level.setBlock(blockpos1, (BlockState) blockstate3.setValue(TripWireHookBlock.FACING, direction1), 3);
+- notifyNeighbors(block, level, blockpos1, direction1);
+- emitState(level, blockpos1, flag4, flag5, flag2, flag3);
++ world.setBlock(blockposition1, (IBlockData) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection1), 3);
++ notifyNeighbors(block, world, blockposition1, enumdirection1);
++ emitState(world, blockposition1, flag4, flag5, flag2, flag3);
+ }
+
+- emitState(level, blockpos, flag4, flag5, flag2, flag3);
+- if (!flag) {
+- level.setBlock(blockpos, (BlockState) blockstate3.setValue(TripWireHookBlock.FACING, direction), 3);
+- if (flag1) {
+- notifyNeighbors(block, level, blockpos, direction);
++ // CraftBukkit start
++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, level), 15, 0);
++ world.getCraftServer().getPluginManager().callEvent(eventRedstone);
++
++ if (eventRedstone.getNewCurrent() > 0) {
++ return;
++ }
++ // CraftBukkit end
++
++ emitState(world, level, flag4, flag5, flag2, flag3);
++ if (!hookState) {
++ world.setBlock(level, (IBlockData) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3);
++ if (attaching) {
++ notifyNeighbors(block, world, level, enumdirection);
+ }
+ }
+
+ if (flag2 != flag4) {
+ for (int l = 1; l < j; ++l) {
+- BlockPos blockpos2 = blockpos.relative(direction, l);
+- BlockState blockstate4 = ablockstate[l];
++ BlockPos blockposition2 = level.relative(enumdirection, l);
++ IBlockData iblockdata4 = aiblockdata[l];
+
+- if (blockstate4 != null) {
+- level.setBlock(blockpos2, (BlockState) blockstate4.trySetValue(TripWireHookBlock.ATTACHED, flag4), 3);
+- if (!level.getBlockState(blockpos2).isAir()) {
++ if (iblockdata4 != null) {
++ world.setBlock(blockposition2, (IBlockData) iblockdata4.trySetValue(TripWireHookBlock.ATTACHED, flag4), 3);
++ if (!world.getBlockState(blockposition2).isAir()) {
+ ;
+ }
+ }
+@@ -205,86 +212,78 @@
+ }
+
+ @Override
+- @Override
+- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) {
+- calculateState(serverlevel, blockpos, blockstate, false, true, -1, (BlockState) null);
++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
++ calculateState(level, pos, state, false, true, -1, (IBlockData) null);
+ }
+
+- private static void emitState(Level level, BlockPos blockpos, boolean flag, boolean flag1, boolean flag2, boolean flag3) {
+- if (flag1 && !flag3) {
+- level.playSound((Player) null, blockpos, SoundEvents.TRIPWIRE_CLICK_ON, SoundSource.BLOCKS, 0.4F, 0.6F);
+- level.gameEvent((Entity) null, GameEvent.BLOCK_ACTIVATE, blockpos);
+- } else if (!flag1 && flag3) {
+- level.playSound((Player) null, blockpos, SoundEvents.TRIPWIRE_CLICK_OFF, SoundSource.BLOCKS, 0.4F, 0.5F);
+- level.gameEvent((Entity) null, GameEvent.BLOCK_DEACTIVATE, blockpos);
+- } else if (flag && !flag2) {
+- level.playSound((Player) null, blockpos, SoundEvents.TRIPWIRE_ATTACH, SoundSource.BLOCKS, 0.4F, 0.7F);
+- level.gameEvent((Entity) null, GameEvent.BLOCK_ATTACH, blockpos);
+- } else if (!flag && flag2) {
+- level.playSound((Player) null, blockpos, SoundEvents.TRIPWIRE_DETACH, SoundSource.BLOCKS, 0.4F, 1.2F / (level.random.nextFloat() * 0.2F + 0.9F));
+- level.gameEvent((Entity) null, GameEvent.BLOCK_DETACH, blockpos);
++ private static void emitState(Level world, BlockPos level, boolean pos, boolean attached, boolean powered, boolean wasAttached) {
++ if (attached && !wasAttached) {
++ world.playSound((Player) null, level, SoundEvents.TRIPWIRE_CLICK_ON, SoundSource.BLOCKS, 0.4F, 0.6F);
++ world.gameEvent((Entity) null, GameEvent.BLOCK_ACTIVATE, level);
++ } else if (!attached && wasAttached) {
++ world.playSound((Player) null, level, SoundEvents.TRIPWIRE_CLICK_OFF, SoundSource.BLOCKS, 0.4F, 0.5F);
++ world.gameEvent((Entity) null, GameEvent.BLOCK_DEACTIVATE, level);
++ } else if (pos && !powered) {
++ world.playSound((Player) null, level, SoundEvents.TRIPWIRE_ATTACH, SoundSource.BLOCKS, 0.4F, 0.7F);
++ world.gameEvent((Entity) null, GameEvent.BLOCK_ATTACH, level);
++ } else if (!pos && powered) {
++ world.playSound((Player) null, level, SoundEvents.TRIPWIRE_DETACH, SoundSource.BLOCKS, 0.4F, 1.2F / (world.random.nextFloat() * 0.2F + 0.9F));
++ world.gameEvent((Entity) null, GameEvent.BLOCK_DETACH, level);
+ }
+
+ }
+
+- private static void notifyNeighbors(Block block, Level level, BlockPos blockpos, Direction direction) {
+- level.updateNeighborsAt(blockpos, block);
+- level.updateNeighborsAt(blockpos.relative(direction.getOpposite()), block);
++ private static void notifyNeighbors(Block block, Level world, BlockPos blockposition, Direction enumdirection) {
++ world.updateNeighborsAt(blockposition, block);
++ world.updateNeighborsAt(blockposition.relative(enumdirection.getOpposite()), block);
+ }
+
+ @Override
+- @Override
+- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) {
+- if (!flag && !blockstate.is(blockstate1.getBlock())) {
+- boolean flag1 = (Boolean) blockstate.getValue(TripWireHookBlock.ATTACHED);
+- boolean flag2 = (Boolean) blockstate.getValue(TripWireHookBlock.POWERED);
++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) {
++ if (!isMoving && !state.is(newState.getBlock())) {
++ boolean flag1 = (Boolean) state.getValue(TripWireHookBlock.ATTACHED);
++ boolean flag2 = (Boolean) state.getValue(TripWireHookBlock.POWERED);
+
+ if (flag1 || flag2) {
+- calculateState(level, blockpos, blockstate, true, false, -1, (BlockState) null);
++ calculateState(level, pos, state, true, false, -1, (IBlockData) null);
+ }
+
+ if (flag2) {
+- level.updateNeighborsAt(blockpos, this);
+- level.updateNeighborsAt(blockpos.relative(((Direction) blockstate.getValue(TripWireHookBlock.FACING)).getOpposite()), this);
++ level.updateNeighborsAt(pos, this);
++ level.updateNeighborsAt(pos.relative(((Direction) state.getValue(TripWireHookBlock.FACING)).getOpposite()), this);
+ }
+
+- super.onRemove(blockstate, level, blockpos, blockstate1, flag);
++ super.onRemove(state, level, pos, newState, isMoving);
+ }
+ }
+
+ @Override
+- @Override
+- public int getSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) {
+- return (Boolean) blockstate.getValue(TripWireHookBlock.POWERED) ? 15 : 0;
++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ return (Boolean) blockState.getValue(TripWireHookBlock.POWERED) ? 15 : 0;
+ }
+
+ @Override
+- @Override
+- public int getDirectSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) {
+- return !(Boolean) blockstate.getValue(TripWireHookBlock.POWERED) ? 0 : (blockstate.getValue(TripWireHookBlock.FACING) == direction ? 15 : 0);
++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) {
++ return !(Boolean) blockState.getValue(TripWireHookBlock.POWERED) ? 0 : (blockState.getValue(TripWireHookBlock.FACING) == side ? 15 : 0);
+ }
+
+ @Override
+- @Override
+- public boolean isSignalSource(BlockState blockstate) {
++ public boolean isSignalSource(IBlockData state) {
+ return true;
+ }
+
+ @Override
+- @Override
+- public BlockState rotate(BlockState blockstate, Rotation rotation) {
+- return (BlockState) blockstate.setValue(TripWireHookBlock.FACING, rotation.rotate((Direction) blockstate.getValue(TripWireHookBlock.FACING)));
++ public IBlockData rotate(IBlockData state, Rotation rotation) {
++ return (IBlockData) state.setValue(TripWireHookBlock.FACING, rotation.rotate((Direction) state.getValue(TripWireHookBlock.FACING)));
+ }
+
+ @Override
+- @Override
+- public BlockState mirror(BlockState blockstate, Mirror mirror) {
+- return blockstate.rotate(mirror.getRotation((Direction) blockstate.getValue(TripWireHookBlock.FACING)));
++ public IBlockData mirror(IBlockData state, Mirror mirror) {
++ return state.rotate(mirror.getRotation((Direction) state.getValue(TripWireHookBlock.FACING)));
+ }
+
+ @Override
+- @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) {
+- statedefinition_builder.add(TripWireHookBlock.FACING, TripWireHookBlock.POWERED, TripWireHookBlock.ATTACHED);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(TripWireHookBlock.FACING, TripWireHookBlock.POWERED, TripWireHookBlock.ATTACHED);
+ }
+ }