2022-09-18 05:03:54 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
|
|
Date: Mon, 9 Aug 2021 20:45:46 -0700
|
|
|
|
Subject: [PATCH] Fire EntityChangeBlockEvent in more places
|
|
|
|
|
2022-09-20 04:35:38 +02:00
|
|
|
Co-authored-by: ChristopheG <61288881+chrisgdt@users.noreply.github.com>
|
2022-09-18 05:03:54 +02:00
|
|
|
|
2022-09-20 04:35:38 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LightningBolt.java b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index a298f511c8a7eb208a0dd63b24ec050848a31476..41a3ca4edf4fa662f2af13efd7b78b56e24aa4a7 100644
|
2022-09-20 04:35:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -98,7 +98,7 @@ public class LightningBolt extends Entity {
|
2022-09-20 04:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.powerLightningRod();
|
2023-06-08 10:47:19 +02:00
|
|
|
- LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition());
|
2024-01-18 15:56:25 +01:00
|
|
|
+ LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition(), this); // Paper - Call EntityChangeBlockEvent
|
2022-09-20 04:35:38 +02:00
|
|
|
this.gameEvent(GameEvent.LIGHTNING_STRIKE);
|
|
|
|
}
|
|
|
|
}
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -192,7 +192,7 @@ public class LightningBolt extends Entity {
|
2022-09-20 04:35:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- private static void clearCopperOnLightningStrike(Level world, BlockPos pos) {
|
2024-01-18 15:56:25 +01:00
|
|
|
+ private static void clearCopperOnLightningStrike(Level world, BlockPos pos, Entity lightning) { // Paper - Call EntityChangeBlockEvent
|
2022-09-20 04:35:38 +02:00
|
|
|
BlockState iblockdata = world.getBlockState(pos);
|
|
|
|
BlockPos blockposition1;
|
|
|
|
BlockState iblockdata1;
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -206,24 +206,29 @@ public class LightningBolt extends Entity {
|
2022-09-20 04:35:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (iblockdata1.getBlock() instanceof WeatheringCopper) {
|
|
|
|
- world.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(world.getBlockState(blockposition1)));
|
2024-01-18 15:56:25 +01:00
|
|
|
+ // Paper start - Call EntityChangeBlockEvent
|
2022-09-20 04:35:38 +02:00
|
|
|
+ BlockState newBlock = WeatheringCopper.getFirst(world.getBlockState(blockposition1));
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1, newBlock)) {
|
2022-09-20 04:35:38 +02:00
|
|
|
+ world.setBlockAndUpdate(blockposition1, newBlock);
|
|
|
|
+ }
|
2024-01-18 15:56:25 +01:00
|
|
|
+ // Paper end - Call EntityChangeBlockEvent
|
2022-09-20 04:35:38 +02:00
|
|
|
BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
|
|
|
|
int i = world.random.nextInt(3) + 3;
|
|
|
|
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
int k = world.random.nextInt(8) + 1;
|
|
|
|
|
|
|
|
- LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k);
|
|
|
|
+ LightningBolt.randomWalkCleaningCopper(world, blockposition1, blockposition_mutableblockposition, k, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count) {
|
|
|
|
+ private static void randomWalkCleaningCopper(Level world, BlockPos pos, BlockPos.MutableBlockPos mutablePos, int count, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
|
|
|
mutablePos.set(pos);
|
|
|
|
|
|
|
|
for (int j = 0; j < count; ++j) {
|
|
|
|
- Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos);
|
|
|
|
+ Optional<BlockPos> optional = LightningBolt.randomStepCleaningCopper(world, mutablePos, lightning); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
|
|
|
|
2023-09-22 17:35:51 +02:00
|
|
|
if (optional.isEmpty()) {
|
2022-09-20 04:35:38 +02:00
|
|
|
break;
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -234,7 +239,7 @@ public class LightningBolt extends Entity {
|
2022-09-20 04:35:38 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos) {
|
|
|
|
+ private static Optional<BlockPos> randomStepCleaningCopper(Level world, BlockPos pos, Entity lightning) { // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
|
|
|
Iterator iterator = BlockPos.randomInCube(world.random, 10, pos, 1).iterator();
|
|
|
|
|
|
|
|
BlockPos blockposition1;
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -251,6 +256,7 @@ public class LightningBolt extends Entity {
|
2022-09-20 04:35:38 +02:00
|
|
|
|
|
|
|
BlockPos blockposition1Final = blockposition1; // CraftBukkit - decompile error
|
|
|
|
WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(lightning, blockposition1Final, iblockdata1)) // Paper - call EntityChangeBlockEvent
|
2022-09-20 04:35:38 +02:00
|
|
|
world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
|
|
|
|
});
|
|
|
|
world.levelEvent(3002, blockposition1, -1);
|
2023-05-15 12:56:12 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java b/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
2023-09-22 19:59:56 +02:00
|
|
|
index 2c443b421e342ebfbdf941a431ba20560521920b..91b68ee3605afdb845405e455c869e48a7fc9aab 100644
|
2023-05-15 12:56:12 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
|
|
|
|
@@ -27,6 +27,12 @@ public class TryLaySpawnOnWaterNearLand {
|
|
|
|
BlockPos blockPos3 = blockPos2.above();
|
|
|
|
if (world.getBlockState(blockPos3).isAir()) {
|
|
|
|
BlockState blockState = frogSpawn.defaultBlockState();
|
|
|
|
+ // Paper start
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos3, blockState)) {
|
2023-05-15 12:56:12 +02:00
|
|
|
+ isPregnant.erase(); // forgot pregnant memory
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
world.setBlock(blockPos3, blockState, 3);
|
|
|
|
world.gameEvent(GameEvent.BLOCK_PLACE, blockPos3, GameEvent.Context.of(entity, blockState));
|
|
|
|
world.playSound((Player)null, entity, SoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
2022-09-18 05:03:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/AxeItem.java b/src/main/java/net/minecraft/world/item/AxeItem.java
|
2023-12-06 17:21:56 +01:00
|
|
|
index db507638a97b5a33df712c54daff35b21922c0dd..2e75fd06e9e379eb95ebfe55086ffc327706ab2f 100644
|
2022-09-18 05:03:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/AxeItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/AxeItem.java
|
2023-12-06 17:21:56 +01:00
|
|
|
@@ -38,6 +38,11 @@ public class AxeItem extends DiggerItem {
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
} else {
|
|
|
|
ItemStack itemStack = context.getItemInHand();
|
2022-09-18 05:03:54 +02:00
|
|
|
+ // Paper start - EntityChangeBlockEvent
|
2023-12-06 17:21:56 +01:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, optional.get())) {
|
2022-09-18 05:03:54 +02:00
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
if (player instanceof ServerPlayer) {
|
|
|
|
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
|
|
|
|
}
|
2022-12-17 19:20:14 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/EnderEyeItem.java b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
2024-01-02 19:45:36 +01:00
|
|
|
index 1977e702f6af39ebf100c1f2f2edc2d1c4d003b0..cfcd1778b5ae66395400221879dde3575591b23d 100644
|
2022-12-17 19:20:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java
|
|
|
|
@@ -43,6 +43,11 @@ public class EnderEyeItem extends Item {
|
|
|
|
return InteractionResult.SUCCESS;
|
|
|
|
} else {
|
|
|
|
BlockState iblockdata1 = (BlockState) iblockdata.setValue(EndPortalFrameBlock.HAS_EYE, true);
|
|
|
|
+ // Paper start
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockposition, iblockdata1)) {
|
2022-12-17 19:20:14 +01:00
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
Block.pushEntitiesUp(iblockdata, iblockdata1, world, blockposition);
|
|
|
|
world.setBlock(blockposition, iblockdata1, 2);
|
2022-09-18 05:03:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/HoneycombItem.java b/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
2023-12-06 17:21:56 +01:00
|
|
|
index 78bdf7c0a058e84cafcd831c6d6f5123c0f168b0..e0cae3b6848af74fefc37a1e3183c501155c4710 100644
|
2022-09-18 05:03:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/HoneycombItem.java
|
2023-06-08 10:47:19 +02:00
|
|
|
@@ -39,6 +39,14 @@ public class HoneycombItem extends Item implements SignApplicator {
|
2022-09-18 05:03:54 +02:00
|
|
|
return getWaxed(blockState).map((state) -> {
|
|
|
|
Player player = context.getPlayer();
|
|
|
|
ItemStack itemStack = context.getItemInHand();
|
|
|
|
+ // Paper start - EntityChangeBlockEvent
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, blockPos, state)) {
|
2023-02-11 18:14:03 +01:00
|
|
|
+ if (!player.isCreative()) {
|
|
|
|
+ player.containerMenu.sendAllDataToRemote();
|
|
|
|
+ }
|
2022-09-18 05:03:54 +02:00
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
if (player instanceof ServerPlayer) {
|
|
|
|
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, blockPos, itemStack);
|
|
|
|
}
|
2022-12-17 19:20:14 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/PotionItem.java b/src/main/java/net/minecraft/world/item/PotionItem.java
|
2024-01-21 19:37:09 +01:00
|
|
|
index 5c62741e3a3854a7f674bfec49758f837f3bb9a0..b93ed2896ebeb8ec75eb3cfb717a740c97dd9622 100644
|
2022-12-17 19:20:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/PotionItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/PotionItem.java
|
|
|
|
@@ -107,6 +107,12 @@ public class PotionItem extends Item {
|
|
|
|
BlockState iblockdata = world.getBlockState(blockposition);
|
|
|
|
|
|
|
|
if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) {
|
|
|
|
+ // Paper start
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityhuman, blockposition, Blocks.MUD.defaultBlockState())) {
|
2022-12-17 19:20:14 +01:00
|
|
|
+ entityhuman.containerMenu.sendAllDataToRemote();
|
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
world.playSound((Player) null, blockposition, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
|
|
entityhuman.setItemInHand(context.getHand(), ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
|
|
|
entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
2022-09-18 05:03:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
2023-09-22 19:59:56 +02:00
|
|
|
index 32995cb5efdad0bc34ecacacb78cccd21220ba8d..21212462e6b415e96536a27b2c009d1562f18946 100644
|
2022-09-18 05:03:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
|
|
|
|
@@ -36,20 +36,29 @@ public class ShovelItem extends DiggerItem {
|
|
|
|
Player player = context.getPlayer();
|
|
|
|
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
|
|
|
|
BlockState blockState3 = null;
|
|
|
|
+ Runnable afterAction = null; // Paper
|
|
|
|
if (blockState2 != null && level.getBlockState(blockPos.above()).isAir()) {
|
|
|
|
- level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
|
|
+ afterAction = () -> level.playSound(player, blockPos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
|
|
|
|
blockState3 = blockState2;
|
|
|
|
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
|
|
|
|
+ afterAction = () -> { // Paper
|
|
|
|
if (!level.isClientSide()) {
|
|
|
|
level.levelEvent((Player)null, 1009, blockPos, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
|
|
|
|
+ }; // Paper
|
|
|
|
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (blockState3 != null) {
|
|
|
|
if (!level.isClientSide) {
|
|
|
|
+ // Paper start
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), blockPos, blockState3)) {
|
2022-09-18 05:03:54 +02:00
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ afterAction.run();
|
|
|
|
+ // Paper end
|
|
|
|
level.setBlock(blockPos, blockState3, 11);
|
|
|
|
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(player, blockState3));
|
|
|
|
if (player != null) {
|
2024-01-02 19:45:36 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/CakeBlock.java b/src/main/java/net/minecraft/world/level/block/CakeBlock.java
|
|
|
|
index 49fe91a8eaeb2580c8ad0166e72540168af605f6..ca1ccedb5a551328ebfad907f39594b220efaefe 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/CakeBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CakeBlock.java
|
|
|
|
@@ -62,6 +62,12 @@ public class CakeBlock extends Block {
|
|
|
|
Block block = Block.byItem(item);
|
|
|
|
|
|
|
|
if (block instanceof CandleBlock) {
|
|
|
|
+ // Paper start - call change block event
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, CandleCakeBlock.byCandle(block))) {
|
|
|
|
+ player.containerMenu.sendAllDataToRemote(); // update inv because candle could decrease
|
|
|
|
+ return InteractionResult.PASS;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - call change block event
|
|
|
|
if (!player.isCreative()) {
|
|
|
|
itemstack.shrink(1);
|
|
|
|
}
|
|
|
|
@@ -91,6 +97,14 @@ public class CakeBlock extends Block {
|
|
|
|
if (!player.canEat(false)) {
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
} else {
|
|
|
|
+ // Paper start - call change block event
|
|
|
|
+ int i = state.getValue(CakeBlock.BITES);
|
|
|
|
+ final BlockState newState = i < MAX_BITES ? state.setValue(CakeBlock.BITES, i + 1) : world.getFluidState(pos).createLegacyBlock();
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newState)) {
|
|
|
|
+ ((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate();
|
|
|
|
+ return InteractionResult.PASS; // return a non-consume result to cake blocks don't drop their candles
|
|
|
|
+ }
|
|
|
|
+ // Paper end - call change block event
|
|
|
|
player.awardStat(Stats.EAT_CAKE_SLICE);
|
|
|
|
// CraftBukkit start
|
|
|
|
// entityhuman.getFoodData().eat(2, 0.1F);
|
|
|
|
@@ -104,7 +118,7 @@ public class CakeBlock extends Block {
|
|
|
|
|
|
|
|
((net.minecraft.server.level.ServerPlayer) player).getBukkitEntity().sendHealthUpdate();
|
|
|
|
// CraftBukkit end
|
|
|
|
- int i = (Integer) state.getValue(CakeBlock.BITES);
|
|
|
|
+ // Paper - move up
|
|
|
|
|
|
|
|
world.gameEvent((Entity) player, GameEvent.EAT, pos);
|
|
|
|
if (i < 6) {
|
2022-09-18 05:03:54 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
2023-12-06 17:21:56 +01:00
|
|
|
index 6cccdd1d19488275ff3fe90838cf1c31e844d517..413b307acaad5823b9e06f49fa2faf561f5f7b9a 100644
|
2022-09-18 05:03:54 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
2023-12-06 17:21:56 +01:00
|
|
|
@@ -238,6 +238,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
2022-09-18 05:03:54 +02:00
|
|
|
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
|
|
|
|
if (i < 7 && !world.isClientSide) {
|
2023-05-31 03:07:04 +02:00
|
|
|
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
|
|
|
|
+ // Paper start - handle cancelled events
|
|
|
|
+ if (iblockdata1 == null) {
|
|
|
|
+ return InteractionResult.PASS;
|
2022-09-18 05:03:54 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
|
|
|
player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
2023-12-06 17:21:56 +01:00
|
|
|
@@ -261,11 +266,16 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
2023-05-31 03:07:04 +02:00
|
|
|
if (i < 7 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
|
|
|
|
// CraftBukkit start
|
|
|
|
double rand = world.getRandom().nextDouble();
|
|
|
|
- BlockState iblockdata1 = ComposterBlock.addItem(user, state, DummyGeneratorAccess.INSTANCE, pos, stack, rand);
|
2023-07-04 10:22:56 +02:00
|
|
|
- if (state == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(user, pos, iblockdata1)) {
|
2023-05-31 03:07:04 +02:00
|
|
|
+ BlockState iblockdata1 = null; // Paper
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (false && (state == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(user, pos, iblockdata1))) { // Paper - move event call into addItem
|
2023-05-31 03:07:04 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
iblockdata1 = ComposterBlock.addItem(user, state, world, pos, stack, rand);
|
|
|
|
+ // Paper start - handle cancelled events
|
|
|
|
+ if (iblockdata1 == null) {
|
|
|
|
+ return state;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
stack.shrink(1);
|
2023-12-06 17:21:56 +01:00
|
|
|
@@ -306,11 +316,13 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
2023-05-31 03:07:04 +02:00
|
|
|
return iblockdata1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ @Nullable // Paper
|
|
|
|
static BlockState addItem(@Nullable Entity user, BlockState state, LevelAccessor world, BlockPos pos, ItemStack stack) {
|
|
|
|
// CraftBukkit start
|
|
|
|
return ComposterBlock.addItem(user, state, world, pos, stack, world.getRandom().nextDouble());
|
|
|
|
}
|
|
|
|
|
|
|
|
+ @Nullable // Paper - make it nullable
|
|
|
|
static BlockState addItem(@Nullable Entity entity, BlockState iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, ItemStack itemstack, double rand) {
|
|
|
|
// CraftBukkit end
|
|
|
|
int i = (Integer) iblockdata.getValue(ComposterBlock.LEVEL);
|
2023-12-06 17:21:56 +01:00
|
|
|
@@ -321,6 +333,11 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
2023-05-31 03:07:04 +02:00
|
|
|
} else {
|
|
|
|
int j = i + 1;
|
|
|
|
BlockState iblockdata1 = (BlockState) iblockdata.setValue(ComposterBlock.LEVEL, j);
|
|
|
|
+ // Paper start - move the EntityChangeBlockEvent here to avoid conflict later for the compost events
|
2023-07-04 10:22:56 +02:00
|
|
|
+ if (entity != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) {
|
2023-05-31 03:07:04 +02:00
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
generatoraccess.setBlock(blockposition, iblockdata1, 3);
|
|
|
|
generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, iblockdata1));
|
2023-03-15 02:27:20 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
Updated Upstream (Bukkit/CraftBukkit) (#10242)
* Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
a6a9d2a4 Remove some old ApiStatus.Experimental annotations
be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage
b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects
b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration
08f86d1c PR-971: Add Player methods for client-side potion effects
2e3024a9 PR-963: Add API for in-world structures
a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality
1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason
cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent
CraftBukkit Changes:
38fd4bd50 Fix accidentally renamed internal damage method
80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage
7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom
ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects
4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration
22a541a29 Improve support for per-world game rules
cb7dccce2 PR-1348: Add Player methods for client-side potion effects
b8d6109f0 PR-1335: Add API for in-world structures
4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity
e74107678 Fix Crafter maximum stack size
0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality
4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason
20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette
3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook
333701839 SPIGOT-7572: Bee nests generated without bees
f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
|
|
|
index 67c9009b735429e887e706baf50a6023d572a46c..7956002e2d4d583c27e277562312d27ea6871557 100644
|
2023-03-15 02:27:20 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
|
2023-03-15 10:33:43 +01:00
|
|
|
@@ -120,7 +120,7 @@ public class DummyGeneratorAccess implements WorldGenLevel {
|
2023-03-15 02:27:20 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) {
|
2023-03-15 10:33:43 +01:00
|
|
|
- // Used by BlockComposter
|
2023-03-15 02:27:20 +01:00
|
|
|
+ // Used by ComposterBlock
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|