diff options
Diffstat (limited to 'patch-remap/og/net/minecraft/world/level/block/BlockComposter.patch')
-rw-r--r-- | patch-remap/og/net/minecraft/world/level/block/BlockComposter.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/patch-remap/og/net/minecraft/world/level/block/BlockComposter.patch b/patch-remap/og/net/minecraft/world/level/block/BlockComposter.patch new file mode 100644 index 0000000000..3fd61efded --- /dev/null +++ b/patch-remap/og/net/minecraft/world/level/block/BlockComposter.patch @@ -0,0 +1,116 @@ +--- a/net/minecraft/world/level/block/BlockComposter.java ++++ b/net/minecraft/world/level/block/BlockComposter.java +@@ -41,6 +41,11 @@ + import net.minecraft.world.phys.shapes.VoxelShapeCollision; + import net.minecraft.world.phys.shapes.VoxelShapes; + ++// CraftBukkit start ++import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder; ++import org.bukkit.craftbukkit.util.DummyGeneratorAccess; ++// CraftBukkit end ++ + public class BlockComposter extends Block implements IInventoryHolder { + + public static final MapCodec<BlockComposter> CODEC = simpleCodec(BlockComposter::new); +@@ -255,7 +260,14 @@ + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); + + if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) { +- IBlockData iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack); ++ // CraftBukkit start ++ double rand = worldserver.getRandom().nextDouble(); ++ IBlockData iblockdata1 = addItem(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand); ++ if (iblockdata == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) { ++ return iblockdata; ++ } ++ iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack, rand); ++ // CraftBukkit end + + itemstack.shrink(1); + return iblockdata1; +@@ -265,6 +277,14 @@ + } + + public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) { ++ // CraftBukkit start ++ if (entity != null && !(entity instanceof EntityHuman)) { ++ IBlockData iblockdata1 = empty(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition); ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) { ++ return iblockdata; ++ } ++ } ++ // CraftBukkit end + if (!world.isClientSide) { + Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F); + EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL)); +@@ -288,10 +308,16 @@ + } + + static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) { ++ // CraftBukkit start ++ return addItem(entity, iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble()); ++ } ++ ++ static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) { ++ // CraftBukkit end + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); + float f = BlockComposter.COMPOSTABLES.getFloat(itemstack.getItem()); + +- if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) { ++ if ((i != 0 || f <= 0.0F) && rand >= (double) f) { + return iblockdata; + } else { + int j = i + 1; +@@ -340,7 +366,8 @@ + public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL); + +- return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty())); ++ // CraftBukkit - empty generatoraccess, blockposition ++ return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition))); + } + + public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory { +@@ -355,6 +382,7 @@ + this.state = iblockdata; + this.level = generatoraccess; + this.pos = blockposition; ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + } + + @Override +@@ -379,8 +407,15 @@ + + @Override + public void setChanged() { ++ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent) ++ if (this.isEmpty()) { + BlockComposter.empty((Entity) null, this.state, this.level, this.pos); + this.changed = true; ++ } else { ++ this.level.setBlock(this.pos, this.state, 3); ++ this.changed = false; ++ } ++ // CraftBukkit end + } + } + +@@ -393,6 +428,7 @@ + + public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { + super(1); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + this.state = iblockdata; + this.level = generatoraccess; + this.pos = blockposition; +@@ -435,8 +471,9 @@ + + public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory { + +- public ContainerEmpty() { ++ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit + super(0); ++ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit + } + + @Override |