aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch289
1 files changed, 289 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch
new file mode 100644
index 0000000000..73e4c2de2c
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TripWireBlock.java.patch
@@ -0,0 +1,289 @@
+--- a/net/minecraft/world/level/block/TripWireBlock.java
++++ b/net/minecraft/world/level/block/TripWireBlock.java
+@@ -18,7 +18,7 @@
+ 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;
+@@ -26,12 +26,13 @@
+ import net.minecraft.world.level.gameevent.GameEvent;
+ import net.minecraft.world.phys.shapes.CollisionContext;
+ import net.minecraft.world.phys.shapes.VoxelShape;
++import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
+ public class TripWireBlock extends Block {
+
+ public static final MapCodec<TripWireBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+- return instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("hook").forGetter((tripwireblock) -> {
+- return tripwireblock.hook;
++ return instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("hook").forGetter((blocktripwire) -> {
++ return blocktripwire.hook;
+ }), propertiesCodec()).apply(instance, TripWireBlock::new);
+ });
+ public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
+@@ -48,84 +49,77 @@
+ private final Block hook;
+
+ @Override
+- @Override
+ public MapCodec<TripWireBlock> codec() {
+ return TripWireBlock.CODEC;
+ }
+
+- public TripWireBlock(Block block, BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
+- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(TripWireBlock.POWERED, false)).setValue(TripWireBlock.ATTACHED, false)).setValue(TripWireBlock.DISARMED, false)).setValue(TripWireBlock.NORTH, false)).setValue(TripWireBlock.EAST, false)).setValue(TripWireBlock.SOUTH, false)).setValue(TripWireBlock.WEST, false));
++ public TripWireBlock(Block block, BlockBehaviour.Properties blockbase_info) {
++ super(blockbase_info);
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(TripWireBlock.POWERED, false)).setValue(TripWireBlock.ATTACHED, false)).setValue(TripWireBlock.DISARMED, false)).setValue(TripWireBlock.NORTH, false)).setValue(TripWireBlock.EAST, false)).setValue(TripWireBlock.SOUTH, false)).setValue(TripWireBlock.WEST, false));
+ this.hook = block;
+ }
+
+ @Override
+- @Override
+- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) {
+- return (Boolean) blockstate.getValue(TripWireBlock.ATTACHED) ? TripWireBlock.AABB : TripWireBlock.NOT_ATTACHED_AABB;
++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
++ return (Boolean) state.getValue(TripWireBlock.ATTACHED) ? TripWireBlock.AABB : TripWireBlock.NOT_ATTACHED_AABB;
+ }
+
+ @Override
+- @Override
+- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) {
+- Level level = blockplacecontext.getLevel();
+- BlockPos blockpos = blockplacecontext.getClickedPos();
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ Level world = context.getLevel();
++ BlockPos blockposition = context.getClickedPos();
+
+- return (BlockState) ((BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(TripWireBlock.NORTH, this.shouldConnectTo(level.getBlockState(blockpos.north()), Direction.NORTH))).setValue(TripWireBlock.EAST, this.shouldConnectTo(level.getBlockState(blockpos.east()), Direction.EAST))).setValue(TripWireBlock.SOUTH, this.shouldConnectTo(level.getBlockState(blockpos.south()), Direction.SOUTH))).setValue(TripWireBlock.WEST, this.shouldConnectTo(level.getBlockState(blockpos.west()), Direction.WEST));
++ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(TripWireBlock.NORTH, this.shouldConnectTo(world.getBlockState(blockposition.north()), Direction.NORTH))).setValue(TripWireBlock.EAST, this.shouldConnectTo(world.getBlockState(blockposition.east()), Direction.EAST))).setValue(TripWireBlock.SOUTH, this.shouldConnectTo(world.getBlockState(blockposition.south()), Direction.SOUTH))).setValue(TripWireBlock.WEST, this.shouldConnectTo(world.getBlockState(blockposition.west()), Direction.WEST));
+ }
+
+ @Override
+- @Override
+- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) {
+- return direction.getAxis().isHorizontal() ? (BlockState) blockstate.setValue((Property) TripWireBlock.PROPERTY_BY_DIRECTION.get(direction), this.shouldConnectTo(blockstate1, direction)) : 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.getAxis().isHorizontal() ? (IBlockData) state.setValue((Property) TripWireBlock.PROPERTY_BY_DIRECTION.get(facing), this.shouldConnectTo(facingState, facing)) : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
+ }
+
+ @Override
+- @Override
+- public void onPlace(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) {
+- if (!blockstate1.is(blockstate.getBlock())) {
+- this.updateSource(level, blockpos, blockstate);
++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) {
++ if (!oldState.is(state.getBlock())) {
++ this.updateSource(level, pos, state);
+ }
+ }
+
+ @Override
+- @Override
+- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) {
+- if (!flag && !blockstate.is(blockstate1.getBlock())) {
+- this.updateSource(level, blockpos, (BlockState) blockstate.setValue(TripWireBlock.POWERED, true));
++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) {
++ if (!isMoving && !state.is(newState.getBlock())) {
++ this.updateSource(level, pos, (IBlockData) state.setValue(TripWireBlock.POWERED, true));
+ }
+ }
+
+ @Override
+- @Override
+- public BlockState playerWillDestroy(Level level, BlockPos blockpos, BlockState blockstate, Player player) {
+- if (!level.isClientSide && !player.getMainHandItem().isEmpty() && player.getMainHandItem().is(Items.SHEARS)) {
+- level.setBlock(blockpos, (BlockState) blockstate.setValue(TripWireBlock.DISARMED, true), 4);
+- level.gameEvent((Entity) player, GameEvent.SHEAR, blockpos);
++ public IBlockData playerWillDestroy(Level world, BlockPos blockposition, IBlockData iblockdata, Player entityhuman) {
++ if (!world.isClientSide && !entityhuman.getMainHandItem().isEmpty() && entityhuman.getMainHandItem().is(Items.SHEARS)) {
++ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(TripWireBlock.DISARMED, true), 4);
++ world.gameEvent((Entity) entityhuman, GameEvent.SHEAR, blockposition);
+ }
+
+- return super.playerWillDestroy(level, blockpos, blockstate, player);
++ return super.playerWillDestroy(world, blockposition, iblockdata, entityhuman);
+ }
+
+- private void updateSource(Level level, BlockPos blockpos, BlockState blockstate) {
+- Direction[] adirection = new Direction[]{Direction.SOUTH, Direction.WEST};
+- int i = adirection.length;
++ private void updateSource(Level level, BlockPos pos, IBlockData state) {
++ Direction[] aenumdirection = new Direction[]{Direction.SOUTH, Direction.WEST};
++ int i = aenumdirection.length;
+ int j = 0;
+
+ while (j < i) {
+- Direction direction = adirection[j];
++ Direction enumdirection = aenumdirection[j];
+ int k = 1;
+
+ while (true) {
+ if (k < 42) {
+- BlockPos blockpos1 = blockpos.relative(direction, k);
+- BlockState blockstate1 = level.getBlockState(blockpos1);
++ BlockPos blockposition1 = pos.relative(enumdirection, k);
++ IBlockData iblockdata1 = level.getBlockState(blockposition1);
+
+- if (blockstate1.is(this.hook)) {
+- if (blockstate1.getValue(TripWireHookBlock.FACING) == direction.getOpposite()) {
+- TripWireHookBlock.calculateState(level, blockpos1, blockstate1, false, true, k, blockstate);
++ if (iblockdata1.is(this.hook)) {
++ if (iblockdata1.getValue(TripWireHookBlock.FACING) == enumdirection.getOpposite()) {
++ TripWireHookBlock.calculateState(level, blockposition1, iblockdata1, false, true, k, state);
+ }
+- } else if (blockstate1.is((Block) this)) {
++ } else if (iblockdata1.is((Block) this)) {
+ ++k;
+ continue;
+ }
+@@ -139,28 +133,26 @@
+ }
+
+ @Override
+- @Override
+- public void entityInside(BlockState blockstate, Level level, BlockPos blockpos, Entity entity) {
++ public void entityInside(IBlockData state, Level level, BlockPos pos, Entity entity) {
+ if (!level.isClientSide) {
+- if (!(Boolean) blockstate.getValue(TripWireBlock.POWERED)) {
+- this.checkPressed(level, blockpos);
++ if (!(Boolean) state.getValue(TripWireBlock.POWERED)) {
++ this.checkPressed(level, pos);
+ }
+ }
+ }
+
+ @Override
+- @Override
+- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) {
+- if ((Boolean) serverlevel.getBlockState(blockpos).getValue(TripWireBlock.POWERED)) {
+- this.checkPressed(serverlevel, blockpos);
++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) {
++ if ((Boolean) level.getBlockState(pos).getValue(TripWireBlock.POWERED)) {
++ this.checkPressed(level, pos);
+ }
+ }
+
+- private void checkPressed(Level level, BlockPos blockpos) {
+- BlockState blockstate = level.getBlockState(blockpos);
+- boolean flag = (Boolean) blockstate.getValue(TripWireBlock.POWERED);
++ private void checkPressed(Level level, BlockPos pos) {
++ IBlockData iblockdata = level.getBlockState(pos);
++ boolean flag = (Boolean) iblockdata.getValue(TripWireBlock.POWERED);
+ boolean flag1 = false;
+- List<? extends Entity> list = level.getEntities((Entity) null, blockstate.getShape(level, blockpos).bounds().move(blockpos));
++ List<? extends Entity> list = level.getEntities((Entity) null, iblockdata.getShape(level, pos).bounds().move(pos));
+
+ if (!list.isEmpty()) {
+ Iterator iterator = list.iterator();
+@@ -175,53 +167,84 @@
+ }
+ }
+
++ // CraftBukkit start - Call interact even when triggering connected tripwire
++ if (flag != flag1 && flag1 && (Boolean)iblockdata.getValue(ATTACHED)) {
++ org.bukkit.World bworld = level.getWorld();
++ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager();
++ org.bukkit.block.Block block = bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ());
++ boolean allowed = false;
++
++ // If all of the events are cancelled block the tripwire trigger, else allow
++ for (Object object : list) {
++ if (object != null) {
++ org.bukkit.event.Cancellable cancellable;
++
++ if (object instanceof Player) {
++ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((Player) object, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null);
++ } else if (object instanceof Entity) {
++ cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
++ manager.callEvent((EntityInteractEvent) cancellable);
++ } else {
++ continue;
++ }
++
++ if (!cancellable.isCancelled()) {
++ allowed = true;
++ break;
++ }
++ }
++ }
++
++ if (!allowed) {
++ return;
++ }
++ }
++ // CraftBukkit end
++
+ if (flag1 != flag) {
+- blockstate = (BlockState) blockstate.setValue(TripWireBlock.POWERED, flag1);
+- level.setBlock(blockpos, blockstate, 3);
+- this.updateSource(level, blockpos, blockstate);
++ iblockdata = (IBlockData) iblockdata.setValue(TripWireBlock.POWERED, flag1);
++ level.setBlock(pos, iblockdata, 3);
++ this.updateSource(level, pos, iblockdata);
+ }
+
+ if (flag1) {
+- level.scheduleTick(new BlockPos(blockpos), (Block) this, 10);
++ level.scheduleTick(new BlockPos(pos), (Block) this, 10);
+ }
+
+ }
+
+- public boolean shouldConnectTo(BlockState blockstate, Direction direction) {
+- return blockstate.is(this.hook) ? blockstate.getValue(TripWireHookBlock.FACING) == direction.getOpposite() : blockstate.is((Block) this);
++ public boolean shouldConnectTo(IBlockData state, Direction direction) {
++ return state.is(this.hook) ? state.getValue(TripWireHookBlock.FACING) == direction.getOpposite() : state.is((Block) this);
+ }
+
+ @Override
+- @Override
+- public BlockState rotate(BlockState blockstate, Rotation rotation) {
+- switch (rotation) {
++ public IBlockData rotate(IBlockData state, Rotation rot) {
++ switch (rot) {
+ case CLOCKWISE_180:
+- return (BlockState) ((BlockState) ((BlockState) ((BlockState) blockstate.setValue(TripWireBlock.NORTH, (Boolean) blockstate.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.EAST, (Boolean) blockstate.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.SOUTH, (Boolean) blockstate.getValue(TripWireBlock.NORTH))).setValue(TripWireBlock.WEST, (Boolean) blockstate.getValue(TripWireBlock.EAST));
++ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) state.setValue(TripWireBlock.NORTH, (Boolean) state.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.EAST, (Boolean) state.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.SOUTH, (Boolean) state.getValue(TripWireBlock.NORTH))).setValue(TripWireBlock.WEST, (Boolean) state.getValue(TripWireBlock.EAST));
+ case COUNTERCLOCKWISE_90:
+- return (BlockState) ((BlockState) ((BlockState) ((BlockState) blockstate.setValue(TripWireBlock.NORTH, (Boolean) blockstate.getValue(TripWireBlock.EAST))).setValue(TripWireBlock.EAST, (Boolean) blockstate.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.SOUTH, (Boolean) blockstate.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.WEST, (Boolean) blockstate.getValue(TripWireBlock.NORTH));
++ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) state.setValue(TripWireBlock.NORTH, (Boolean) state.getValue(TripWireBlock.EAST))).setValue(TripWireBlock.EAST, (Boolean) state.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.SOUTH, (Boolean) state.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.WEST, (Boolean) state.getValue(TripWireBlock.NORTH));
+ case CLOCKWISE_90:
+- return (BlockState) ((BlockState) ((BlockState) ((BlockState) blockstate.setValue(TripWireBlock.NORTH, (Boolean) blockstate.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.EAST, (Boolean) blockstate.getValue(TripWireBlock.NORTH))).setValue(TripWireBlock.SOUTH, (Boolean) blockstate.getValue(TripWireBlock.EAST))).setValue(TripWireBlock.WEST, (Boolean) blockstate.getValue(TripWireBlock.SOUTH));
++ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) state.setValue(TripWireBlock.NORTH, (Boolean) state.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.EAST, (Boolean) state.getValue(TripWireBlock.NORTH))).setValue(TripWireBlock.SOUTH, (Boolean) state.getValue(TripWireBlock.EAST))).setValue(TripWireBlock.WEST, (Boolean) state.getValue(TripWireBlock.SOUTH));
+ default:
+- return blockstate;
++ return state;
+ }
+ }
+
+ @Override
+- @Override
+- public BlockState mirror(BlockState blockstate, Mirror mirror) {
++ public IBlockData mirror(IBlockData state, Mirror mirror) {
+ switch (mirror) {
+ case LEFT_RIGHT:
+- return (BlockState) ((BlockState) blockstate.setValue(TripWireBlock.NORTH, (Boolean) blockstate.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.SOUTH, (Boolean) blockstate.getValue(TripWireBlock.NORTH));
++ return (IBlockData) ((IBlockData) state.setValue(TripWireBlock.NORTH, (Boolean) state.getValue(TripWireBlock.SOUTH))).setValue(TripWireBlock.SOUTH, (Boolean) state.getValue(TripWireBlock.NORTH));
+ case FRONT_BACK:
+- return (BlockState) ((BlockState) blockstate.setValue(TripWireBlock.EAST, (Boolean) blockstate.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.WEST, (Boolean) blockstate.getValue(TripWireBlock.EAST));
++ return (IBlockData) ((IBlockData) state.setValue(TripWireBlock.EAST, (Boolean) state.getValue(TripWireBlock.WEST))).setValue(TripWireBlock.WEST, (Boolean) state.getValue(TripWireBlock.EAST));
+ default:
+- return super.mirror(blockstate, mirror);
++ return super.mirror(state, mirror);
+ }
+ }
+
+ @Override
+- @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) {
+- statedefinition_builder.add(TripWireBlock.POWERED, TripWireBlock.ATTACHED, TripWireBlock.DISARMED, TripWireBlock.NORTH, TripWireBlock.EAST, TripWireBlock.WEST, TripWireBlock.SOUTH);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(TripWireBlock.POWERED, TripWireBlock.ATTACHED, TripWireBlock.DISARMED, TripWireBlock.NORTH, TripWireBlock.EAST, TripWireBlock.WEST, TripWireBlock.SOUTH);
+ }
+ }