mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Fix some NPE for EntityCompostItemEvent (#9169)
This commit is contained in:
@@ -9,27 +9,27 @@ 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 {
|
||||
return InteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack, rand);
|
||||
+ if (iblockdata1 == null) {
|
||||
// Paper start - EntityChangeBlockEvent
|
||||
double rand = world.getRandom().nextDouble();
|
||||
BlockState dummyBlockState = ComposterBlock.addItem(player, state, org.bukkit.craftbukkit.util.DummyGeneratorAccess.INSTANCE, pos, itemstack, rand);
|
||||
+ if (dummyBlockState == null) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
return state;
|
||||
}
|
||||
iblockdata1 = ComposterBlock.addItem(user, state, world, pos, stack, rand);
|
||||
// CraftBukkit start
|
||||
double rand = world.getRandom().nextDouble();
|
||||
BlockState iblockdata1 = ComposterBlock.addItem(user, state, DummyGeneratorAccess.INSTANCE, pos, stack, rand);
|
||||
+ // Paper start
|
||||
+ if (iblockdata1 == null) {
|
||||
+ return state;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
|
||||
stack.shrink(1);
|
||||
if (state == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(user, pos, iblockdata1).isCancelled()) {
|
||||
return state;
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
|
||||
int i = (Integer) iblockdata.getValue(ComposterBlock.LEVEL);
|
||||
float f = ComposterBlock.COMPOSTABLES.getFloat(itemstack.getItem());
|
||||
|
Reference in New Issue
Block a user