diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch new file mode 100644 index 0000000000..735972bb47 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch @@ -0,0 +1,112 @@ +--- a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java ++++ b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +@@ -6,43 +6,64 @@ + import net.minecraft.core.BlockPos; + import net.minecraft.util.Mth; + import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.player.Player; + import net.minecraft.world.level.Level; + 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.BlockSetType; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.IntegerProperty; ++import org.bukkit.event.entity.EntityInteractEvent; ++// CraftBukkit end + + public class WeightedPressurePlateBlock extends BasePressurePlateBlock { + + public static final MapCodec<WeightedPressurePlateBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { +- return instance.group(Codec.intRange(1, 1024).fieldOf("max_weight").forGetter((weightedpressureplateblock) -> { +- return weightedpressureplateblock.maxWeight; +- }), BlockSetType.CODEC.fieldOf("block_set_type").forGetter((weightedpressureplateblock) -> { +- return weightedpressureplateblock.type; ++ return instance.group(Codec.intRange(1, 1024).fieldOf("max_weight").forGetter((blockpressureplateweighted) -> { ++ return blockpressureplateweighted.maxWeight; ++ }), BlockSetType.CODEC.fieldOf("block_set_type").forGetter((blockpressureplateweighted) -> { ++ return blockpressureplateweighted.type; + }), propertiesCodec()).apply(instance, WeightedPressurePlateBlock::new); + }); + public static final IntegerProperty POWER = BlockStateProperties.POWER; + private final int maxWeight; + + @Override +- @Override + public MapCodec<WeightedPressurePlateBlock> codec() { + return WeightedPressurePlateBlock.CODEC; + } + +- protected WeightedPressurePlateBlock(int i, BlockSetType blocksettype, BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties, blocksettype); +- this.registerDefaultState((BlockState) ((BlockState) this.stateDefinition.any()).setValue(WeightedPressurePlateBlock.POWER, 0)); ++ protected WeightedPressurePlateBlock(int i, BlockSetType blocksettype, BlockBehaviour.Properties blockbase_info) { ++ super(blockbase_info, blocksettype); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(WeightedPressurePlateBlock.POWER, 0)); + this.maxWeight = i; + } + + @Override +- @Override +- protected int getSignalStrength(Level level, BlockPos blockpos) { +- int i = Math.min(getEntityCount(level, WeightedPressurePlateBlock.TOUCH_AABB.move(blockpos), Entity.class), this.maxWeight); ++ protected int getSignalStrength(Level level, BlockPos pos) { ++ // CraftBukkit start ++ // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); ++ int i = 0; ++ for (Entity entity : getEntities(level, WeightedPressurePlateBlock.TOUCH_AABB.move(pos), Entity.class)) { ++ org.bukkit.event.Cancellable cancellable; + ++ if (entity instanceof Player) { ++ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); ++ } else { ++ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ level.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) cancellable); ++ } ++ ++ // We only want to block turning the plate on if all events are cancelled ++ if (!cancellable.isCancelled()) { ++ i++; ++ } ++ } ++ ++ i = Math.min(i, this.maxWeight); ++ // CraftBukkit end ++ + if (i > 0) { + float f = (float) Math.min(this.maxWeight, i) / (float) this.maxWeight; + +@@ -53,26 +74,22 @@ + } + + @Override +- @Override +- protected int getSignalForState(BlockState blockstate) { +- return (Integer) blockstate.getValue(WeightedPressurePlateBlock.POWER); ++ protected int getSignalForState(IBlockData state) { ++ return (Integer) state.getValue(WeightedPressurePlateBlock.POWER); + } + + @Override +- @Override +- protected BlockState setSignalForState(BlockState blockstate, int i) { +- return (BlockState) blockstate.setValue(WeightedPressurePlateBlock.POWER, i); ++ protected IBlockData setSignalForState(IBlockData state, int strength) { ++ return (IBlockData) state.setValue(WeightedPressurePlateBlock.POWER, strength); + } + + @Override +- @Override + protected int getPressedTime() { + return 10; + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(WeightedPressurePlateBlock.POWER); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(WeightedPressurePlateBlock.POWER); + } + } |