diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/PressurePlateBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/PressurePlateBlock.java.patch | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/PressurePlateBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/PressurePlateBlock.java.patch new file mode 100644 index 0000000000..6f7e246e10 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/PressurePlateBlock.java.patch @@ -0,0 +1,119 @@ +--- a/net/minecraft/world/level/block/PressurePlateBlock.java ++++ b/net/minecraft/world/level/block/PressurePlateBlock.java +@@ -2,56 +2,95 @@ + + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import net.minecraft.core.BlockPos; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.LivingEntity; ++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.BooleanProperty; ++import org.bukkit.event.entity.EntityInteractEvent; ++// CraftBukkit end + + public class PressurePlateBlock extends BasePressurePlateBlock { +- public static final MapCodec<PressurePlateBlock> CODEC = RecordCodecBuilder.mapCodec( +- instance -> instance.group(BlockSetType.CODEC.fieldOf("block_set_type").forGetter(pressurePlateBlock -> pressurePlateBlock.type), propertiesCodec()) +- .apply(instance, PressurePlateBlock::new) +- ); ++ ++ public static final MapCodec<PressurePlateBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(BlockSetType.CODEC.fieldOf("block_set_type").forGetter((blockpressureplatebinary) -> { ++ return blockpressureplatebinary.type; ++ }), propertiesCodec()).apply(instance, PressurePlateBlock::new); ++ }); + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; + + @Override + public MapCodec<PressurePlateBlock> codec() { +- return CODEC; ++ return PressurePlateBlock.CODEC; + } + +- protected PressurePlateBlock(BlockSetType type, BlockBehaviour.Properties properties) { +- super(properties, type); +- this.registerDefaultState(this.stateDefinition.any().setValue(POWERED, Boolean.valueOf(false))); ++ protected PressurePlateBlock(BlockSetType blocksettype, BlockBehaviour.Properties blockbase_info) { ++ super(blockbase_info, blocksettype); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(PressurePlateBlock.POWERED, false)); + } + + @Override +- protected int getSignalForState(BlockState state) { +- return state.getValue(POWERED) ? 15 : 0; ++ protected int getSignalForState(IBlockData state) { ++ return (Boolean) state.getValue(PressurePlateBlock.POWERED) ? 15 : 0; + } + + @Override +- protected BlockState setSignalForState(BlockState state, int strength) { +- return state.setValue(POWERED, Boolean.valueOf(strength > 0)); ++ protected IBlockData setSignalForState(IBlockData state, int strength) { ++ return (IBlockData) state.setValue(PressurePlateBlock.POWERED, strength > 0); + } + + @Override + protected int getSignalStrength(Level level, BlockPos pos) { +- Class<? extends Entity> clazz = switch (this.type.pressurePlateSensitivity()) { +- case EVERYTHING -> Entity.class; +- case MOBS -> LivingEntity.class; +- }; +- return getEntityCount(level, TOUCH_AABB.move(pos), clazz) > 0 ? 15 : 0; ++ Class<? extends Entity> oclass; // CraftBukkit ++ ++ switch (this.type.pressurePlateSensitivity()) { ++ case EVERYTHING: ++ oclass = Entity.class; ++ break; ++ case MOBS: ++ oclass = LivingEntity.class; ++ break; ++ default: ++ throw new IncompatibleClassChangeError(); ++ } ++ ++ Class<? extends Entity> oclass1 = oclass; ++ ++ // CraftBukkit start - Call interact event when turning on a pressure plate ++ for (Entity entity : getEntities(level, PressurePlateBlock.TOUCH_AABB.move(pos), oclass)) { ++ if (this.getSignalForState(level.getBlockState(pos)) == 0) { ++ org.bukkit.World bworld = level.getWorld(); ++ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); ++ 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(), bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ manager.callEvent((EntityInteractEvent) cancellable); ++ } ++ ++ // We only want to block turning the plate on if all events are cancelled ++ if (cancellable.isCancelled()) { ++ continue; ++ } ++ } ++ ++ return 15; ++ } ++ ++ return 0; ++ // CraftBukkit end + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(POWERED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(PressurePlateBlock.POWERED); + } + } |