diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 69ba4efc..b5a75f84 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -310,6 +310,15 @@ public abstract class AEBaseGui extends GuiContainer OptionalSlotFake fs = (OptionalSlotFake) o; if ( fs.isEnabled() ) this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 ); + else + { + GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); + GL11.glColor4f( 1.0F, 1.0F, 1.0F, 0.4F ); + GL11.glEnable( GL11.GL_BLEND ); + this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 ); + GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); + GL11.glPopAttrib(); + } } } } diff --git a/client/gui/implementations/GuiChest.java b/client/gui/implementations/GuiChest.java index c487e34d..4bc888fc 100644 --- a/client/gui/implementations/GuiChest.java +++ b/client/gui/implementations/GuiChest.java @@ -1,14 +1,49 @@ package appeng.client.gui.implementations; +import java.io.IOException; + +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiTabButton; import appeng.container.implementations.ContainerChest; import appeng.core.localization.GuiText; +import appeng.core.sync.GuiBridge; +import appeng.core.sync.packets.PacketSwitchGuis; import appeng.tile.storage.TileChest; +import cpw.mods.fml.common.network.PacketDispatcher; public class GuiChest extends AEBaseGui { + GuiTabButton priority; + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + super.actionPerformed( par1GuiButton ); + + if ( par1GuiButton == priority ) + { + try + { + PacketDispatcher.sendPacketToServer( (new PacketSwitchGuis( GuiBridge.GUI_PRIORITY )).getPacket() ); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + @Override + public void initGui() + { + super.initGui(); + + buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRenderer ) ); + } + public GuiChest(InventoryPlayer inventoryPlayer, TileChest te) { super( new ContainerChest( inventoryPlayer, te ) ); this.ySize = 166; diff --git a/client/gui/implementations/GuiDrive.java b/client/gui/implementations/GuiDrive.java index d8db233e..af1f4550 100644 --- a/client/gui/implementations/GuiDrive.java +++ b/client/gui/implementations/GuiDrive.java @@ -1,14 +1,49 @@ package appeng.client.gui.implementations; +import java.io.IOException; + +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiTabButton; import appeng.container.implementations.ContainerDrive; import appeng.core.localization.GuiText; +import appeng.core.sync.GuiBridge; +import appeng.core.sync.packets.PacketSwitchGuis; import appeng.tile.storage.TileDrive; +import cpw.mods.fml.common.network.PacketDispatcher; public class GuiDrive extends AEBaseGui { + GuiTabButton priority; + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + super.actionPerformed( par1GuiButton ); + + if ( par1GuiButton == priority ) + { + try + { + PacketDispatcher.sendPacketToServer( (new PacketSwitchGuis( GuiBridge.GUI_PRIORITY )).getPacket() ); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + @Override + public void initGui() + { + super.initGui(); + + buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRenderer ) ); + } + public GuiDrive(InventoryPlayer inventoryPlayer, TileDrive te) { super( new ContainerDrive( inventoryPlayer, te ) ); this.ySize = 199; diff --git a/client/gui/implementations/GuiLevelEmitter.java b/client/gui/implementations/GuiLevelEmitter.java index fdb210e9..ac2062be 100644 --- a/client/gui/implementations/GuiLevelEmitter.java +++ b/client/gui/implementations/GuiLevelEmitter.java @@ -2,6 +2,7 @@ package appeng.client.gui.implementations; import java.io.IOException; +import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; import appeng.api.config.FuzzyMode; @@ -20,6 +21,9 @@ public class GuiLevelEmitter extends GuiUpgradeable GuiTextField level; + GuiButton plus1, plus10, plus100, plus1000; + GuiButton minus1, minus10, minus100, minus1000; + public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) { super( new ContainerLevelEmitter( inventoryPlayer, te ) ); } @@ -28,6 +32,7 @@ public class GuiLevelEmitter extends GuiUpgradeable public void initGui() { super.initGui(); + level = new GuiTextField( this.fontRenderer, this.guiLeft + 44, this.guiTop + 43, 59, this.fontRenderer.FONT_HEIGHT ); level.setEnableBackgroundDrawing( false ); level.setMaxStringLength( 16 ); @@ -43,10 +48,77 @@ public class GuiLevelEmitter extends GuiUpgradeable redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_EMITTER, RedstoneMode.IGNORE ); fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+1" ) ); + buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+10" ) ); + buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+100" ) ); + buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+1000" ) ); + + buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-1" ) ); + buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-10" ) ); + buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-100" ) ); + buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-1000" ) ); + buttonList.add( redstoneMode ); buttonList.add( fuzzyMode ); } + @Override + protected void actionPerformed(GuiButton btn) + { + super.actionPerformed( btn ); + + if ( btn == plus1 ) + addQty( 1 ); + if ( btn == plus10 ) + addQty( 10 ); + if ( btn == plus100 ) + addQty( 100 ); + if ( btn == plus1000 ) + addQty( 1000 ); + if ( btn == minus1 ) + addQty( -1 ); + if ( btn == minus10 ) + addQty( -10 ); + if ( btn == minus100 ) + addQty( -100 ); + if ( btn == minus1000 ) + addQty( -1000 ); + } + + private void addQty(int i) + { + try + { + String Out = level.getText(); + + boolean Fixed = false; + while (Out.startsWith( "0" ) && Out.length() > 1) + { + Out = Out.substring( 1 ); + Fixed = true; + } + + if ( Fixed ) + level.setText( Out ); + + if ( Out.length() == 0 ) + Out = "0"; + + long result = Long.parseLong( Out ); + result += i; + if ( result < 0 ) + result = 0; + + level.setText( Out = Long.toString( result ) ); + + PacketDispatcher.sendPacketToServer( (new PacketValueConfig( "LevelEmitter.Value", Out )).getPacket() ); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + protected void handleButtonVisiblity() { fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ); diff --git a/client/gui/implementations/GuiStorageBus.java b/client/gui/implementations/GuiStorageBus.java index 58f2d7a4..40b8c9de 100644 --- a/client/gui/implementations/GuiStorageBus.java +++ b/client/gui/implementations/GuiStorageBus.java @@ -11,9 +11,12 @@ import appeng.api.config.AccessRestriction; import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; import appeng.client.gui.widgets.GuiImgButton; +import appeng.client.gui.widgets.GuiTabButton; import appeng.container.implementations.ContainerStorageBus; import appeng.core.localization.GuiText; +import appeng.core.sync.GuiBridge; import appeng.core.sync.packets.PacketConfigButton; +import appeng.core.sync.packets.PacketSwitchGuis; import appeng.parts.misc.PartStorageBus; import cpw.mods.fml.common.network.PacketDispatcher; @@ -21,10 +24,11 @@ public class GuiStorageBus extends GuiUpgradeable { GuiImgButton rwMode; + GuiTabButton priority; public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) { super( new ContainerStorageBus( inventoryPlayer, te ) ); - this.ySize = 245; + this.ySize = 251; } @Override @@ -52,6 +56,8 @@ public class GuiStorageBus extends GuiUpgradeable fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACCESS, AccessRestriction.READ_WRITE ); + buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRenderer ) ); + buttonList.add( fuzzyMode ); buttonList.add( rwMode ); } @@ -63,6 +69,17 @@ public class GuiStorageBus extends GuiUpgradeable boolean backwards = Mouse.isButtonDown( 1 ); + if ( btn == priority ) + { + try + { + PacketDispatcher.sendPacketToServer( (new PacketSwitchGuis( GuiBridge.GUI_PRIORITY )).getPacket() ); + } + catch (IOException e) + { + e.printStackTrace(); + } + } try { if ( btn == fuzzyMode ) diff --git a/client/gui/implementations/GuiUpgradeable.java b/client/gui/implementations/GuiUpgradeable.java index 478effbd..02dae4f2 100644 --- a/client/gui/implementations/GuiUpgradeable.java +++ b/client/gui/implementations/GuiUpgradeable.java @@ -51,8 +51,8 @@ public class GuiUpgradeable extends AEBaseGui protected void addButtons() { - redstoneMode = new GuiImgButton( 122 + guiLeft, 31 + guiTop, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); - fuzzyMode = new GuiImgButton( 122 + guiLeft, 49 + guiTop, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); + redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE ); + fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); buttonList.add( redstoneMode ); buttonList.add( fuzzyMode ); diff --git a/client/render/BusRenderer.java b/client/render/BusRenderer.java index 9775a82f..0426f7aa 100644 --- a/client/render/BusRenderer.java +++ b/client/render/BusRenderer.java @@ -59,7 +59,8 @@ public class BusRenderer implements IItemRenderer if ( type == ItemRenderType.INVENTORY ) GL11.glTranslatef( 0.0f, -0.1f, 0.0f ); - GL11.glTranslated( 0.2, 0.3, 0.0 ); + GL11.glTranslated( 0.2, 0.3, 0.1 ); + GL11.glScaled( 1.2, 1.2, 1. ); GL11.glColor4f( 1, 1, 1, 1 ); Tessellator.instance.setColorOpaque_F( 1, 1, 1 ); diff --git a/container/AEBaseContainer.java b/container/AEBaseContainer.java index 24be1b2d..dbb67bc7 100644 --- a/container/AEBaseContainer.java +++ b/container/AEBaseContainer.java @@ -43,6 +43,8 @@ public abstract class AEBaseContainer extends Container BaseActionSource mySrc; + public ContainerOpenContext openContext; + protected IMEInventoryHandler cellInv; protected IEnergySource powerSrc; protected HashSet locked = new HashSet(); diff --git a/container/implementations/ContainerStorageBus.java b/container/implementations/ContainerStorageBus.java index 9f1c8d93..20b55b19 100644 --- a/container/implementations/ContainerStorageBus.java +++ b/container/implementations/ContainerStorageBus.java @@ -6,6 +6,9 @@ import net.minecraft.inventory.IInventory; import appeng.api.config.AccessRestriction; import appeng.api.config.FuzzyMode; import appeng.api.config.Settings; +import appeng.api.config.Upgrades; +import appeng.container.slot.OptionalSlotFakeTypeOnly; +import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; import appeng.parts.misc.PartStorageBus; @@ -25,7 +28,7 @@ public class ContainerStorageBus extends ContainerUpgradeable @Override protected int getHeight() { - return 245; + return 251; } @Override @@ -40,16 +43,38 @@ public class ContainerStorageBus extends ContainerUpgradeable return true; } + @Override + public boolean isSlotEnabled(int idx) + { + int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY ); + + return upgrades > idx; + } + @Override protected void setupConfig() { + int xo = 8; + int yo = 23 + 6; + + IInventory config = myte.getInventoryByName( "config" ); + for (int y = 0; y < 7; y++) + { + for (int x = 0; x < 9; x++) + { + if ( y < 2 ) + addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) ); + else + addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) ); + } + } + IInventory upgrades = myte.getInventoryByName( "upgrades" ); addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0 )).setNotDraggable() ); addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1 )).setNotDraggable() ); addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2 )).setNotDraggable() ); addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3 )).setNotDraggable() ); addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4 )).setNotDraggable() ); - } @Override diff --git a/container/implementations/ContainerUpgradeable.java b/container/implementations/ContainerUpgradeable.java index 2738d2f8..3cbdd04e 100644 --- a/container/implementations/ContainerUpgradeable.java +++ b/container/implementations/ContainerUpgradeable.java @@ -19,7 +19,7 @@ import appeng.container.slot.OptionalSlotFakeTypeOnly; import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; -import appeng.helpers.NetworkToolViewer; +import appeng.items.contents.NetworkToolViewer; import appeng.items.tools.ToolNetworkTool; import appeng.util.Platform; import cpw.mods.fml.relauncher.Side; diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index cea8e266..58525e98 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -19,7 +19,7 @@ public enum GuiText NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain, - StorageBus; + StorageBus, Priority, Security; String root; diff --git a/core/sync/AppEngPacketHandlerBase.java b/core/sync/AppEngPacketHandlerBase.java index 138bed2b..7adac36f 100644 --- a/core/sync/AppEngPacketHandlerBase.java +++ b/core/sync/AppEngPacketHandlerBase.java @@ -15,6 +15,7 @@ import appeng.core.sync.packets.PacketMatterCannon; import appeng.core.sync.packets.PacketMockExplosion; import appeng.core.sync.packets.PacketMultiPart; import appeng.core.sync.packets.PacketPartPlacement; +import appeng.core.sync.packets.PacketSwitchGuis; import appeng.core.sync.packets.PacketValueConfig; public class AppEngPacketHandlerBase @@ -42,7 +43,9 @@ public class AppEngPacketHandlerBase PACKET_LOCALIZED_CHATMSG(PacketLocalizedChatMsg.class), - PACKET_VALUE_CONFIG(PacketValueConfig.class); + PACKET_VALUE_CONFIG(PacketValueConfig.class), + + PACKET_SWITCH_GUIS(PacketSwitchGuis.class); final public Class pc; final public Constructor con; diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index 3d7f2574..60455566 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -17,7 +17,9 @@ import appeng.api.parts.IPart; import appeng.api.parts.IPartHost; import appeng.api.storage.IStorageMonitorable; import appeng.client.gui.GuiNull; +import appeng.container.AEBaseContainer; import appeng.container.ContainerNull; +import appeng.container.ContainerOpenContext; import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerChest; import appeng.container.implementations.ContainerCondenser; @@ -30,16 +32,20 @@ import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.implementations.ContainerMEPortableCell; import appeng.container.implementations.ContainerNetworkStatus; import appeng.container.implementations.ContainerNetworkTool; +import appeng.container.implementations.ContainerPriority; import appeng.container.implementations.ContainerQNB; +import appeng.container.implementations.ContainerSecurity; import appeng.container.implementations.ContainerStorageBus; import appeng.container.implementations.ContainerUpgradeable; import appeng.container.implementations.ContainerVibrationChamber; import appeng.helpers.IInterfaceHost; +import appeng.helpers.IPriorityHost; import appeng.parts.automation.PartLevelEmitter; import appeng.parts.misc.PartStorageBus; import appeng.tile.grindstone.TileGrinder; import appeng.tile.misc.TileCellWorkbench; import appeng.tile.misc.TileCondenser; +import appeng.tile.misc.TileSecurity; import appeng.tile.misc.TileVibrationChamber; import appeng.tile.qnb.TileQuantumBridge; import appeng.tile.storage.TileChest; @@ -81,6 +87,10 @@ public enum GuiBridge implements IGuiHandler GUI_STORAGEBUS(ContainerStorageBus.class, PartStorageBus.class, false), + GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, false), + + GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, false), + // extends (Container/Gui) + Bus GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false), @@ -166,6 +176,22 @@ public enum GuiBridge implements IGuiHandler } } + private Object updateGui(Object newContainer, World w, int x, int y, int z, ForgeDirection side) + { + if ( newContainer instanceof AEBaseContainer ) + { + AEBaseContainer bc = (AEBaseContainer) newContainer; + bc.openContext = new ContainerOpenContext(); + bc.openContext.w = w; + bc.openContext.x = x; + bc.openContext.y = y; + bc.openContext.z = z; + bc.openContext.side = side; + } + + return newContainer; + } + @Override public Object getServerGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z) { @@ -179,7 +205,7 @@ public enum GuiBridge implements IGuiHandler { Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z ); if ( ID.CorrectTileOrPart( myItem ) ) - return ID.ConstructContainer( player.inventory, side, myItem ); + return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side ); } } else @@ -190,12 +216,12 @@ public enum GuiBridge implements IGuiHandler ((IPartHost) TE).getPart( side ); IPart part = ((IPartHost) TE).getPart( side ); if ( ID.CorrectTileOrPart( part ) ) - return ID.ConstructContainer( player.inventory, side, part ); + return updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side ); } else { if ( ID.CorrectTileOrPart( TE ) ) - return ID.ConstructContainer( player.inventory, side, TE ); + return updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side ); } } diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index a97efb34..84fa82c3 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -11,6 +11,7 @@ import net.minecraft.network.INetworkManager; import appeng.api.config.FuzzyMode; import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerLevelEmitter; +import appeng.container.implementations.ContainerPriority; import appeng.core.sync.AppEngPacket; public class PacketValueConfig extends AppEngPacket @@ -30,7 +31,13 @@ public class PacketValueConfig extends AppEngPacket { Container c = player.openContainer; - if ( Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter ) + if ( Name.equals( "PriorityHost.Priority" ) && c instanceof ContainerPriority ) + { + ContainerPriority pc = (ContainerPriority) c; + pc.setPriority( Integer.parseInt( Value ), player ); + return; + } + else if ( Name.equals( "LevelEmitter.Value" ) && c instanceof ContainerLevelEmitter ) { ContainerLevelEmitter lvc = (ContainerLevelEmitter) c; lvc.setLevel( Integer.parseInt( Value ), player ); diff --git a/debug/TileChunkLoader.java b/debug/TileChunkLoader.java index 734fbdca..f2d59c6c 100644 --- a/debug/TileChunkLoader.java +++ b/debug/TileChunkLoader.java @@ -1,6 +1,5 @@ package appeng.debug; -import java.util.EnumSet; import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; @@ -27,7 +26,7 @@ public class TileChunkLoader extends AEBaseTile { public ChunkLoaderHandler() { - super( EnumSet.of( TileEventType.TICK ) ); + super( TileEventType.TICK ); } @Override diff --git a/helpers/NetworkToolViewer.java b/helpers/NetworkToolViewer.java deleted file mode 100644 index 2a6a7d8d..00000000 --- a/helpers/NetworkToolViewer.java +++ /dev/null @@ -1,117 +0,0 @@ -package appeng.helpers; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import appeng.api.implementations.guiobjects.INetworkTool; -import appeng.api.implementations.items.IUpgradeModule; -import appeng.api.networking.IGridHost; -import appeng.tile.inventory.AppEngInternalInventory; -import appeng.util.Platform; - -public class NetworkToolViewer implements INetworkTool -{ - - final AppEngInternalInventory inv; - final ItemStack is; - final IGridHost gh; - - public NetworkToolViewer(ItemStack is, IGridHost gHost) { - this.is = is; - gh = gHost; - inv = new AppEngInternalInventory( null, 9 ); - inv.readFromNBT( Platform.openNbtData( is ), "inv" ); - } - - @Override - public int getSizeInventory() - { - return inv.getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) - { - return inv.getStackInSlot( i ); - } - - @Override - public ItemStack decrStackSize(int i, int j) - { - return inv.decrStackSize( i, j ); - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - return inv.getStackInSlotOnClosing( i ); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - inv.setInventorySlotContents( i, itemstack ); - } - - @Override - public String getInvName() - { - return inv.getInvName(); - } - - @Override - public boolean isInvNameLocalized() - { - return inv.isInvNameLocalized(); - } - - @Override - public int getInventoryStackLimit() - { - return inv.getInventoryStackLimit(); - } - - @Override - public void onInventoryChanged() - { - inv.onInventoryChanged(); - inv.writeToNBT( Platform.openNbtData( is ), "inv" ); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return inv.isUseableByPlayer( entityplayer ); - } - - @Override - public void openChest() - { - inv.openChest(); - } - - @Override - public void closeChest() - { - inv.closeChest(); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return inv.isItemValidForSlot( i, itemstack ) && itemstack.getItem() instanceof IUpgradeModule - && ((IUpgradeModule) itemstack.getItem()).getType( itemstack ) != null; - } - - @Override - public ItemStack getItemStack() - { - return is; - } - - @Override - public IGridHost getGridHost() - { - return gh; - } - -} diff --git a/helpers/PartPlacement.java b/helpers/PartPlacement.java index 8c91981c..a14cc00e 100644 --- a/helpers/PartPlacement.java +++ b/helpers/PartPlacement.java @@ -100,6 +100,7 @@ public class PartPlacement { is.add( sp.facade.getItemStack() ); host.getFacadeContainer().removeFacade( host, sp.side ); + world.notifyBlocksOfNeighborChange( x, y, z, 0 ); } if ( host.isEmpty() ) @@ -272,7 +273,7 @@ public class PartPlacement return true; } } - else + else if ( host != null && !host.canAddPart( held, side ) ) return false; } diff --git a/helpers/PortableCellViewer.java b/helpers/PortableCellViewer.java deleted file mode 100644 index 49d4b540..00000000 --- a/helpers/PortableCellViewer.java +++ /dev/null @@ -1,54 +0,0 @@ -package appeng.helpers; - -import net.minecraft.item.ItemStack; -import appeng.api.config.Actionable; -import appeng.api.config.PowerMultiplier; -import appeng.api.implementations.guiobjects.IPortableCell; -import appeng.api.implementations.items.IAEItemPowerStorage; -import appeng.api.storage.IMEMonitor; -import appeng.api.storage.MEMonitorHandler; -import appeng.api.storage.data.IAEFluidStack; -import appeng.api.storage.data.IAEItemStack; -import appeng.me.storage.CellInventory; - -public class PortableCellViewer extends MEMonitorHandler implements IPortableCell -{ - - private ItemStack target; - private IAEItemPowerStorage ips; - - public PortableCellViewer(ItemStack is) { - super( CellInventory.getCell( is ) ); - ips = (IAEItemPowerStorage) is.getItem(); - target = is; - } - - public ItemStack getItemStack() - { - return target; - } - - @Override - public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) - { - amt = usePowerMultiplier.multiply( amt ); - - if ( mode == Actionable.SIMULATE ) - return usePowerMultiplier.divide( Math.min( amt, ips.getAECurrentPower( getItemStack() ) ) ); - - return usePowerMultiplier.divide( ips.extractAEPower( getItemStack(), amt ) ); - } - - @Override - public IMEMonitor getItemInventory() - { - return this; - } - - @Override - public IMEMonitor getFluidInventory() - { - return null; - } - -} diff --git a/items/parts/ItemFacade.java b/items/parts/ItemFacade.java index 48e270ad..ad2807e6 100644 --- a/items/parts/ItemFacade.java +++ b/items/parts/ItemFacade.java @@ -32,7 +32,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem setfeature( EnumSet.of( AEFeature.Facades ) ); setHasSubtypes( true ); if ( Platform.isClient() ) - MinecraftForgeClient.registerItemRenderer( this.itemID, BusRenderer.instance ); + MinecraftForgeClient.registerItemRenderer( itemID, BusRenderer.instance ); } @Override @@ -70,7 +70,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem { ItemStack is = new ItemStack( AEApi.instance().items().itemFacade.item() ); NBTTagCompound data = new NBTTagCompound(); - data.setIntArray( "x", ids ); + data.setIntArray( "x", ids.clone() ); is.setTagCompound( data ); return is; } diff --git a/items/storage/CellConfig.java b/items/storage/CellConfig.java deleted file mode 100644 index 4d026366..00000000 --- a/items/storage/CellConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package appeng.items.storage; - -import net.minecraft.item.ItemStack; -import appeng.tile.inventory.AppEngInternalInventory; -import appeng.util.Platform; - -public class CellConfig extends AppEngInternalInventory -{ - - final ItemStack is; - - public CellConfig(ItemStack is) { - super( null, 63 ); - this.is = is; - readFromNBT( Platform.openNbtData( is ), "list" ); - } - - @Override - public void onInventoryChanged() - { - writeToNBT( Platform.openNbtData( is ), "list" ); - } - -} \ No newline at end of file diff --git a/items/storage/CellUpgrades.java b/items/storage/CellUpgrades.java deleted file mode 100644 index 3f2f148d..00000000 --- a/items/storage/CellUpgrades.java +++ /dev/null @@ -1,24 +0,0 @@ -package appeng.items.storage; - -import net.minecraft.item.ItemStack; -import appeng.parts.automation.UpgradeInventory; -import appeng.util.Platform; - -public class CellUpgrades extends UpgradeInventory -{ - - final ItemStack is; - - public CellUpgrades(ItemStack is, int upgrades) { - super( is.getItem(), null, upgrades ); - this.is = is; - readFromNBT( Platform.openNbtData( is ), "upgrades" ); - } - - @Override - public void onInventoryChanged() - { - writeToNBT( Platform.openNbtData( is ), "upgrades" ); - } - -} \ No newline at end of file