diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch | 225 |
1 files changed, 225 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch new file mode 100644 index 0000000000..771b25481b --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch @@ -0,0 +1,225 @@ +--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java ++++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java +@@ -15,12 +15,13 @@ + 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.properties.BlockSetType; + import net.minecraft.world.level.gameevent.GameEvent; + import net.minecraft.world.phys.AABB; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + + public abstract class BasePressurePlateBlock extends Block { + +@@ -29,19 +30,17 @@ + protected static final AABB TOUCH_AABB = new AABB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.25D, 0.9375D); + protected final BlockSetType type; + +- protected BasePressurePlateBlock(BlockBehaviour.Properties blockbehaviour_properties, BlockSetType blocksettype) { +- super(blockbehaviour_properties.sound(blocksettype.soundType())); +- this.type = blocksettype; ++ protected BasePressurePlateBlock(BlockBehaviour.Properties properties, BlockSetType type) { ++ super(properties.sound(type.soundType())); ++ this.type = type; + } + + @Override +- @Override + protected abstract MapCodec<? extends BasePressurePlateBlock> codec(); + + @Override +- @Override +- public VoxelShape getShape(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, CollisionContext collisioncontext) { +- return this.getSignalForState(blockstate) > 0 ? BasePressurePlateBlock.PRESSED_AABB : BasePressurePlateBlock.AABB; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return this.getSignalForState(state) > 0 ? BasePressurePlateBlock.PRESSED_AABB : BasePressurePlateBlock.AABB; + } + + protected int getPressedTime() { +@@ -49,120 +48,130 @@ + } + + @Override +- @Override +- public boolean isPossibleToRespawnInThis(BlockState blockstate) { ++ public boolean isPossibleToRespawnInThis(IBlockData state) { + return true; + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- return direction == Direction.DOWN && !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 == Direction.DOWN && !state.canSurvive(level, currentPos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- @Override +- public boolean canSurvive(BlockState blockstate, LevelReader levelreader, BlockPos blockpos) { +- BlockPos blockpos1 = blockpos.below(); ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ BlockPos blockposition1 = pos.below(); + +- return canSupportRigidBlock(levelreader, blockpos1) || canSupportCenter(levelreader, blockpos1, Direction.UP); ++ return canSupportRigidBlock(level, blockposition1) || canSupportCenter(level, blockposition1, Direction.UP); + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- int i = this.getSignalForState(blockstate); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ int i = this.getSignalForState(state); + + if (i > 0) { +- this.checkPressed((Entity) null, serverlevel, blockpos, blockstate, i); ++ this.checkPressed((Entity) null, level, pos, state, i); + } + + } + + @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) { +- int i = this.getSignalForState(blockstate); ++ int i = this.getSignalForState(state); + + if (i == 0) { +- this.checkPressed(entity, level, blockpos, blockstate, i); ++ this.checkPressed(entity, level, pos, state, i); + } + + } + } + +- private void checkPressed(@Nullable Entity entity, Level level, BlockPos blockpos, BlockState blockstate, int i) { +- int j = this.getSignalStrength(level, blockpos); +- boolean flag = i > 0; ++ private void checkPressed(@Nullable Entity entity, Level level, BlockPos pos, IBlockData state, int currentSignal) { ++ int j = this.getSignalStrength(level, pos); ++ boolean flag = currentSignal > 0; + boolean flag1 = j > 0; + +- if (i != j) { +- BlockState blockstate1 = this.setSignalForState(blockstate, j); ++ // CraftBukkit start - Interact Pressure Plate ++ org.bukkit.World bworld = level.getWorld(); ++ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); + +- level.setBlock(blockpos, blockstate1, 2); +- this.updateNeighbours(level, blockpos); +- level.setBlocksDirty(blockpos, blockstate, blockstate1); ++ if (flag != flag1) { ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), currentSignal, j); ++ manager.callEvent(eventRedstone); ++ ++ flag1 = eventRedstone.getNewCurrent() > 0; ++ j = eventRedstone.getNewCurrent(); + } ++ // CraftBukkit end + ++ if (currentSignal != j) { ++ IBlockData iblockdata1 = this.setSignalForState(state, j); ++ ++ level.setBlock(pos, iblockdata1, 2); ++ this.updateNeighbours(level, pos); ++ level.setBlocksDirty(pos, state, iblockdata1); ++ } ++ + if (!flag1 && flag) { +- level.playSound((Player) null, blockpos, this.type.pressurePlateClickOff(), SoundSource.BLOCKS); +- level.gameEvent(entity, GameEvent.BLOCK_DEACTIVATE, blockpos); ++ level.playSound((Player) null, pos, this.type.pressurePlateClickOff(), SoundSource.BLOCKS); ++ level.gameEvent(entity, GameEvent.BLOCK_DEACTIVATE, pos); + } else if (flag1 && !flag) { +- level.playSound((Player) null, blockpos, this.type.pressurePlateClickOn(), SoundSource.BLOCKS); +- level.gameEvent(entity, GameEvent.BLOCK_ACTIVATE, blockpos); ++ level.playSound((Player) null, pos, this.type.pressurePlateClickOn(), SoundSource.BLOCKS); ++ level.gameEvent(entity, GameEvent.BLOCK_ACTIVATE, pos); + } + + if (flag1) { +- level.scheduleTick(new BlockPos(blockpos), (Block) this, this.getPressedTime()); ++ level.scheduleTick(new BlockPos(pos), (Block) this, this.getPressedTime()); + } + + } + + @Override +- @Override +- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!flag && !blockstate.is(blockstate1.getBlock())) { +- if (this.getSignalForState(blockstate) > 0) { +- this.updateNeighbours(level, blockpos); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) { ++ if (!isMoving && !state.is(newState.getBlock())) { ++ if (this.getSignalForState(state) > 0) { ++ this.updateNeighbours(level, pos); + } + +- super.onRemove(blockstate, level, blockpos, blockstate1, flag); ++ super.onRemove(state, level, pos, newState, isMoving); + } + } + +- protected void updateNeighbours(Level level, BlockPos blockpos) { +- level.updateNeighborsAt(blockpos, this); +- level.updateNeighborsAt(blockpos.below(), this); ++ protected void updateNeighbours(Level level, BlockPos pos) { ++ level.updateNeighborsAt(pos, this); ++ level.updateNeighborsAt(pos.below(), this); + } + + @Override +- @Override +- public int getSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return this.getSignalForState(blockstate); ++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return this.getSignalForState(blockState); + } + + @Override +- @Override +- public int getDirectSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return direction == Direction.UP ? this.getSignalForState(blockstate) : 0; ++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return side == Direction.UP ? this.getSignalForState(blockState) : 0; + } + + @Override +- @Override +- public boolean isSignalSource(BlockState blockstate) { ++ public boolean isSignalSource(IBlockData state) { + return true; + } + +- protected static int getEntityCount(Level level, AABB aabb, Class<? extends Entity> oclass) { +- return level.getEntitiesOfClass(oclass, aabb, EntitySelector.NO_SPECTATORS.and((entity) -> { ++ protected static int getEntityCount(Level level, AABB box, Class<? extends Entity> entityClass) { ++ // CraftBukkit start ++ return getEntities(level, box, entityClass).size(); ++ } ++ ++ protected static <T extends Entity> java.util.List<T> getEntities(Level world, AABB axisalignedbb, Class<T> oclass) { ++ // CraftBukkit end ++ return world.getEntitiesOfClass(oclass, axisalignedbb, EntitySelector.NO_SPECTATORS.and((entity) -> { + return !entity.isIgnoringBlockTriggers(); +- })).size(); ++ })); // CraftBukkit + } + + protected abstract int getSignalStrength(Level level, BlockPos pos); + +- protected abstract int getSignalForState(BlockState state); ++ protected abstract int getSignalForState(IBlockData state); + +- protected abstract BlockState setSignalForState(BlockState state, int signal); ++ protected abstract IBlockData setSignalForState(IBlockData state, int signal); + } |