geforkt von Mirrors/Paper
Fix composter throwing UOE with new game event
Dieser Commit ist enthalten in:
Ursprung
69697c6a22
Commit
286598313a
@ -9,11 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
|
||||||
+++ b/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 {
|
@@ -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);
|
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||||
}
|
}
|
||||||
- BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand);
|
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand);
|
||||||
+ BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
|
|
||||||
+ if (iblockdata1 == null) {
|
+ if (iblockdata1 == null) {
|
||||||
+ return InteractionResult.PASS;
|
+ return InteractionResult.PASS;
|
||||||
+ }
|
+ }
|
||||||
@ -38,19 +36,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
- if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
|
- if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ io.papermc.paper.event.block.CompostItemEvent event;
|
|
||||||
+ boolean willRaiseLevel = !((i != 0 || f <= 0.0F) && rand >= (double) f);
|
+ boolean willRaiseLevel = !((i != 0 || f <= 0.0F) && rand >= (double) f);
|
||||||
+ if (entity == null) {
|
+ if (generatoraccess == DummyGeneratorAccess.INSTANCE || entity == null) { // call event on test run or when entity is null (via hopper)
|
||||||
+ event = new io.papermc.paper.event.block.CompostItemEvent(org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel);
|
+ final io.papermc.paper.event.block.CompostItemEvent event;
|
||||||
+ } else {
|
+ if (entity == null) {
|
||||||
+ event = new io.papermc.paper.event.entity.EntityCompostItemEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(generatoraccess, blockposition), itemstack.getBukkitStack(), willRaiseLevel);
|
+ 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 (!willRaiseLevel) {
|
||||||
+ if (!event.callEvent()) {
|
|
||||||
+ return null;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (!event.willRaiseLevel()) {
|
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
return iblockdata;
|
return iblockdata;
|
||||||
} else {
|
} else {
|
||||||
|
@ -201,3 +201,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
||||||
player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
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
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren