@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/BlockComposter.java
|
||||
+++ b/net/minecraft/world/level/block/BlockComposter.java
|
||||
@@ -36,12 +36,18 @@
|
||||
@@ -38,6 +38,12 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
|
||||
@@ -12,15 +12,17 @@
|
||||
+
|
||||
public class BlockComposter extends Block implements IInventoryHolder {
|
||||
|
||||
public static final BlockStateInteger a = BlockProperties.as;
|
||||
public static final Object2FloatMap<IMaterial> b = new Object2FloatOpenHashMap();
|
||||
private static final VoxelShape c = VoxelShapes.b();
|
||||
- private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> {
|
||||
+ private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error
|
||||
public static final int READY = 8;
|
||||
@@ -47,7 +53,7 @@
|
||||
public static final Object2FloatMap<IMaterial> COMPOSTABLES = new Object2FloatOpenHashMap();
|
||||
private static final int AABB_SIDE_THICKNESS = 2;
|
||||
private static final VoxelShape OUTER_SHAPE = VoxelShapes.b();
|
||||
- private static final VoxelShape[] SHAPES = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> {
|
||||
+ private static final VoxelShape[] SHAPES = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
||||
avoxelshape[i] = VoxelShapes.a(BlockComposter.OUTER_SHAPE, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
||||
}
|
||||
@@ -187,18 +193,25 @@
|
||||
@@ -225,18 +231,25 @@
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
} else if (i == 8) {
|
||||
@@ -34,22 +36,22 @@
|
||||
|
||||
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
|
||||
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
int i = (Integer) iblockdata.get(BlockComposter.LEVEL);
|
||||
|
||||
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
||||
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
||||
if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) {
|
||||
- IBlockData iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ double rand = worldserver.getRandom().nextDouble();
|
||||
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ IBlockData iblockdata1 = a(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
|
||||
+ iblockdata1 = a(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.subtract(1);
|
||||
return iblockdata1;
|
||||
@@ -207,7 +220,15 @@
|
||||
@@ -245,7 +258,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@
|
||||
+ // CraftBukkit start
|
||||
+ public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
+ if (entity != null) {
|
||||
+ IBlockData iblockdata1 = d(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
|
||||
+ IBlockData iblockdata1 = c(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
@@ -66,69 +68,71 @@
|
||||
if (!world.isClientSide) {
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D;
|
||||
@@ -233,10 +254,16 @@
|
||||
@@ -271,10 +292,16 @@
|
||||
}
|
||||
|
||||
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||
static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ return b(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||
+ return a(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||
+ }
|
||||
+
|
||||
+ private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
|
||||
+ static IBlockData a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
|
||||
+ // CraftBukkit end
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
float f = BlockComposter.b.getFloat(itemstack.getItem());
|
||||
int i = (Integer) iblockdata.get(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;
|
||||
@@ -284,7 +311,8 @@
|
||||
@@ -322,7 +349,8 @@
|
||||
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
int i = (Integer) iblockdata.get(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)));
|
||||
}
|
||||
|
||||
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
||||
@@ -296,6 +324,7 @@
|
||||
|
||||
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
super(1);
|
||||
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
|
||||
this.a = iblockdata;
|
||||
this.b = generatoraccess;
|
||||
this.c = blockposition;
|
||||
@@ -348,6 +377,7 @@
|
||||
this.blockData = iblockdata;
|
||||
this.generatorAccess = generatoraccess;
|
||||
this.blockPosition = blockposition;
|
||||
private static class ContainerOutput extends InventorySubcontainer implements IWorldInventory {
|
||||
@@ -337,6 +365,7 @@
|
||||
this.state = iblockdata;
|
||||
this.level = generatoraccess;
|
||||
this.pos = blockposition;
|
||||
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -372,15 +402,23 @@
|
||||
@@ -361,8 +390,15 @@
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
- BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
|
||||
- this.emptied = true;
|
||||
- BlockComposter.c(this.state, this.level, this.pos);
|
||||
- this.changed = true;
|
||||
+ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
|
||||
+ if (this.isEmpty()) {
|
||||
+ BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
|
||||
+ this.emptied = true;
|
||||
+ BlockComposter.c(this.state, this.level, this.pos);
|
||||
+ this.changed = true;
|
||||
+ } else {
|
||||
+ this.generatorAccess.setTypeAndData(this.blockPosition, this.blockData, 3);
|
||||
+ this.emptied = false;
|
||||
+ this.level.setTypeAndData(this.pos, this.state, 3);
|
||||
+ this.changed = false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
|
||||
@@ -375,6 +411,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;
|
||||
@@ -417,8 +454,9 @@
|
||||
|
||||
private static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
|
||||
|
||||
- public ContainerEmpty() {
|
||||
+ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit
|
||||
|
||||
Reference in New Issue
Block a user