Fixed Crash in Portable Cell.

Can no longer pick up Open Portable Cell.
Can no longer insert Portable Cell into itself.
This commit is contained in:
AlgorithmX2
2014-02-01 16:25:15 -06:00
parent fbcee6ca12
commit 58d9939503
2 changed files with 15 additions and 8 deletions
@@ -2,12 +2,13 @@ package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerMEPortableCell;
public class GuiMEPortableCell extends GuiMEMonitorable public class GuiMEPortableCell extends GuiMEMonitorable
{ {
public GuiMEPortableCell(InventoryPlayer inventoryPlayer, IPortableCell te) { public GuiMEPortableCell(InventoryPlayer inventoryPlayer, IPortableCell te) {
super( inventoryPlayer, te ); super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
maxRows = 3; maxRows = 3;
} }
@@ -14,9 +14,10 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
IPortableCell civ; IPortableCell civ;
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell montiorable) { public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell montiorable) {
super( ip, (IStorageMonitorable) montiorable, Platform.isServer() ); super( ip, (IStorageMonitorable) montiorable, false );
lockPlayerInventorySlot( ip.currentItem ); lockPlayerInventorySlot( ip.currentItem );
civ = montiorable; civ = montiorable;
bindPlayerInventory( ip, 0, 0 );
} }
int ticks = 0; int ticks = 0;
@@ -26,18 +27,23 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
{ {
ItemStack currentItem = getPlayerInv().getCurrentItem(); ItemStack currentItem = getPlayerInv().getCurrentItem();
if ( currentItem != civ.getItemStack() ) if ( civ != null )
{ {
if ( currentItem != null ) if ( currentItem != civ.getItemStack() )
{ {
if ( Platform.isSameItem( civ.getItemStack(), currentItem ) ) if ( currentItem != null )
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, civ.getItemStack() ); {
if ( Platform.isSameItem( civ.getItemStack(), currentItem ) )
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, civ.getItemStack() );
else
getPlayerInv().player.closeScreen();
}
else else
getPlayerInv().player.closeScreen(); getPlayerInv().player.closeScreen();
} }
else
getPlayerInv().player.closeScreen();
} }
else
getPlayerInv().player.closeScreen();
// drain 1 ae t // drain 1 ae t
ticks++; ticks++;