Skip to content

Commit

Permalink
Fix incorrect parameter for SilentChest PacketPlayOutOpenWindow
Browse files Browse the repository at this point in the history
Probably fixes issues with ProtocolSupport, and if it doesn't there's nothing else I can do as we'll be as close to identical to NMS as possible.
  • Loading branch information
Jikoo committed Jan 10, 2017
1 parent 72ef873 commit ef48603
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import net.minecraft.server.v1_11_R1.EntityPlayer;
import net.minecraft.server.v1_11_R1.EnumDirection;
import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.IInventory;
import net.minecraft.server.v1_11_R1.ITileInventory;
import net.minecraft.server.v1_11_R1.InventoryEnderChest;
import net.minecraft.server.v1_11_R1.InventoryLargeChest;
Expand Down Expand Up @@ -168,7 +167,7 @@ public boolean activateContainer(Player p, boolean silentchest, org.bukkit.block

final World world = player.world;
final BlockPosition blockPosition = new BlockPosition(b.getX(), b.getY(), b.getZ());
Object tile = world.getTileEntity(blockPosition);
final Object tile = world.getTileEntity(blockPosition);

if (tile == null) {
return false;
Expand All @@ -183,10 +182,12 @@ public boolean activateContainer(Player p, boolean silentchest, org.bukkit.block
return true;
}

if (!(tile instanceof IInventory)) {
if (!(tile instanceof ITileInventory)) {
return false;
}

ITileInventory tileInventory = (ITileInventory) tile;

Block block = world.getType(blockPosition).getBlock();
Container container = null;

Expand All @@ -207,11 +208,11 @@ public boolean activateContainer(Player p, boolean silentchest, org.bukkit.block
}

if ((localEnumDirection == EnumDirection.WEST) || (localEnumDirection == EnumDirection.NORTH)) {
tile = new InventoryLargeChest("container.chestDouble",
(TileEntityChest) localTileEntity, (ITileInventory) tile);
tileInventory = new InventoryLargeChest("container.chestDouble",
(TileEntityChest) localTileEntity, tileInventory);
} else {
tile = new InventoryLargeChest("container.chestDouble",
(ITileInventory) tile, (TileEntityChest) localTileEntity);
tileInventory = new InventoryLargeChest("container.chestDouble",
tileInventory, (TileEntityChest) localTileEntity);
}
break;
}
Expand All @@ -223,32 +224,31 @@ public boolean activateContainer(Player p, boolean silentchest, org.bukkit.block
}

if (silentchest) {
container = new SilentContainerChest(player.inventory, ((IInventory) tile), player);
container = new SilentContainerChest(player.inventory, tileInventory, player);
}
}

if (block instanceof BlockShulkerBox) {
player.b(StatisticList.getStatistic("stat.shulkerBoxOpened"));

if (silentchest && tile instanceof TileEntityShulkerBox) {
if (silentchest && tileInventory instanceof TileEntityShulkerBox) {
// Set value to current + 1. Ensures consistency later when resetting.
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tile,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile) + 1);
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tileInventory,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tileInventory) + 1);

container = new SilentContainerShulkerBox(player.inventory, (IInventory) tile, player);
container = new SilentContainerShulkerBox(player.inventory, tileInventory, player);
}
}

boolean returnValue = false;
final IInventory iInventory = (IInventory) tile;

if (!silentchest || container == null) {
player.openContainer(iInventory);
player.openContainer(tileInventory);
returnValue = true;
} else {
try {
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, iInventory.getName(), iInventory.getScoreboardDisplayName(), iInventory.getSize()));
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, tileInventory.getContainerName(), tileInventory.getScoreboardDisplayName(), tileInventory.getSize()));
player.activeContainer = container;
player.activeContainer.windowId = windowId;
player.activeContainer.addSlotListener(player);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<openinv.version>3.0.6-SNAPSHOT</openinv.version>
<openinv.version>3.0.6</openinv.version>
</properties>

<modules>
Expand Down

0 comments on commit ef48603

Please sign in to comment.