diff --git a/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch b/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch index 96fd41be15..844256de70 100644 --- a/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch +++ b/patches/server/Add-CompostItemEvent-and-EntityCompostItemEvent.patch @@ -9,11 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java +++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java @@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { - if (state != dummyBlockState && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, dummyBlockState).isCancelled()) { // if block state will change and event cancelled return InteractionResult.sidedSuccess(world.isClientSide); } -- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand); -+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack); + BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand); + if (iblockdata1 == null) { + return InteractionResult.PASS; + } @@ -38,19 +36,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if ((i != 0 || f <= 0.0F) && rand >= (double) f) { + // Paper start -+ io.papermc.paper.event.block.CompostItemEvent event; + boolean willRaiseLevel = !((i != 0 || f <= 0.0F) && rand >= (double) f); -+ if (entity == null) { -+ event = new io.papermc.paper.event.block.CompostItemEvent(org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel); -+ } else { -+ event = new io.papermc.paper.event.entity.EntityCompostItemEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel); ++ if (generatoraccess == DummyGeneratorAccess.INSTANCE || entity == null) { // call event on test run or when entity is null (via hopper) ++ final io.papermc.paper.event.block.CompostItemEvent event; ++ if (entity == null) { ++ event = new io.papermc.paper.event.block.CompostItemEvent(org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel); ++ } else { ++ event = new io.papermc.paper.event.entity.EntityCompostItemEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel); ++ } ++ if (!event.callEvent()) { ++ return null; ++ } ++ willRaiseLevel = event.willRaiseLevel(); + } -+ -+ if (!event.callEvent()) { -+ return null; -+ } -+ -+ if (!event.willRaiseLevel()) { ++ if (!willRaiseLevel) { + // Paper end return iblockdata; } else { diff --git a/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch b/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch index a99d1df5a5..28fb44eb5f 100644 --- a/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch +++ b/patches/server/Fire-EntityChangeBlockEvent-in-more-places.patch @@ -201,3 +201,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0); player.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); +diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java +@@ -0,0 +0,0 @@ public class DummyGeneratorAccess implements WorldGenLevel { + + @Override + public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) { +- throw new UnsupportedOperationException("Not supported yet."); ++ // Used by ComposterBlock + } + + @Override