@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/BlockComposter.java
|
||||
+++ b/net/minecraft/world/level/block/BlockComposter.java
|
||||
@@ -37,6 +37,12 @@
|
||||
@@ -40,6 +40,12 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
|
||||
@@ -13,61 +13,46 @@
|
||||
public class BlockComposter extends Block implements IInventoryHolder {
|
||||
|
||||
public static final int READY = 8;
|
||||
@@ -227,18 +233,25 @@
|
||||
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
} else if (i == 8) {
|
||||
- extractProduce(iblockdata, world, blockposition);
|
||||
+ extractProduce(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
} else {
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
- public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
|
||||
+ public static IBlockData insertItem(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
|
||||
@@ -246,7 +252,14 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
|
||||
|
||||
if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) {
|
||||
- IBlockData iblockdata1 = addItem(iblockdata, worldserver, blockposition, itemstack);
|
||||
- IBlockData iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ double rand = worldserver.getRandom().nextDouble();
|
||||
+ IBlockData iblockdata1 = addItem(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ IBlockData iblockdata1 = addItem(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ iblockdata1 = addItem(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
|
||||
+ iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack, rand);
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.shrink(1);
|
||||
return iblockdata1;
|
||||
@@ -247,7 +260,15 @@
|
||||
}
|
||||
@@ -256,6 +269,14 @@
|
||||
}
|
||||
|
||||
- public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ // CraftBukkit start
|
||||
+ public static IBlockData extractProduce(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
+ if (entity != null) {
|
||||
+ IBlockData iblockdata1 = empty(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
|
||||
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).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!world.isClientSide) {
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D;
|
||||
@@ -273,10 +294,16 @@
|
||||
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));
|
||||
@@ -279,10 +300,16 @@
|
||||
}
|
||||
|
||||
static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||
static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ return addItem(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||
+ return addItem(entity, iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||
+ }
|
||||
+
|
||||
+ static IBlockData addItem(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
|
||||
+ 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());
|
||||
@@ -77,7 +62,7 @@
|
||||
return iblockdata;
|
||||
} else {
|
||||
int j = i + 1;
|
||||
@@ -324,7 +351,8 @@
|
||||
@@ -331,7 +358,8 @@
|
||||
public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
|
||||
|
||||
@@ -87,7 +72,7 @@
|
||||
}
|
||||
|
||||
public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory {
|
||||
@@ -339,6 +367,7 @@
|
||||
@@ -346,6 +374,7 @@
|
||||
this.state = iblockdata;
|
||||
this.level = generatoraccess;
|
||||
this.pos = blockposition;
|
||||
@@ -95,15 +80,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -363,8 +392,15 @@
|
||||
@@ -370,8 +399,15 @@
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
- BlockComposter.empty(this.state, this.level, this.pos);
|
||||
- BlockComposter.empty((Entity) null, this.state, this.level, this.pos);
|
||||
- this.changed = true;
|
||||
+ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
|
||||
+ if (this.isEmpty()) {
|
||||
+ BlockComposter.empty(this.state, this.level, this.pos);
|
||||
+ BlockComposter.empty((Entity) null, this.state, this.level, this.pos);
|
||||
+ this.changed = true;
|
||||
+ } else {
|
||||
+ this.level.setBlock(this.pos, this.state, 3);
|
||||
@@ -113,7 +98,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +413,7 @@
|
||||
@@ -384,6 +420,7 @@
|
||||
|
||||
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
super(1);
|
||||
@@ -121,7 +106,7 @@
|
||||
this.state = iblockdata;
|
||||
this.level = generatoraccess;
|
||||
this.pos = blockposition;
|
||||
@@ -419,8 +456,9 @@
|
||||
@@ -426,8 +463,9 @@
|
||||
|
||||
public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user