Updated to CraftBukkit 1.9
This commit is contained in:
@@ -29,6 +29,7 @@ import net.minecraft.server.v1_9_R1.BlockChest.Type;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.*;
|
||||
|
||||
public class AnySilentChest {
|
||||
|
||||
public boolean isAnyChestNeeded(Player p, int x, int y, int z) {
|
||||
// FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
@@ -37,16 +38,17 @@ public class AnySilentChest {
|
||||
BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).g == Type.TRAP ?
|
||||
Block.getByName("trapped_chest") : Block.getByName("chest"));
|
||||
|
||||
// If block on top
|
||||
// If a block is on top
|
||||
if (topBlocking(world, position)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If block next to chest is chest and has a block on top
|
||||
// If the block next to the chest is chest and has a block on top
|
||||
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
||||
BlockPosition sidePosition = position.shift(direction);
|
||||
Block var8 = world.getType(sidePosition).getBlock();
|
||||
if (var8 == chest) {
|
||||
Block block = world.getType(sidePosition).getBlock();
|
||||
|
||||
if (block == chest) {
|
||||
if (this.topBlocking(world, sidePosition)) {
|
||||
return true;
|
||||
}
|
||||
@@ -55,6 +57,7 @@ public class AnySilentChest {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean topBlocking(World world, BlockPosition position) {
|
||||
return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
|
||||
}
|
||||
@@ -65,20 +68,22 @@ public class AnySilentChest {
|
||||
}
|
||||
|
||||
private boolean ocelotOnTop(World world, BlockPosition position) {
|
||||
Iterator var3 = world.a(EntityOcelot.class,
|
||||
Iterator iterator = world.a(EntityOcelot.class,
|
||||
new AxisAlignedBB((double) position.getX(), (double) (position.getY() + 1),
|
||||
(double) position.getZ(), (double) (position.getX() + 1),
|
||||
(double) (position.getY() + 2), (double) (position.getZ() + 1))).iterator();
|
||||
|
||||
EntityOcelot var5;
|
||||
EntityOcelot entityOcelot;
|
||||
|
||||
do {
|
||||
if (!var3.hasNext()) {
|
||||
if (!iterator.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity var4 = (Entity) var3.next();
|
||||
var5 = (EntityOcelot) var4;
|
||||
} while (!var5.isSitting());
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
entityOcelot = (EntityOcelot) entity;
|
||||
} while (!entityOcelot.isSitting());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -107,12 +112,14 @@ public class AnySilentChest {
|
||||
for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
|
||||
BlockPosition side = position.shift(direction);
|
||||
Block block = world.getType(side).getBlock();
|
||||
|
||||
if (block == chest) {
|
||||
if (!anyChest && this.topBlocking(world, side)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity sideTileEntity = world.getTileEntity(side);
|
||||
|
||||
if (sideTileEntity instanceof TileEntityChest) {
|
||||
if (direction != EnumDirection.WEST && direction != EnumDirection.NORTH) {
|
||||
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory, (TileEntityChest) sideTileEntity);
|
||||
@@ -124,11 +131,14 @@ public class AnySilentChest {
|
||||
}
|
||||
|
||||
boolean returnValue = true;
|
||||
|
||||
if (silentChest) {
|
||||
tileInventory = new SilentInventory(tileInventory);
|
||||
|
||||
if (OpenInv.notifySilentChest()) {
|
||||
OpenInv.sendMessage(p, "You are opening a chest silently.");
|
||||
}
|
||||
|
||||
returnValue = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user