Skip to content

Commit

Permalink
OK, I'm pretty sure I fixed #7 and fixed #8 this time.
Browse files Browse the repository at this point in the history
I redid the large chest contents.  I think what was happening before is
that the data for tile entity #2 was getting put in the slot for TE #1
(and vice versa) when one of the sides was getting clicked
(specifically, the south on an east/west facing chest), and minecraft
just didn't like that.  Plus, the issue from 12d5bd9 (positions getting
mixed up) also caried caused issues.
  • Loading branch information
Pokechu22 committed Jul 5, 2015
1 parent d84480f commit e7408e3
Showing 1 changed file with 74 additions and 38 deletions.
112 changes: 74 additions & 38 deletions src/wdl/WDLEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,47 +307,83 @@ public static void onItemGuiClosed() {
if (WDL.windowContainer instanceof ContainerChest
&& te instanceof TileEntityChest) {
if (WDL.windowContainer.inventorySlots.size() > 63) {
TileEntity te2;
BlockPos chestPos1 = WDL.lastClickedBlock;
BlockPos chestPos2;
TileEntityChest tec1, tec2;

if ((te2 = WDL.worldClient.getTileEntity(chestPos1.add(0, 0, 1))) instanceof TileEntityChest
&& ((TileEntityChest) te2).getChestType() == ((TileEntityChest) te)
.getChestType()) {
tec1 = (TileEntityChest) te;
tec2 = (TileEntityChest) te2;
chestPos2 = chestPos1.add(0, 0, 1);
} else if ((te2 = WDL.worldClient.getTileEntity(chestPos1.add(0, 0,
-1))) instanceof TileEntityChest
&& ((TileEntityChest) te2).getChestType() == ((TileEntityChest) te)
.getChestType()) {
tec1 = (TileEntityChest) te2;
tec2 = (TileEntityChest) te;
chestPos2 = chestPos1.add(0, 0, -1);
} else if ((te2 = WDL.worldClient.getTileEntity(chestPos1.add(1, 0,
0))) instanceof TileEntityChest
&& ((TileEntityChest) te2).getChestType() == ((TileEntityChest) te)
.getChestType()) {
tec1 = (TileEntityChest) te;
tec2 = (TileEntityChest) te2;
chestPos2 = chestPos1.add(1, 0, 0);
} else if ((te2 = WDL.worldClient.getTileEntity(chestPos1.add(-1,
0, 0))) instanceof TileEntityChest
&& ((TileEntityChest) te2).getChestType() == ((TileEntityChest) te)
.getChestType()) {
tec1 = (TileEntityChest) te2;
tec2 = (TileEntityChest) te;
chestPos2 = chestPos1.add(-1, 0, 0);
} else {
WDL.chatMsg("Could not save this chest!");
// This is messy, but it needs to be like this because
// the left and right chests must be in the right positions.

BlockPos pos1, pos2;
TileEntity te1, te2;

pos1 = WDL.lastClickedBlock;
te1 = te;

// We need seperate variables for the above reason --
// pos1 isn't always the same as chestPos1 (and thus
// chest1 isn't always te1).
BlockPos chestPos1 = null, chestPos2 = null;
TileEntityChest chest1 = null, chest2 = null;

pos2 = pos1.add(0, 0, 1);
te2 = WDL.worldClient.getTileEntity(pos2);
if (te2 instanceof TileEntityChest &&
((TileEntityChest) te2).getChestType() ==
((TileEntityChest) te1).getChestType()) {

chest1 = (TileEntityChest) te1;
chest2 = (TileEntityChest) te2;

chestPos1 = pos1;
chestPos2 = pos2;
}

pos2 = pos1.add(0, 0, -1);
te2 = WDL.worldClient.getTileEntity(pos2);
if (te2 instanceof TileEntityChest &&
((TileEntityChest) te2).getChestType() ==
((TileEntityChest) te1).getChestType()) {

chest1 = (TileEntityChest) te2;
chest2 = (TileEntityChest) te1;

chestPos1 = pos2;
chestPos2 = pos1;
}

pos2 = pos1.add(1, 0, 0);
te2 = WDL.worldClient.getTileEntity(pos2);
if (te2 instanceof TileEntityChest &&
((TileEntityChest) te2).getChestType() ==
((TileEntityChest) te1).getChestType()) {
chest1 = (TileEntityChest) te1;
chest2 = (TileEntityChest) te2;

chestPos1 = pos1;
chestPos2 = pos2;
}

pos2 = pos1.add(-1, 0, 0);
te2 = WDL.worldClient.getTileEntity(pos2);
if (te2 instanceof TileEntityChest &&
((TileEntityChest) te2).getChestType() ==
((TileEntityChest) te1).getChestType()) {
chest1 = (TileEntityChest) te2;
chest2 = (TileEntityChest) te1;

chestPos1 = pos2;
chestPos2 = pos1;
}

if (chest1 == null || chest2 == null ||
chestPos1 == null || chestPos2 == null) {
WDL.chatError("Could not save this double chest!");
WDL.chatError("Not all chest blocks were found!");
return;
}

WDL.saveContainerItems(WDL.windowContainer, tec1, 0);
WDL.saveContainerItems(WDL.windowContainer, tec2, 27);
WDL.newTileEntities.put(chestPos1, tec1);
WDL.newTileEntities.put(chestPos2, tec2);
WDL.saveContainerItems(WDL.windowContainer, chest1, 0);
WDL.saveContainerItems(WDL.windowContainer, chest2, 27);
WDL.newTileEntities.put(chestPos1, chest1);
WDL.newTileEntities.put(chestPos2, chest2);

saveName = "Double Chest contents";
}
// basic chest
Expand Down

0 comments on commit e7408e3

Please sign in to comment.