From 72ef873772b0a290a72acb23d244b6f95422a3c3 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Sat, 31 Dec 2016 07:05:52 -0500 Subject: [PATCH] Fixes for shulker boxes and AnyChest in 1.11 Fixes IBlockData used being the default for a shulker box, closes #55 Corrected using wrong method to check if blocked in 1.11.2. Something something NMS version bumps. --- internal/v1_11_R1/pom.xml | 2 +- .../internal/v1_11_R1/AnySilentContainer.java | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/v1_11_R1/pom.xml b/internal/v1_11_R1/pom.xml index 208245c..eb26f81 100644 --- a/internal/v1_11_R1/pom.xml +++ b/internal/v1_11_R1/pom.xml @@ -20,7 +20,7 @@ org.spigotmc spigot - 1.11-R0.1-SNAPSHOT + 1.11.2-R0.1-SNAPSHOT provided diff --git a/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/AnySilentContainer.java b/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/AnySilentContainer.java index ec541cb..bed8cd0 100644 --- a/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/AnySilentContainer.java +++ b/internal/v1_11_R1/src/main/java/com/lishid/openinv/internal/v1_11_R1/AnySilentContainer.java @@ -69,10 +69,11 @@ public class AnySilentContainer implements IAnySilentContainer { EntityPlayer player = ((CraftPlayer) p).getHandle(); World world = player.world; BlockPosition blockPosition = new BlockPosition(b.getX(), b.getY(), b.getZ()); - Block block = world.getType(blockPosition).getBlock(); + IBlockData blockData = world.getType(blockPosition); + Block block = blockData.getBlock(); if (block instanceof BlockShulkerBox) { - return isBlockedShulkerBox(world, blockPosition, block); + return isBlockedShulkerBox(world, blockPosition, blockData); } if (block instanceof BlockEnderChest) { @@ -107,7 +108,7 @@ public class AnySilentContainer implements IAnySilentContainer { return false; } - private boolean isBlockedShulkerBox(World world, BlockPosition blockPosition, Block block) { + private boolean isBlockedShulkerBox(World world, BlockPosition blockPosition, IBlockData blockData) { // For reference, look at net.minecraft.server.BlockShulkerBox TileEntity tile = world.getTileEntity(blockPosition); @@ -115,16 +116,20 @@ public class AnySilentContainer implements IAnySilentContainer { return false; } - IBlockData iBlockData = block.getBlockData(); - - EnumDirection enumDirection = iBlockData.get(BlockShulkerBox.a); + EnumDirection enumDirection = blockData.get(BlockShulkerBox.a); if (((TileEntityShulkerBox) tile).p() == TileEntityShulkerBox.AnimationPhase.CLOSED) { - AxisAlignedBB axisAlignedBB = BlockShulkerBox.j.b(0.5F * enumDirection.getAdjacentX(), + AxisAlignedBB axisAlignedBB = Block.j.b(0.5F * enumDirection.getAdjacentX(), 0.5F * enumDirection.getAdjacentY(), 0.5F * enumDirection.getAdjacentZ()) .a(enumDirection.getAdjacentX(), enumDirection.getAdjacentY(), enumDirection.getAdjacentZ()); - return world.b(axisAlignedBB.a(blockPosition.shift(enumDirection))); + try { + // 1.11.2 + return world.a(axisAlignedBB.a(blockPosition.shift(enumDirection))); + } catch (Exception e) { + // 1.11 + return world.b(axisAlignedBB.a(blockPosition.shift(enumDirection))); + } } return false;