mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 22:40:21 +01:00
readd EntityInsideBlockEvent for pitcher crop
This commit is contained in:
parent
a67d7adcc9
commit
7b4afa8b82
8 changed files with 32 additions and 36 deletions
|
@ -23,7 +23,7 @@
|
|||
if (potionContents != null && potionContents.is(Potions.WATER)) {
|
||||
if (!level.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, Blocks.WATER_CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, Blocks.WATER_CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
@ -82,7 +82,7 @@
|
|||
if (potionContents != null && potionContents.is(Potions.WATER)) {
|
||||
if (!level.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, state.cycle(LayeredCauldronBlock.LEVEL), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, state.cycle(LayeredCauldronBlock.LEVEL), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
@ -145,7 +145,7 @@
|
|||
+ }
|
||||
+ // Paper end - fire PlayerBucketFillEvent
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, Blocks.CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, Blocks.CAULDRON.defaultBlockState(), player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
@ -179,7 +179,7 @@
|
|||
+ }
|
||||
+ // Paper end - fire PlayerBucketEmptyEvent
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, state, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, state, player, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY, false)) { // Paper - Call CauldronLevelChangeEvent
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
if (shouldHandlePrecipitation(level, precipitation)) {
|
||||
if (precipitation == Biome.Precipitation.RAIN) {
|
||||
+ // Paper start - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, Blocks.WATER_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
|
@ -13,7 +13,7 @@
|
|||
level.gameEvent(null, GameEvent.BLOCK_CHANGE, pos);
|
||||
} else if (precipitation == Biome.Precipitation.SNOW) {
|
||||
+ // Paper start - Call CauldronLevelChangeEvent
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, Blocks.POWDER_SNOW_CAULDRON.defaultBlockState(), null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL, false)) { // avoid duplicate game event
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
|
@ -27,7 +27,7 @@
|
|||
- level.setBlockAndUpdate(pos, blockState);
|
||||
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState));
|
||||
+ // Paper start - Call CauldronLevelChangeEvent; don't send level event or game event if cancelled
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
|
@ -37,7 +37,7 @@
|
|||
- level.setBlockAndUpdate(pos, blockState);
|
||||
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState));
|
||||
+ // Paper start - Call CauldronLevelChangeEvent; don't send level event or game event if cancelled
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { // CraftBukkit
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
- if (blockEntity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) {
|
||||
+ if (blockEntity instanceof CommandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
||||
+ if (blockEntity instanceof CommandBlockEntity && (player.canUseGameMasterBlocks() || (player.isCreative() && player.getBukkitEntity().hasPermission("minecraft.commandblock")))) { // Paper - command block permission
|
||||
player.openCommandBlock((CommandBlockEntity)blockEntity);
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
private void checkPressed(Level level, BlockPos pos, BlockState state) {
|
||||
if (this.canSurvive(state, level, pos)) {
|
||||
+ if (state.getBlock() != this) { return; } // Paper - Fix some rails connecting improperly
|
||||
+ if (!state.is(this)) { return; } // Paper - Fix some rails connecting improperly
|
||||
boolean poweredValue = state.getValue(POWERED);
|
||||
boolean flag = false;
|
||||
List<AbstractMinecart> interactingMinecartOfType = this.getInteractingMinecartOfType(level, pos, AbstractMinecart.class, entity -> true);
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
--- a/net/minecraft/world/level/block/DragonEggBlock.java
|
||||
+++ b/net/minecraft/world/level/block/DragonEggBlock.java
|
||||
@@ -55,6 +_,18 @@
|
||||
@@ -55,6 +_,16 @@
|
||||
level.random.nextInt(16) - level.random.nextInt(16)
|
||||
);
|
||||
if (level.getBlockState(blockPos).isAir() && worldBorder.isWithinBounds(blockPos)) {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block from = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
|
||||
+ org.bukkit.block.Block to = level.getWorld().getBlockAt(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
+ org.bukkit.block.Block from = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos);
|
||||
+ org.bukkit.block.Block to = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos);
|
||||
+ org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(from, to);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
level.setBlock(pos, this.getStateWithAge(level, pos, min), 3);
|
||||
} else {
|
||||
- level.removeBlock(pos, false);
|
||||
+ if(blockState.getBlock() != Blocks.TNT) level.removeBlock(pos, false); // Paper - TNTPrimeEvent; We might be cancelling it below, move the setAir down
|
||||
+ if (!blockState.is(Blocks.TNT)) level.removeBlock(pos, false); // Paper - TNTPrimeEvent; We might be cancelling it below, move the setAir down
|
||||
}
|
||||
|
||||
Block block = blockState.getBlock();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||
@@ -61,35 +_,79 @@
|
||||
@@ -61,35 +_,69 @@
|
||||
|
||||
@Override
|
||||
protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||
|
@ -12,7 +12,7 @@
|
|||
+ // CraftBukkit start - moved down
|
||||
+ // entity.clearFire();
|
||||
+ if ((entity instanceof net.minecraft.world.entity.player.Player || serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) && entity.mayInteract(serverLevel, pos)) { // Paper - Fixes MC-248588
|
||||
+ if (this.handleEntityOnFireInsideWithEvent(state, level, pos, entity)) { // Paper - fix powdered snow cauldron extinguishing entities
|
||||
+ if (this.handleEntityOnFireInside(state, level, pos, entity)) { // Paper - fix powdered snow cauldron extinguishing entities
|
||||
+ entity.clearFire();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
@ -22,7 +22,6 @@
|
|||
|
||||
- private void handleEntityOnFireInside(BlockState state, Level level, BlockPos pos) {
|
||||
+ // CraftBukkit start
|
||||
+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - fix powdered snow cauldron extinguishing entities; use #handleEntityOnFireInsideWithEvent
|
||||
+ private boolean handleEntityOnFireInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||
if (this.precipitationType == Biome.Precipitation.SNOW) {
|
||||
- lowerFillLevel(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LEVEL, state.getValue(LEVEL)), level, pos);
|
||||
|
@ -46,26 +45,17 @@
|
|||
+ int i = (Integer) state.getValue(LayeredCauldronBlock.LEVEL) - 1;
|
||||
+ BlockState iblockdata1 = i == 0 ? Blocks.CAULDRON.defaultBlockState() : (BlockState) state.setValue(LayeredCauldronBlock.LEVEL, i);
|
||||
+
|
||||
+ return LayeredCauldronBlock.changeLevel(state, level, BlockPos, iblockdata1, entity, reason);
|
||||
+ return LayeredCauldronBlock.changeLevel(level, BlockPos, iblockdata1, entity, reason);
|
||||
+ }
|
||||
+ // Paper start - fix powdered snow cauldron extinguishing entities
|
||||
+ protected boolean handleEntityOnFireInsideWithEvent(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (this.precipitationType == Biome.Precipitation.SNOW) {
|
||||
+ return LayeredCauldronBlock.lowerFillLevel((BlockState) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) state.getValue(LayeredCauldronBlock.LEVEL)), world, pos, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH);
|
||||
+ } else {
|
||||
+ return LayeredCauldronBlock.lowerFillLevel(state, world, pos, entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - fix powdered snow cauldron extinguishing entities
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ // Paper start - Call CauldronLevelChangeEvent
|
||||
+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
|
||||
+ return changeLevel(iblockdata, world, blockposition, newBlock, entity, reason, true);
|
||||
+ public static boolean changeLevel(Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
|
||||
+ return changeLevel(world, blockposition, newBlock, entity, reason, true);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean changeLevel(BlockState iblockdata, Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
+ public static boolean changeLevel(Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable
|
||||
+ // Paper end - Call CauldronLevelChangeEvent
|
||||
+ org.bukkit.craftbukkit.block.CraftBlockState newState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, blockposition);
|
||||
+ newState.setData(newBlock);
|
||||
+
|
||||
|
@ -89,7 +79,7 @@
|
|||
BlockState blockState = state.cycle(LEVEL);
|
||||
- level.setBlockAndUpdate(pos, blockState);
|
||||
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState));
|
||||
+ LayeredCauldronBlock.changeLevel(state, level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
|
||||
+ LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +90,7 @@
|
|||
- level.setBlockAndUpdate(pos, blockState);
|
||||
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState));
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, blockState, null, CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
--- a/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
+++ b/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
@@ -107,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
||||
if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
serverLevel.destroyBlock(pos, true, entity);
|
||||
}
|
||||
@@ -131,7 +_,7 @@
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
|
||||
|
|
Loading…
Reference in a new issue