From f8e6a426ce8768a2297df26d262b9e9dff253e2f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Tue, 4 Feb 2014 20:44:54 -0600 Subject: [PATCH] Tweaked Terminal Gui to use smaller textures. Crafting Terminal Added, ( incomplete ) Moved FMP Cut-able Registration to Init. Upgrades now drop when parts break. TE -> TE3 pulverizer api. --- .../gui/implementations/GuiCraftingTerm.java | 28 +++++++++++++++++ .../gui/implementations/GuiMEMonitorable.java | 10 ++++--- client/gui/implementations/GuiSecurity.java | 6 ++-- .../ContainerCraftingTerm.java | 24 +++++++++++++++ .../implementations/ContainerSecurity.java | 4 ++- core/localization/GuiText.java | 2 ++ core/sync/GuiBridge.java | 4 +++ integration/modules/FMP.java | 8 ++--- integration/modules/TE.java | 11 ++++++- parts/automation/PartUpgradeable.java | 10 +++++++ parts/reporting/PartCraftingTerminal.java | 30 ++++++++++++++++++- parts/reporting/PartTerminal.java | 11 ++++++- 12 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 client/gui/implementations/GuiCraftingTerm.java create mode 100644 container/implementations/ContainerCraftingTerm.java diff --git a/client/gui/implementations/GuiCraftingTerm.java b/client/gui/implementations/GuiCraftingTerm.java new file mode 100644 index 00000000..232b6829 --- /dev/null +++ b/client/gui/implementations/GuiCraftingTerm.java @@ -0,0 +1,28 @@ +package appeng.client.gui.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import appeng.api.storage.IStorageMonitorable; +import appeng.container.implementations.ContainerCraftingTerm; +import appeng.core.localization.GuiText; + +public class GuiCraftingTerm extends GuiMEMonitorable +{ + + public GuiCraftingTerm(InventoryPlayer inventoryPlayer, IStorageMonitorable te) { + super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) ); + reservedSpace = 73; + } + + protected String getBackground() + { + return "guis/crafting.png"; + } + + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) + { + super.drawFG( offsetX, offsetY, mouseX, mouseY ); + fontRenderer.drawString( GuiText.CraftingTerminal.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 ); + } + +} diff --git a/client/gui/implementations/GuiMEMonitorable.java b/client/gui/implementations/GuiMEMonitorable.java index 1a3802f7..4b8f54e8 100644 --- a/client/gui/implementations/GuiMEMonitorable.java +++ b/client/gui/implementations/GuiMEMonitorable.java @@ -35,6 +35,7 @@ public class GuiMEMonitorable extends AEBaseMEGui int xoffset = 9; int perRow = 9; int reservedSpace = 0; + int lowerTextureOffset = 0; int rows = 0; int maxRows = Integer.MAX_VALUE; @@ -83,7 +84,8 @@ public class GuiMEMonitorable extends AEBaseMEGui { int NEI = 0; int top = 4; - int extraSpace = height - 114 - NEI - top - reservedSpace; + int magicNumber = 114 + 1; + int extraSpace = height - magicNumber - NEI - top - reservedSpace; rows = (int) Math.floor( extraSpace / 18 ); if ( rows > maxRows ) @@ -106,7 +108,7 @@ public class GuiMEMonitorable extends AEBaseMEGui // extra slots : 72 // slot 18 - this.ySize = 114 + rows * 18 + reservedSpace; + this.ySize = magicNumber + rows * 18 + reservedSpace; this.guiTop = top; buttonList.add( new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.SORT_BY, Configuration.instance.settings.getSetting( Settings.SORT_BY ) ) ); @@ -127,7 +129,7 @@ public class GuiMEMonitorable extends AEBaseMEGui if ( s instanceof AppEngSlot ) { if ( ((AppEngSlot) s).xDisplayPosition < 197 ) - ((AppEngSlot) s).yDisplayPosition = ((AppEngSlot) s).defY + ySize - 78 - 4; + ((AppEngSlot) s).yDisplayPosition = ((AppEngSlot) s).defY + ySize - 78 - 5; } } } @@ -176,7 +178,7 @@ public class GuiMEMonitorable extends AEBaseMEGui for (int x = 0; x < rows; x++) this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 ); - this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18, 0, 106, x_width, 98 + reservedSpace ); + this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset ); searchField.drawTextBox(); } diff --git a/client/gui/implementations/GuiSecurity.java b/client/gui/implementations/GuiSecurity.java index 1f1a84d4..a6c64f3e 100644 --- a/client/gui/implementations/GuiSecurity.java +++ b/client/gui/implementations/GuiSecurity.java @@ -16,7 +16,7 @@ public class GuiSecurity extends GuiMEMonitorable public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) { super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) ); - reservedSpace = 32; + reservedSpace = 33; xSize += 50; } @@ -27,7 +27,7 @@ public class GuiSecurity extends GuiMEMonitorable { super.initGui(); - int top = this.guiTop + this.ySize - 114; + int top = this.guiTop + this.ySize - 116; buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT .getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) ); @@ -92,7 +92,7 @@ public class GuiSecurity extends GuiMEMonitorable public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { super.drawFG( offsetX, offsetY, mouseX, mouseY ); - fontRenderer.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 3 - reservedSpace, 4210752 ); + fontRenderer.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 ); } } diff --git a/container/implementations/ContainerCraftingTerm.java b/container/implementations/ContainerCraftingTerm.java new file mode 100644 index 00000000..77dfb04a --- /dev/null +++ b/container/implementations/ContainerCraftingTerm.java @@ -0,0 +1,24 @@ +package appeng.container.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import appeng.api.storage.IStorageMonitorable; +import appeng.container.slot.SlotNormal; +import appeng.container.slot.SlotOutput; +import appeng.parts.reporting.PartCraftingTerminal; + +public class ContainerCraftingTerm extends ContainerMEMonitorable +{ + + PartCraftingTerminal ct; + + SlotNormal craftingSlots[] = new SlotNormal[9]; + SlotOutput outputSlot; + + public ContainerCraftingTerm(InventoryPlayer ip, IStorageMonitorable montiorable) { + super( ip, montiorable, false ); + ct = (PartCraftingTerminal) montiorable; + + bindPlayerInventory( ip, 0, 0 ); + } + +} diff --git a/container/implementations/ContainerSecurity.java b/container/implementations/ContainerSecurity.java index 1434426d..cedcebe0 100644 --- a/container/implementations/ContainerSecurity.java +++ b/container/implementations/ContainerSecurity.java @@ -37,7 +37,7 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE securityBox = (TileSecurity) montiorable; - addSlotToContainer( configSlot = new SlotRestrictedInput( PlaceableItemType.BIOMETRIC_CARD, securityBox.configSlot, 0, 37, -32 ) ); + addSlotToContainer( configSlot = new SlotRestrictedInput( PlaceableItemType.BIOMETRIC_CARD, securityBox.configSlot, 0, 37, -33 ) ); addSlotToContainer( wirelessIn = new SlotRestrictedInput( PlaceableItemType.WIRELESS_TERMINAL, wirelessEncoder, 0, 212, 10 ) ); addSlotToContainer( wirelessOut = new SlotOutput( wirelessEncoder, 1, 212, 68, -1 ) ); @@ -50,6 +50,8 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE @Override public void onContainerClosed(EntityPlayer player) { + super.onContainerClosed( player ); + if ( wirelessIn.getHasStack() ) player.dropPlayerItem( wirelessIn.getStack() ); diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index d2ab627a..c371484e 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -23,6 +23,8 @@ public enum GuiText SecurityCardEditor, NoPermissions, WirelessTerminal, Wireless, + CraftingTerminal, + METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel; String root; diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index 2ba6333a..7724316c 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -31,6 +31,7 @@ import appeng.container.ContainerOpenContext; import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerChest; import appeng.container.implementations.ContainerCondenser; +import appeng.container.implementations.ContainerCraftingTerm; import appeng.container.implementations.ContainerDrive; import appeng.container.implementations.ContainerGrinder; import appeng.container.implementations.ContainerIOPort; @@ -53,6 +54,7 @@ import appeng.helpers.IPriorityHost; import appeng.helpers.WirelessTerminalGuiObject; import appeng.parts.automation.PartLevelEmitter; import appeng.parts.misc.PartStorageBus; +import appeng.parts.reporting.PartCraftingTerminal; import appeng.server.AccessType; import appeng.tile.grindstone.TileGrinder; import appeng.tile.misc.TileCellWorkbench; @@ -108,6 +110,8 @@ public enum GuiBridge implements IGuiHandler GUI_SECURITY(ContainerSecurity.class, TileSecurity.class, false, SecurityPermissions.SECURITY), + GUI_CRAFTING_TERMINAL(ContainerCraftingTerm.class, PartCraftingTerminal.class, false, SecurityPermissions.CRAFT), + // extends (Container/Gui) + Bus GUI_LEVELEMITTER(ContainerLevelEmitter.class, PartLevelEmitter.class, false, SecurityPermissions.BUILD), diff --git a/integration/modules/FMP.java b/integration/modules/FMP.java index 8b94a604..8b0aba34 100644 --- a/integration/modules/FMP.java +++ b/integration/modules/FMP.java @@ -65,16 +65,14 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF @Override public void Init() throws Throwable { - + BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartz.block() ); + BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzPiller.block() ); + BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block() ); } @Override public void PostInit() throws Throwable { - BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartz.block() ); - BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzPiller.block() ); - BlockMicroMaterial.createAndRegister( AEApi.instance().blocks().blockQuartzChiseled.block() ); - PartRegistry reg[] = PartRegistry.values(); String data[] = new String[reg.length]; diff --git a/integration/modules/TE.java b/integration/modules/TE.java index daa35d3b..9f3bdd66 100644 --- a/integration/modules/TE.java +++ b/integration/modules/TE.java @@ -2,12 +2,14 @@ package appeng.integration.modules; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import appeng.api.AEApi; import appeng.integration.IIntegrationModule; import appeng.integration.abstraction.ITE; import cofh.api.transport.IItemConduit; +import cpw.mods.fml.common.event.FMLInterModComms; public class TE implements IIntegrationModule, ITE { @@ -38,7 +40,14 @@ public class TE implements IIntegrationModule, ITE private void pulverizer(ItemStack in, ItemStack out) { - thermalexpansion.api.crafting.CraftingManagers.pulverizerManager.addRecipe( 320, in, out ); + NBTTagCompound toSend = new NBTTagCompound(); + toSend.setInteger( "energy", 3200 ); + toSend.setCompoundTag( "input", new NBTTagCompound() ); + toSend.setCompoundTag( "primaryOutput", new NBTTagCompound() ); + + in.writeToNBT( toSend.getCompoundTag( "input" ) ); + out.writeToNBT( toSend.getCompoundTag( "primaryOutput" ) ); + FMLInterModComms.sendMessage( "ThermalExpansion", "PulverizerRecipe", toSend ); } @Override diff --git a/parts/automation/PartUpgradeable.java b/parts/automation/PartUpgradeable.java index 2a6e23e6..d7e38e8b 100644 --- a/parts/automation/PartUpgradeable.java +++ b/parts/automation/PartUpgradeable.java @@ -1,5 +1,7 @@ package appeng.parts.automation; +import java.util.List; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import appeng.api.config.RedstoneMode; @@ -29,6 +31,14 @@ public class PartUpgradeable extends PartBasicState implements ISegmentedInvento return 4; } + @Override + public void getDrops(List drops, boolean wrenched) + { + for (ItemStack is : upgrades) + if ( is != null ) + drops.add( is ); + } + public void writeToNBT(net.minecraft.nbt.NBTTagCompound extra) { super.writeToNBT( extra ); diff --git a/parts/reporting/PartCraftingTerminal.java b/parts/reporting/PartCraftingTerminal.java index e4af3e00..97987dc0 100644 --- a/parts/reporting/PartCraftingTerminal.java +++ b/parts/reporting/PartCraftingTerminal.java @@ -1,11 +1,28 @@ package appeng.parts.reporting; +import java.util.List; + +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import appeng.client.texture.CableBusTextures; +import appeng.core.sync.GuiBridge; +import appeng.tile.inventory.AppEngInternalInventory; +import appeng.tile.inventory.IAEAppEngInventory; +import appeng.tile.inventory.InvOperation; -public class PartCraftingTerminal extends PartMonitor +public class PartCraftingTerminal extends PartTerminal implements IAEAppEngInventory { + AppEngInternalInventory craftingGrid = new AppEngInternalInventory( this, 9 ); + + @Override + public void getDrops(List drops, boolean wrenched) + { + for (ItemStack is : craftingGrid) + if ( is != null ) + drops.add( is ); + } + public PartCraftingTerminal(ItemStack is) { super( PartCraftingTerminal.class, is ); frontBright = CableBusTextures.PartCraftingTerm_Bright; @@ -14,4 +31,15 @@ public class PartCraftingTerminal extends PartMonitor frontSolid = CableBusTextures.PartCraftingTerm_Solid; } + public GuiBridge getGui() + { + return GuiBridge.GUI_CRAFTING_TERMINAL; + } + + @Override + public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) + { + // :) + } + } diff --git a/parts/reporting/PartTerminal.java b/parts/reporting/PartTerminal.java index 8ffadb50..64ae7259 100644 --- a/parts/reporting/PartTerminal.java +++ b/parts/reporting/PartTerminal.java @@ -14,6 +14,10 @@ import appeng.util.Platform; public class PartTerminal extends PartMonitor implements IStorageMonitorable { + public PartTerminal(Class clz, ItemStack is) { + super( clz, is ); + } + public PartTerminal(ItemStack is) { super( PartTerminal.class, is ); frontBright = CableBusTextures.PartTerminal_Bright; @@ -22,6 +26,11 @@ public class PartTerminal extends PartMonitor implements IStorageMonitorable frontSolid = CableBusTextures.PartTerminal_Solid; } + public GuiBridge getGui() + { + return GuiBridge.GUI_ME; + } + @Override public boolean onActivate(EntityPlayer player, Vec3 pos) { @@ -31,7 +40,7 @@ public class PartTerminal extends PartMonitor implements IStorageMonitorable return true; if ( proxy.isActive() ) - Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_ME ); + Platform.openGUI( player, getHost().getTile(), side, getGui() ); else { if ( proxy.isPowered() )