From c99964dad68f5ccb6d1f40f89baa1881105ba421 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 00:20:12 -0500 Subject: [PATCH 01/18] Finished Crafting CPU Gui. --- .../gui/implementations/GuiCraftingCPU.java | 158 ++++++++++++++---- .../implementations/ContainerCraftingCPU.java | 8 + core/localization/GuiText.java | 4 +- core/sync/packets/PacketValueConfig.java | 7 + me/cache/CraftingCache.java | 12 +- .../implementations/CraftingCPUCluster.java | 28 +++- tile/crafting/TileMolecularAssembler.java | 24 +-- 7 files changed, 188 insertions(+), 53 deletions(-) diff --git a/client/gui/implementations/GuiCraftingCPU.java b/client/gui/implementations/GuiCraftingCPU.java index 17c7b1772..5b78732b3 100644 --- a/client/gui/implementations/GuiCraftingCPU.java +++ b/client/gui/implementations/GuiCraftingCPU.java @@ -1,7 +1,9 @@ package appeng.client.gui.implementations; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import net.minecraft.client.gui.GuiButton; @@ -20,10 +22,15 @@ import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiScrollbar; import appeng.client.gui.widgets.ISortSource; import appeng.container.implementations.ContainerCraftingCPU; +import appeng.core.AELog; import appeng.core.localization.GuiText; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketValueConfig; import appeng.tile.crafting.TileCraftingTile; import appeng.util.Platform; +import com.google.common.base.Joiner; + public class GuiCraftingCPU extends AEBaseGui implements ISortSource { @@ -37,21 +44,38 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource public GuiCraftingCPU(InventoryPlayer inventoryPlayer, TileCraftingTile te) { super( new ContainerCraftingCPU( inventoryPlayer, te ) ); - this.ySize = 153; - this.xSize = 195; + this.ySize = 184; + this.xSize = 238; myScrollBar = new GuiScrollbar(); } + GuiButton cancel; + @Override protected void actionPerformed(GuiButton btn) { super.actionPerformed( btn ); + + if ( cancel == btn ) + { + try + { + NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) ); + } + catch (IOException e) + { + AELog.error( e ); + } + } } @Override public void initGui() { super.initGui(); + + cancel = new GuiButton( 0, this.guiLeft + 163, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + buttonList.add( cancel ); } private long getTotal(IAEItemStack is) @@ -167,13 +191,14 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource for (IAEItemStack l : visual) size++; - myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 ); - myScrollBar.setRange( 0, (size + 4) / 5 - rows, 1 ); + myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 ); + myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 ); } @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { + setScrollBar(); bindTexture( "guis/craftingcpu.png" ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); } @@ -188,17 +213,18 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource int gx = (width - xSize) / 2; int gy = (height - ySize) / 2; + int yoff = 23; tooltip = -1; for (int z = 0; z <= 4 * 5; z++) { - int minX = gx + 14 + x * 31; - int minY = gy + 41 + y * 18; + int minX = gx + 9 + x * 67; + int minY = gy + 22 + y * yoff; - if ( minX < mouse_x && minX + 28 > mouse_x ) + if ( minX < mouse_x && minX + 67 > mouse_x ) { - if ( minY < mouse_y && minY + 20 > mouse_y ) + if ( minY < mouse_y && minY + yoff - 2 > mouse_y ) { tooltip = z; break; @@ -208,7 +234,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource x++; - if ( x > 4 ) + if ( x > 2 ) { y++; x = 0; @@ -221,21 +247,24 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { - fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 7, 4210752 ); + fontRendererObj.drawString( GuiText.CraftingStatus.getLocal(), 8, 7, 4210752 ); - int sectionLength = 30; + int sectionLength = 67; int x = 0; int y = 0; - int xo = 0 + 12; - int yo = 0 + 42; - int viewStart = 0;// myScrollBar.getCurrentScroll() * 5; - int viewEnd = viewStart + 5 * 4; + int xo = 0 + 9; + int yo = 0 + 22; + int viewStart = myScrollBar.getCurrentScroll() * 3; + int viewEnd = viewStart + 3 * 6; - String ToolTip = ""; + String dspToolTip = ""; + List lineList = new LinkedList(); int toolPosX = 0; int toolPosY = 0; + int offY = 23; + for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++) { IAEItemStack refStack = visual.get( z );// repo.getRefrenceItem( z ); @@ -244,37 +273,100 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource GL11.glPushMatrix(); GL11.glScaled( 0.5, 0.5, 0.5 ); - String str = Long.toString( refStack.getStackSize() ); - if ( refStack.getStackSize() >= 10000 ) - str = Long.toString( refStack.getStackSize() / 1000 ) + "k"; + IAEItemStack stored = storage.findPrecise( refStack ); + IAEItemStack activeStack = active.findPrecise( refStack ); + IAEItemStack pendingStack = pending.findPrecise( refStack ); - int w = fontRendererObj.getStringWidth( str ); - fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2), - 4210752 ); + int lines = 0; + + if ( stored != null && stored.getStackSize() > 0 ) + lines++; + if ( activeStack != null && activeStack.getStackSize() > 0 ) + lines++; + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) + lines++; + + int negY = ((lines - 1) * 5) / 2; + int downY = 0; + + if ( stored != null && stored.getStackSize() > 0 ) + { + String str = Long.toString( stored.getStackSize() ); + if ( stored.getStackSize() >= 10000 ) + str = Long.toString( stored.getStackSize() / 1000 ) + "k"; + if ( stored.getStackSize() >= 10000000 ) + str = Long.toString( stored.getStackSize() / 1000000 ) + "m"; + + str = GuiText.Stored.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); + + downY += 5; + } + + if ( activeStack != null && activeStack.getStackSize() > 0 ) + { + String str = Long.toString( activeStack.getStackSize() ); + if ( activeStack.getStackSize() >= 10000 ) + str = Long.toString( activeStack.getStackSize() / 1000 ) + "k"; + if ( activeStack.getStackSize() >= 10000000 ) + str = Long.toString( activeStack.getStackSize() / 1000000 ) + "m"; + + str = GuiText.Crafting.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) ); + + downY += 5; + } + + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) + { + String str = Long.toString( pendingStack.getStackSize() ); + if ( pendingStack.getStackSize() >= 10000 ) + str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k"; + if ( pendingStack.getStackSize() >= 10000000 ) + str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m"; + + str = GuiText.Scheduled.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); + + } GL11.glPopMatrix(); - int posX = x * sectionLength + xo + sectionLength - 18; - int posY = y * 18 + yo; + int posX = x * (1 + sectionLength) + xo + sectionLength - 19; + int posY = y * offY + yo; ItemStack is = refStack.copy().getItemStack(); if ( tooltip == z - viewStart ) { - ToolTip = Platform.getItemDisplayName( is ); + dspToolTip = Platform.getItemDisplayName( is ); - ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize())); - if ( refStack.getCountRequestable() > 0 ) - ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true )); + if ( lineList.size() > 0 ) + dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList ); - toolPosX = x * sectionLength + xo + sectionLength - 8; - toolPosY = y * 18 + yo; + toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8; + toolPosY = y * offY + yo; } drawItem( posX, posY, is ); x++; - if ( x > 4 ) + if ( x > 2 ) { y++; x = 0; @@ -283,10 +375,10 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource } - if ( tooltip >= 0 && ToolTip.length() > 0 ) + if ( tooltip >= 0 && dspToolTip.length() > 0 ) { GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); - drawTooltip( toolPosX, toolPosY + 10, 0, ToolTip ); + drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip ); GL11.glPopAttrib(); } diff --git a/container/implementations/ContainerCraftingCPU.java b/container/implementations/ContainerCraftingCPU.java index 4a8db72bf..a0697a329 100644 --- a/container/implementations/ContainerCraftingCPU.java +++ b/container/implementations/ContainerCraftingCPU.java @@ -62,6 +62,14 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH isContainerValid = false; } + public void cancelCrafting() + { + if ( monitor != null ) + { + monitor.cancel(); + } + } + private void findNode(IGridHost host, ForgeDirection d) { if ( network == null ) diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 075463a6a..366924e9f 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -30,7 +30,9 @@ public enum GuiText StoredPower, MaxPower, RequiredPower, Efficiency, InWorldCrafting, inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether, inWorldPurificationFluix, inWorldSingularity, ChargedQuartz, - OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting; + OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting, + + Stored, Crafting, Scheduled, CraftingStatus, Cancel; String root; diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index 6ee0b386b..b58cfe693 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -17,6 +17,7 @@ import appeng.api.util.IConfigManager; import appeng.api.util.IConfigureableObject; import appeng.container.AEBaseContainer; import appeng.container.implementations.ContainerCellWorkbench; +import appeng.container.implementations.ContainerCraftingCPU; import appeng.container.implementations.ContainerLevelEmitter; import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPriority; @@ -53,6 +54,12 @@ public class PacketValueConfig extends AppEngPacket si.onWheel( is, Value.equals( "WheelUp" ) ); return; } + else if ( Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU ) + { + ContainerCraftingCPU qk = (ContainerCraftingCPU) c; + qk.cancelCrafting(); + return; + } else if ( Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife ) { ContainerQuartzKnife qk = (ContainerQuartzKnife) c; diff --git a/me/cache/CraftingCache.java b/me/cache/CraftingCache.java index 5185e042a..f1c2fc39b 100644 --- a/me/cache/CraftingCache.java +++ b/me/cache/CraftingCache.java @@ -18,6 +18,7 @@ import appeng.api.networking.crafting.ICraftingMedium; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.crafting.ICraftingProvider; import appeng.api.networking.crafting.ICraftingProviderHelper; +import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.events.MENetworkCraftingCpuChange; import appeng.api.networking.events.MENetworkCraftingPatternChange; import appeng.api.networking.events.MENetworkEventSubscribe; @@ -43,7 +44,10 @@ public class CraftingCache implements IGridCache, ICraftingProviderHelper, ICell HashSet cpuClusters = new HashSet(); HashSet providers = new HashSet(); + IGrid grid; + IStorageGrid sg; + IEnergyGrid eg; HashMap> craftingMethods = new HashMap(); HashMap> craftableItems = new HashMap(); @@ -57,7 +61,9 @@ public class CraftingCache implements IGridCache, ICraftingProviderHelper, ICell @MENetworkEventSubscribe public void afterCacheConstruction(MENetworkPostCacheConstruction cc) { - IStorageGrid sg = grid.getCache( IStorageGrid.class ); + sg = grid.getCache( IStorageGrid.class ); + eg = grid.getCache( IEnergyGrid.class ); + sg.registerCellProvider( this ); } @@ -71,7 +77,7 @@ public class CraftingCache implements IGridCache, ICraftingProviderHelper, ICell } for (CraftingCPUCluster cpu : cpuClusters) - cpu.updateCraftingLogic( grid, this ); + cpu.updateCraftingLogic( grid, eg, this ); } @MENetworkEventSubscribe @@ -138,8 +144,6 @@ public class CraftingCache implements IGridCache, ICraftingProviderHelper, ICell private void updatePatterns() { - IStorageGrid sg = grid.getCache( IStorageGrid.class ); - // update the stuff that was in the list... for (IAEItemStack out : craftableItems.keySet()) { diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index 3adf1fec7..b218613ce 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -13,12 +13,14 @@ import net.minecraft.world.WorldServer; import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; +import appeng.api.config.PowerMultiplier; import appeng.api.networking.IGrid; import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; import appeng.api.networking.crafting.CraftingItemList; import appeng.api.networking.crafting.ICraftingMedium; import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.events.MENetworkCraftingCpuChange; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.storage.IBaseMonitor; @@ -346,7 +348,14 @@ public class CraftingCPUCluster implements IAECluster, IBaseMonitor e : tasks.entrySet()) @@ -399,10 +408,22 @@ public class CraftingCPUCluster implements IAECluster, IBaseMonitor Date: Sat, 28 Jun 2014 00:20:37 -0500 Subject: [PATCH 02/18] Clicking on crafting slots with an item in your hand no longer switches guis --- client/gui/AEBaseGui.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/gui/AEBaseGui.java b/client/gui/AEBaseGui.java index 66d3391ac..4e8b3dc4a 100644 --- a/client/gui/AEBaseGui.java +++ b/client/gui/AEBaseGui.java @@ -250,7 +250,7 @@ public abstract class AEBaseGui extends GuiContainer action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN; stack = ((SlotME) slot).getAEStack(); - if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 ) + if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null ) action = InventoryAction.AUTOCRAFT; break; From d77da8c62db6f18923a8ff31699e22e19e2a0373 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 00:21:37 -0500 Subject: [PATCH 03/18] Post Cache Construction Event should fire before things access grid caches. --- me/Grid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/me/Grid.java b/me/Grid.java index dce6123a9..cb6c0d7ac 100644 --- a/me/Grid.java +++ b/me/Grid.java @@ -40,10 +40,10 @@ public class Grid implements IGrid caches.put( c, new GridCacheWrapper( myCaches.get( c ) ) ); } + postEvent( new MENetworkPostCacheConstruction() ); + TickHandler.instance.addNetwork( this ); center.setGrid( this ); - - postEvent( new MENetworkPostCacheConstruction() ); } public Set> getMachineClasses() From 9191d8d29e700ba8d6bb048bd31ca55e48ce3505 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 00:25:54 -0500 Subject: [PATCH 04/18] Split RF into RF Tiles and RF Items, should fix some crashes. --- integration/modules/RFItem.java | 27 +++++++++++++++++++ .../tools/powered/powersink/RedstoneFlux.java | 2 +- transformer/asm/ASMIntegration.java | 5 +++- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 integration/modules/RFItem.java diff --git a/integration/modules/RFItem.java b/integration/modules/RFItem.java new file mode 100644 index 000000000..2cb3a475a --- /dev/null +++ b/integration/modules/RFItem.java @@ -0,0 +1,27 @@ +package appeng.integration.modules; + +import appeng.integration.BaseModule; +import appeng.integration.IIntegrationModule; + +public class RFItem extends BaseModule implements IIntegrationModule +{ + + public static RFItem instance; + + public RFItem() { + TestClass( cofh.api.energy.IEnergyContainerItem.class ); + } + + @Override + public void Init() + { + + } + + @Override + public void PostInit() + { + + } + +} diff --git a/items/tools/powered/powersink/RedstoneFlux.java b/items/tools/powered/powersink/RedstoneFlux.java index d2f0f8430..b371c2587 100644 --- a/items/tools/powered/powersink/RedstoneFlux.java +++ b/items/tools/powered/powersink/RedstoneFlux.java @@ -5,7 +5,7 @@ import appeng.api.config.PowerUnits; import appeng.transformer.annotations.integration.Interface; import cofh.api.energy.IEnergyContainerItem; -@Interface(iface = "cofh.api.energy.IEnergyContainerItem", iname = "RF") +@Interface(iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem") public class RedstoneFlux extends IC2 implements IEnergyContainerItem { diff --git a/transformer/asm/ASMIntegration.java b/transformer/asm/ASMIntegration.java index 64215be45..d8941ab02 100644 --- a/transformer/asm/ASMIntegration.java +++ b/transformer/asm/ASMIntegration.java @@ -37,7 +37,10 @@ public class ASMIntegration implements IClassTransformer integrationModules.add( IntegrationSide.BOTH, "BuildCraft", "BuildCraft|Silicon", "BC" ); integrationModules.add( IntegrationSide.BOTH, "BuildCraft5 Power", null, "MJ5" ); integrationModules.add( IntegrationSide.BOTH, "BuildCraft6 Power", null, "MJ6" ); - integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power", null, "RF" ); + + integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power - Tiles", null, "RF" ); + integrationModules.add( IntegrationSide.BOTH, "RedstoneFlux Power - Items", null, "RFItem" ); + // integrationModules.add( IntegrationSide.BOTH, "Greg Tech", "gregtech_addon", "GT" ); // integrationModules.add( IntegrationSide.BOTH, "Universal Electricity", null, "UE" ); // integrationModules.add( IntegrationSide.BOTH, "Logistics Pipes", "LogisticsPipes|Main", "LP" ); From c8bdf1bd451a49acdef66fae6e0f5ca8afb710fa Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 15:18:36 -0500 Subject: [PATCH 05/18] Crafting Plan Screen is almost done. --- .../gui/implementations/GuiCraftConfirm.java | 313 +++++++++++++++++- .../gui/implementations/GuiCraftingCPU.java | 5 +- .../ContainerCraftConfirm.java | 67 +++- core/localization/GuiText.java | 2 +- .../sync/packets/PacketMEInventoryUpdate.java | 4 + crafting/CraftingTreeNode.java | 9 + crafting/CraftingTreeProcess.java | 14 + .../implementations/CraftingCPUCluster.java | 8 - 8 files changed, 401 insertions(+), 21 deletions(-) diff --git a/client/gui/implementations/GuiCraftConfirm.java b/client/gui/implementations/GuiCraftConfirm.java index 7cbe5492a..b9be8ddef 100644 --- a/client/gui/implementations/GuiCraftConfirm.java +++ b/client/gui/implementations/GuiCraftConfirm.java @@ -1,23 +1,64 @@ package appeng.client.gui.implementations; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; + +import appeng.api.AEApi; import appeng.api.storage.ITerminalHost; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiScrollbar; import appeng.container.implementations.ContainerCraftConfirm; import appeng.core.localization.GuiText; +import appeng.util.Platform; + +import com.google.common.base.Joiner; public class GuiCraftConfirm extends AEBaseGui { + int rows = 5; + + IItemList storage = AEApi.instance().storage().createItemList(); + IItemList pending = AEApi.instance().storage().createItemList(); + + List visual = new ArrayList(); + public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) { super( new ContainerCraftConfirm( inventoryPlayer, te ) ); + xSize = 238; + ySize = 206; + myScrollBar = new GuiScrollbar(); } + GuiButton cancel; + GuiButton start; + GuiButton selectcpu; + @Override public void initGui() { super.initGui(); + + start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + ySize - 25, 50, 20, GuiText.Start.getLocal() ); + buttonList.add( start ); + + selectcpu = new GuiButton( 0, this.guiLeft + (219 - 150) / 2, this.guiTop + ySize - 68, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + + GuiText.Automatic ); + buttonList.add( selectcpu ); + + cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + buttonList.add( cancel ); } @Override @@ -26,21 +67,287 @@ public class GuiCraftConfirm extends AEBaseGui super.actionPerformed( btn ); } + private long getTotal(IAEItemStack is) + { + IAEItemStack a = storage.findPrecise( is ); + IAEItemStack c = pending.findPrecise( is ); + + long total = 0; + + if ( a != null ) + total += a.getStackSize(); + + if ( c != null ) + total += c.getStackSize(); + + return total; + } + + public void postUpdate(List list, byte ref) + { + switch (ref) + { + case 0: + for (IAEItemStack l : list) + handleInput( storage, l ); + break; + + case 1: + for (IAEItemStack l : list) + handleInput( pending, l ); + break; + } + + for (IAEItemStack l : list) + { + long amt = getTotal( l ); + + if ( amt <= 0 ) + deleteVisualStack( l ); + else + { + IAEItemStack is = findVisualStack( l ); + is.setStackSize( amt ); + } + } + + setScrollBar(); + } + + private void handleInput(IItemList s, IAEItemStack l) + { + IAEItemStack a = s.findPrecise( l ); + + if ( l.getStackSize() <= 0 ) + { + if ( a != null ) + a.reset(); + } + else + { + if ( a == null ) + { + s.add( l.copy() ); + a = s.findPrecise( l ); + } + + if ( a != null ) + a.setStackSize( l.getStackSize() ); + } + } + + private IAEItemStack findVisualStack(IAEItemStack l) + { + Iterator i = visual.iterator(); + while (i.hasNext()) + { + IAEItemStack o = i.next(); + if ( o.equals( l ) ) + return o; + } + + IAEItemStack stack = l.copy(); + visual.add( stack ); + return stack; + } + + private void deleteVisualStack(IAEItemStack l) + { + Iterator i = visual.iterator(); + while (i.hasNext()) + { + IAEItemStack o = i.next(); + if ( o.equals( l ) ) + { + i.remove(); + return; + } + } + } + + private void setScrollBar() + { + int size = visual.size(); + + myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 ); + myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 ); + } + @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { + setScrollBar(); bindTexture( "guis/craftingreport.png" ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); } - protected String getBackground() + int tooltip = -1; + + @Override + public void drawScreen(int mouse_x, int mouse_y, float btn) { - return "guis/craftingreport.png"; + int x = 0; + int y = 0; + + int gx = (width - xSize) / 2; + int gy = (height - ySize) / 2; + int yoff = 23; + + tooltip = -1; + + for (int z = 0; z <= 4 * 5; z++) + { + int minX = gx + 9 + x * 67; + int minY = gy + 22 + y * yoff; + + if ( minX < mouse_x && minX + 67 > mouse_x ) + { + if ( minY < mouse_y && minY + yoff - 2 > mouse_y ) + { + tooltip = z; + break; + } + + } + + x++; + + if ( x > 2 ) + { + y++; + x = 0; + } + } + + super.drawScreen( mouse_x, mouse_y, btn ); } @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { - fontRendererObj.drawString( GuiText.ConfirmCrafting.getLocal(), 8, 6, 4210752 ); + ContainerCraftConfirm c = (ContainerCraftConfirm) inventorySlots; + + long BytesUsed = c.bytesUsed; + String byteUsed = NumberFormat.getInstance().format( BytesUsed ); + String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal(); + fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 ); + + String dsp = c.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + c.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + c.cpuCoProcessors) + : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2; + fontRendererObj.drawString( dsp, offset, 165, 4210752 ); + + int sectionLength = 67; + + int x = 0; + int y = 0; + int xo = 0 + 9; + int yo = 0 + 22; + int viewStart = myScrollBar.getCurrentScroll() * 3; + int viewEnd = viewStart + 3 * rows; + + String dspToolTip = ""; + List lineList = new LinkedList(); + int toolPosX = 0; + int toolPosY = 0; + + int offY = 23; + + for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++) + { + IAEItemStack refStack = visual.get( z );// repo.getRefrenceItem( z ); + if ( refStack != null ) + { + GL11.glPushMatrix(); + GL11.glScaled( 0.5, 0.5, 0.5 ); + + IAEItemStack stored = storage.findPrecise( refStack ); + IAEItemStack pendingStack = pending.findPrecise( refStack ); + + int lines = 0; + + if ( stored != null && stored.getStackSize() > 0 ) + lines++; + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) + lines++; + + int negY = ((lines - 1) * 5) / 2; + int downY = 0; + + if ( stored != null && stored.getStackSize() > 0 ) + { + String str = Long.toString( stored.getStackSize() ); + if ( stored.getStackSize() >= 10000 ) + str = Long.toString( stored.getStackSize() / 1000 ) + "k"; + if ( stored.getStackSize() >= 10000000 ) + str = Long.toString( stored.getStackSize() / 1000000 ) + "m"; + + str = GuiText.FromStorage.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); + + downY += 5; + } + + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) + { + String str = Long.toString( pendingStack.getStackSize() ); + if ( pendingStack.getStackSize() >= 10000 ) + str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k"; + if ( pendingStack.getStackSize() >= 10000000 ) + str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m"; + + str = GuiText.ToCraft.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); + + } + + GL11.glPopMatrix(); + int posX = x * (1 + sectionLength) + xo + sectionLength - 19; + int posY = y * offY + yo; + + ItemStack is = refStack.copy().getItemStack(); + + if ( tooltip == z - viewStart ) + { + dspToolTip = Platform.getItemDisplayName( is ); + + if ( lineList.size() > 0 ) + dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList ); + + toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8; + toolPosY = y * offY + yo; + } + + drawItem( posX, posY, is ); + + x++; + + if ( x > 2 ) + { + y++; + x = 0; + } + } + + } + + if ( tooltip >= 0 && dspToolTip.length() > 0 ) + { + GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); + drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip ); + GL11.glPopAttrib(); + } + } + } diff --git a/client/gui/implementations/GuiCraftingCPU.java b/client/gui/implementations/GuiCraftingCPU.java index 5b78732b3..2a918faff 100644 --- a/client/gui/implementations/GuiCraftingCPU.java +++ b/client/gui/implementations/GuiCraftingCPU.java @@ -187,9 +187,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource private void setScrollBar() { - int size = 0; - for (IAEItemStack l : visual) - size++; + int size = visual.size(); myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 ); myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 ); @@ -198,7 +196,6 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { - setScrollBar(); bindTexture( "guis/craftingcpu.png" ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); } diff --git a/container/implementations/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index 9c42ff42a..5472d00bf 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -1,23 +1,30 @@ package appeng.container.implementations; +import java.io.IOException; import java.util.concurrent.Future; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; +import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGrid; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.PlayerSource; import appeng.api.storage.ITerminalHost; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; import appeng.container.AEBaseContainer; +import appeng.container.guisync.GuiSync; import appeng.core.AELog; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.crafting.CraftingJob; import appeng.crafting.ICraftingHost; -import appeng.me.cache.CraftingCache; public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingHost { @@ -26,6 +33,15 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH public Future job; public CraftingJob result; + @GuiSync(0) + public long bytesUsed; + + @GuiSync(1) + public long cpuBytesAvail; + + @GuiSync(2) + public int cpuCoProcessors; + public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) { super( ip, te ); priHost = te; @@ -42,10 +58,51 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH result = job.get(); if ( !result.isSimulation() ) { - CraftingCache cc = getGrid().getCache( CraftingCache.class ); - cc.submitJob( result, null, getActionSrc() ); - AELog.info( "Job info is ready!" ); - this.isContainerValid = false; + try + { + PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); + PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); + + IItemList plan = AEApi.instance().storage().createItemList(); + result.tree.getPlan( plan ); + + bytesUsed = result.getByteTotal(); + + for (IAEItemStack out : plan) + { + IAEItemStack o = out.copy(); + o.reset(); + o.setStackSize( out.getStackSize() ); + + IAEItemStack p = out.copy(); + p.reset(); + p.setStackSize( out.getCountRequestable() ); + + if ( o.getStackSize() > 0 ) + a.appendItem( o ); + + if ( p.getStackSize() > 0 ) + b.appendItem( p ); + } + + for (Object g : this.crafters) + { + if ( g instanceof EntityPlayer ) + { + NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g ); + NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g ); + } + } + } + catch (IOException e) + { + // :P + } + + // CraftingCache cc = getGrid().getCache( CraftingCache.class ); + // cc.submitJob( result, null, getActionSrc() ); + // AELog.info( "Job info is ready!" ); + // this.isContainerValid = false; } } catch (Throwable e) diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 366924e9f..31874f5cc 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -32,7 +32,7 @@ public enum GuiText OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting, - Stored, Crafting, Scheduled, CraftingStatus, Cancel; + Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors; String root; diff --git a/core/sync/packets/PacketMEInventoryUpdate.java b/core/sync/packets/PacketMEInventoryUpdate.java index 07c2d2f3f..435fc3dc1 100644 --- a/core/sync/packets/PacketMEInventoryUpdate.java +++ b/core/sync/packets/PacketMEInventoryUpdate.java @@ -16,6 +16,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import appeng.api.storage.data.IAEItemStack; +import appeng.client.gui.implementations.GuiCraftConfirm; import appeng.client.gui.implementations.GuiCraftingCPU; import appeng.client.gui.implementations.GuiMEMonitorable; import appeng.client.gui.implementations.GuiNetworkStatus; @@ -89,6 +90,9 @@ public class PacketMEInventoryUpdate extends AppEngPacket { GuiScreen gs = Minecraft.getMinecraft().currentScreen; + if ( gs instanceof GuiCraftConfirm ) + ((GuiCraftConfirm) gs).postUpdate( list, ref ); + if ( gs instanceof GuiCraftingCPU ) ((GuiCraftingCPU) gs).postUpdate( list, ref ); diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index 668e48bd2..8d200e740 100644 --- a/crafting/CraftingTreeNode.java +++ b/crafting/CraftingTreeNode.java @@ -228,4 +228,13 @@ public class CraftingTreeNode for (CraftingTreeProcess pro : nodes) pro.setJob( storage, craftingCPUCluster, src ); } + + public void getPlan(IItemList plan) + { + for (IAEItemStack i : used) + plan.add( i.copy() ); + + for (CraftingTreeProcess pro : nodes) + pro.getPlan( plan ); + } } diff --git a/crafting/CraftingTreeProcess.java b/crafting/CraftingTreeProcess.java index 26b9f3d43..2b6a39f5a 100644 --- a/crafting/CraftingTreeProcess.java +++ b/crafting/CraftingTreeProcess.java @@ -13,6 +13,7 @@ import appeng.api.config.Actionable; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.security.BaseActionSource; import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; import appeng.container.ContainerNull; import appeng.me.cache.CraftingCache; import appeng.me.cluster.implementations.CraftingCPUCluster; @@ -202,4 +203,17 @@ public class CraftingTreeProcess for (CraftingTreeNode pro : nodes.keySet()) pro.setJob( storage, craftingCPUCluster, src ); } + + public void getPlan(IItemList plan) + { + for (IAEItemStack i : details.getOutputs()) + { + i = i.copy(); + i.setCountRequestable( i.getStackSize() * crafts ); + plan.addRequestable( i ); + } + + for (CraftingTreeNode pro : nodes.keySet()) + pro.getPlan( plan ); + } } diff --git a/me/cluster/implementations/CraftingCPUCluster.java b/me/cluster/implementations/CraftingCPUCluster.java index b218613ce..56475fde6 100644 --- a/me/cluster/implementations/CraftingCPUCluster.java +++ b/me/cluster/implementations/CraftingCPUCluster.java @@ -301,14 +301,6 @@ public class CraftingCPUCluster implements IAECluster, IBaseMonitor tp : tasks.entrySet()) - o += tp.getValue().value * tp.getKey().getCondencedOutputs()[0].getStackSize(); - return o; - } - private boolean canCraft(ICraftingPatternDetails details, IAEItemStack[] condencedInputs) { for (IAEItemStack g : condencedInputs) From 1cbda9e7aeb35e18dd7c8fdcad93afe3396b08d9 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 17:32:20 -0500 Subject: [PATCH 06/18] 1.7.10 deprecations. --- block/AEBaseBlock.java | 2 +- block/networking/BlockCableBus.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index b271f772f..7a2b60363 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -669,7 +669,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature } } - if ( id.removedByPlayer( w, player, x, y, z ) ) + if ( id.removedByPlayer( w, player, x, y, z, false ) ) { List l = new ArrayList(); for (ItemStack iss : drops) diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index f79002efc..36b6db2d3 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -271,6 +271,7 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection return cb( world, x, y, z ).isEmpty(); } + @SuppressWarnings("deprecation") @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { From 6718fae629fb6b933ef54699524c562664409f61 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 17:32:40 -0500 Subject: [PATCH 07/18] Initial 1.7.10 IC2 API Update. --- items/tools/powered/powersink/IC2.java | 20 +++---- parts/layers/LayerIEnergySink.java | 10 ++-- parts/layers/LayerIEnergySource.java | 17 ++++++ parts/p2p/PartP2PIC2Power.java | 76 ++++++++++++++++++-------- tile/powersink/IC2.java | 6 +- 5 files changed, 89 insertions(+), 40 deletions(-) diff --git a/items/tools/powered/powersink/IC2.java b/items/tools/powered/powersink/IC2.java index 56d675864..63b08b3b8 100644 --- a/items/tools/powered/powersink/IC2.java +++ b/items/tools/powered/powersink/IC2.java @@ -20,10 +20,10 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int charge(ItemStack is, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + public double charge(ItemStack is, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - int addedAmt = amount; - int limit = getTransferLimit( is ); + double addedAmt = amount; + double limit = getTransferLimit( is ); if ( !ignoreTransferLimit && amount > limit ) addedAmt = limit; @@ -32,25 +32,25 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externaly, boolean simulate) { return 0; } @Override - public int getCharge(ItemStack is) + public double getCharge(ItemStack is) { return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) ); } @Override - public boolean canUse(ItemStack is, int amount) + public boolean canUse(ItemStack is, double amount) { return getCharge( is ) > amount; } @Override - public boolean use(ItemStack is, int amount, EntityLivingBase entity) + public boolean use(ItemStack is, double amount, EntityLivingBase entity) { if ( canUse( is, amount ) ) { @@ -92,9 +92,9 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int getMaxCharge(ItemStack itemStack) + public double getMaxCharge(ItemStack itemStack) { - return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) ); + return PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) ); } @Override @@ -104,7 +104,7 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int getTransferLimit(ItemStack itemStack) + public double getTransferLimit(ItemStack itemStack) { return Math.max( 32, getMaxCharge( itemStack ) / 200 ); } diff --git a/parts/layers/LayerIEnergySink.java b/parts/layers/LayerIEnergySink.java index 66b8166ff..547e242c0 100644 --- a/parts/layers/LayerIEnergySink.java +++ b/parts/layers/LayerIEnergySink.java @@ -112,7 +112,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public double demandedEnergyUnits() + public double getDemandedEnergy() { if ( !isInIC2() ) return 0; @@ -125,7 +125,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink if ( part instanceof IEnergySink ) { // use lower number cause ic2 deletes power it sends that isn't recieved. - return ((IEnergySink) part).demandedEnergyUnits(); + return ((IEnergySink) part).getDemandedEnergy(); } } @@ -133,7 +133,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { if ( !isInIC2() ) return amount; @@ -143,7 +143,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink IPart part = getPart( dir ); if ( part instanceof IEnergySink ) { - return ((IEnergySink) part).injectEnergyUnits( directionFrom, amount ); + return ((IEnergySink) part).injectEnergy( directionFrom, amount, voltage ); } } @@ -151,7 +151,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public int getMaxSafeInput() + public int getSinkTier() { return Integer.MAX_VALUE; // no real options here... } diff --git a/parts/layers/LayerIEnergySource.java b/parts/layers/LayerIEnergySource.java index 2bc99d9da..f5bb48310 100644 --- a/parts/layers/LayerIEnergySource.java +++ b/parts/layers/LayerIEnergySource.java @@ -147,4 +147,21 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource } } + @Override + public int getSourceTier() + { + // this is a flawed implementation, that requires a change to the IC2 API. + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + IPart part = getPart( dir ); + if ( part instanceof IEnergySource ) + { + return ((IEnergySource) part).getSourceTier(); + } + } + + return 0; + } + } diff --git a/parts/p2p/PartP2PIC2Power.java b/parts/p2p/PartP2PIC2Power.java index ee015d424..3de80ffd9 100644 --- a/parts/p2p/PartP2PIC2Power.java +++ b/parts/p2p/PartP2PIC2Power.java @@ -37,23 +37,31 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } // two packet buffering... - double OutputPacketA; - double OutputPacketB; + double OutputEnergyA; + double OutputEnergyB; + + // two packet buffering... + double OutputVoltageA; + double OutputVoltageB; @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT( tag ); - tag.setDouble( "OutputPacket", OutputPacketA ); - tag.setDouble( "OutputPacket2", OutputPacketB ); + tag.setDouble( "OutputPacket", OutputEnergyA ); + tag.setDouble( "OutputPacket2", OutputEnergyB ); + tag.setDouble( "OutputVoltageA", OutputVoltageA ); + tag.setDouble( "OutputVoltageB", OutputVoltageB ); } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT( tag ); - OutputPacketA = tag.getDouble( "OutputPacket" ); - OutputPacketB = tag.getDouble( "OutputPacket2" ); + OutputEnergyA = tag.getDouble( "OutputPacket" ); + OutputEnergyB = tag.getDouble( "OutputPacket2" ); + OutputVoltageA = tag.getDouble( "OutputVoltageA" ); + OutputVoltageB = tag.getDouble( "OutputVoltageB" ); } @SideOnly(Side.CLIENT) @@ -79,7 +87,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } @Override - public double demandedEnergyUnits() + public double getDemandedEnergy() { if ( output ) return 0; @@ -88,7 +96,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i { for (PartP2PIC2Power t : getOutputs()) { - if ( t.OutputPacketA <= 0.0001 || t.OutputPacketB <= 0.0001 ) + if ( t.OutputEnergyA <= 0.0001 || t.OutputEnergyB <= 0.0001 ) { return 2048; } @@ -120,7 +128,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i }; @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { TunnelCollection outs; try @@ -138,14 +146,14 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i LinkedList Options = new LinkedList(); for (PartP2PIC2Power o : outs) { - if ( o.OutputPacketA <= 0.01 ) + if ( o.OutputEnergyA <= 0.01 ) Options.add( o ); } if ( Options.isEmpty() ) { for (PartP2PIC2Power o : outs) - if ( o.OutputPacketB <= 0.01 ) + if ( o.OutputEnergyB <= 0.01 ) Options.add( o ); } @@ -160,17 +168,19 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i PartP2PIC2Power x = (PartP2PIC2Power) Platform.pickRandom( Options ); - if ( x != null && x.OutputPacketA <= 0.001 ) + if ( x != null && x.OutputEnergyA <= 0.001 ) { QueueTunnelDrain( PowerUnits.EU, amount ); - x.OutputPacketA = amount; + x.OutputEnergyA = amount; + x.OutputVoltageA = voltage; return 0; } - if ( x != null && x.OutputPacketB <= 0.001 ) + if ( x != null && x.OutputEnergyB <= 0.001 ) { QueueTunnelDrain( PowerUnits.EU, amount ); - x.OutputPacketB = amount; + x.OutputEnergyB = amount; + x.OutputVoltageB = voltage; return 0; } @@ -178,28 +188,50 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } @Override - public int getMaxSafeInput() + public int getSinkTier() { - return Integer.MAX_VALUE; + return 4; } @Override public double getOfferedEnergy() { if ( output ) - return OutputPacketA; + return OutputEnergyA; return 0; } @Override public void drawEnergy(double amount) { - OutputPacketA -= amount; - if ( OutputPacketA < 0.001 ) + OutputEnergyA -= amount; + if ( OutputEnergyA < 0.001 ) { - OutputPacketA = OutputPacketB; - OutputPacketB = 0; + OutputEnergyA = OutputEnergyB; + OutputEnergyB = 0; + + OutputVoltageA = OutputVoltageB; + OutputVoltageB = 0; } } + @Override + public int getSourceTier() + { + if ( output ) + return calculateTierFromVoltage( OutputVoltageA ); + return 4; + } + + private int calculateTierFromVoltage(double outputVoltageA2) + { + for (int x = 8; x >= 0; x--) + { + double top = ic2.api.energy.EnergyNet.instance.getPowerFromTier( x ); + if ( outputVoltageA2 > top && top > 0 ) + return x + 1; + } + return 0; + } + } diff --git a/tile/powersink/IC2.java b/tile/powersink/IC2.java index fd8f9e99d..200440406 100644 --- a/tile/powersink/IC2.java +++ b/tile/powersink/IC2.java @@ -25,13 +25,13 @@ public abstract class IC2 extends MinecraftJoules6 implements IEnergySink } @Override - final public double demandedEnergyUnits() + final public double getDemandedEnergy() { return getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE ); } @Override - final public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + final public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { // just store the excess in the current block, if I return the waste, // IC2 will just disintegrate it - Oct 20th 2013 @@ -41,7 +41,7 @@ public abstract class IC2 extends MinecraftJoules6 implements IEnergySink } @Override - final public int getMaxSafeInput() + final public int getSinkTier() { return Integer.MAX_VALUE; } From b3cb822d1d1f0eeb5cd9e2c0b7a5f22cfcf5187a Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 18:02:14 -0500 Subject: [PATCH 08/18] Use IC2 Api to get tier. --- parts/p2p/PartP2PIC2Power.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/parts/p2p/PartP2PIC2Power.java b/parts/p2p/PartP2PIC2Power.java index 3de80ffd9..4610d135c 100644 --- a/parts/p2p/PartP2PIC2Power.java +++ b/parts/p2p/PartP2PIC2Power.java @@ -223,15 +223,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i return 4; } - private int calculateTierFromVoltage(double outputVoltageA2) + private int calculateTierFromVoltage(double voltage) { - for (int x = 8; x >= 0; x--) - { - double top = ic2.api.energy.EnergyNet.instance.getPowerFromTier( x ); - if ( outputVoltageA2 > top && top > 0 ) - return x + 1; - } - return 0; + return ic2.api.energy.EnergyNet.instance.getTierFromPower( voltage ); } } From 8dc2c04afd96c3f5c5a034a9dcbb3696ca387ba8 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 20:26:29 -0500 Subject: [PATCH 09/18] 1.7.10 Deprecations. --- block/AEBaseBlock.java | 2 +- block/networking/BlockCableBus.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/AEBaseBlock.java b/block/AEBaseBlock.java index b271f772f..7a2b60363 100644 --- a/block/AEBaseBlock.java +++ b/block/AEBaseBlock.java @@ -669,7 +669,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature } } - if ( id.removedByPlayer( w, player, x, y, z ) ) + if ( id.removedByPlayer( w, player, x, y, z, false ) ) { List l = new ArrayList(); for (ItemStack iss : drops) diff --git a/block/networking/BlockCableBus.java b/block/networking/BlockCableBus.java index f79002efc..36b6db2d3 100644 --- a/block/networking/BlockCableBus.java +++ b/block/networking/BlockCableBus.java @@ -271,6 +271,7 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection return cb( world, x, y, z ).isEmpty(); } + @SuppressWarnings("deprecation") @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { From 96b51155381744121b4bb2dc5aa24f8fe7cf7c5e Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 20:26:43 -0500 Subject: [PATCH 10/18] IC2 Api Update. --- items/tools/powered/powersink/IC2.java | 20 ++++---- parts/layers/LayerIEnergySink.java | 10 ++-- parts/layers/LayerIEnergySource.java | 17 +++++++ parts/p2p/PartP2PIC2Power.java | 70 ++++++++++++++++++-------- tile/powersink/IC2.java | 6 +-- 5 files changed, 83 insertions(+), 40 deletions(-) diff --git a/items/tools/powered/powersink/IC2.java b/items/tools/powered/powersink/IC2.java index 56d675864..63b08b3b8 100644 --- a/items/tools/powered/powersink/IC2.java +++ b/items/tools/powered/powersink/IC2.java @@ -20,10 +20,10 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int charge(ItemStack is, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + public double charge(ItemStack is, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) { - int addedAmt = amount; - int limit = getTransferLimit( is ); + double addedAmt = amount; + double limit = getTransferLimit( is ); if ( !ignoreTransferLimit && amount > limit ) addedAmt = limit; @@ -32,25 +32,25 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int discharge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) + public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean externaly, boolean simulate) { return 0; } @Override - public int getCharge(ItemStack is) + public double getCharge(ItemStack is) { return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAECurrentPower( is ) ); } @Override - public boolean canUse(ItemStack is, int amount) + public boolean canUse(ItemStack is, double amount) { return getCharge( is ) > amount; } @Override - public boolean use(ItemStack is, int amount, EntityLivingBase entity) + public boolean use(ItemStack is, double amount, EntityLivingBase entity) { if ( canUse( is, amount ) ) { @@ -92,9 +92,9 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int getMaxCharge(ItemStack itemStack) + public double getMaxCharge(ItemStack itemStack) { - return (int) PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) ); + return PowerUnits.AE.convertTo( PowerUnits.EU, getAEMaxPower( itemStack ) ); } @Override @@ -104,7 +104,7 @@ public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpe } @Override - public int getTransferLimit(ItemStack itemStack) + public double getTransferLimit(ItemStack itemStack) { return Math.max( 32, getMaxCharge( itemStack ) / 200 ); } diff --git a/parts/layers/LayerIEnergySink.java b/parts/layers/LayerIEnergySink.java index 66b8166ff..547e242c0 100644 --- a/parts/layers/LayerIEnergySink.java +++ b/parts/layers/LayerIEnergySink.java @@ -112,7 +112,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public double demandedEnergyUnits() + public double getDemandedEnergy() { if ( !isInIC2() ) return 0; @@ -125,7 +125,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink if ( part instanceof IEnergySink ) { // use lower number cause ic2 deletes power it sends that isn't recieved. - return ((IEnergySink) part).demandedEnergyUnits(); + return ((IEnergySink) part).getDemandedEnergy(); } } @@ -133,7 +133,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { if ( !isInIC2() ) return amount; @@ -143,7 +143,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink IPart part = getPart( dir ); if ( part instanceof IEnergySink ) { - return ((IEnergySink) part).injectEnergyUnits( directionFrom, amount ); + return ((IEnergySink) part).injectEnergy( directionFrom, amount, voltage ); } } @@ -151,7 +151,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink } @Override - public int getMaxSafeInput() + public int getSinkTier() { return Integer.MAX_VALUE; // no real options here... } diff --git a/parts/layers/LayerIEnergySource.java b/parts/layers/LayerIEnergySource.java index 2bc99d9da..f5bb48310 100644 --- a/parts/layers/LayerIEnergySource.java +++ b/parts/layers/LayerIEnergySource.java @@ -147,4 +147,21 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource } } + @Override + public int getSourceTier() + { + // this is a flawed implementation, that requires a change to the IC2 API. + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + IPart part = getPart( dir ); + if ( part instanceof IEnergySource ) + { + return ((IEnergySource) part).getSourceTier(); + } + } + + return 0; + } + } diff --git a/parts/p2p/PartP2PIC2Power.java b/parts/p2p/PartP2PIC2Power.java index ee015d424..4610d135c 100644 --- a/parts/p2p/PartP2PIC2Power.java +++ b/parts/p2p/PartP2PIC2Power.java @@ -37,23 +37,31 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } // two packet buffering... - double OutputPacketA; - double OutputPacketB; + double OutputEnergyA; + double OutputEnergyB; + + // two packet buffering... + double OutputVoltageA; + double OutputVoltageB; @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT( tag ); - tag.setDouble( "OutputPacket", OutputPacketA ); - tag.setDouble( "OutputPacket2", OutputPacketB ); + tag.setDouble( "OutputPacket", OutputEnergyA ); + tag.setDouble( "OutputPacket2", OutputEnergyB ); + tag.setDouble( "OutputVoltageA", OutputVoltageA ); + tag.setDouble( "OutputVoltageB", OutputVoltageB ); } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT( tag ); - OutputPacketA = tag.getDouble( "OutputPacket" ); - OutputPacketB = tag.getDouble( "OutputPacket2" ); + OutputEnergyA = tag.getDouble( "OutputPacket" ); + OutputEnergyB = tag.getDouble( "OutputPacket2" ); + OutputVoltageA = tag.getDouble( "OutputVoltageA" ); + OutputVoltageB = tag.getDouble( "OutputVoltageB" ); } @SideOnly(Side.CLIENT) @@ -79,7 +87,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } @Override - public double demandedEnergyUnits() + public double getDemandedEnergy() { if ( output ) return 0; @@ -88,7 +96,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i { for (PartP2PIC2Power t : getOutputs()) { - if ( t.OutputPacketA <= 0.0001 || t.OutputPacketB <= 0.0001 ) + if ( t.OutputEnergyA <= 0.0001 || t.OutputEnergyB <= 0.0001 ) { return 2048; } @@ -120,7 +128,7 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i }; @Override - public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { TunnelCollection outs; try @@ -138,14 +146,14 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i LinkedList Options = new LinkedList(); for (PartP2PIC2Power o : outs) { - if ( o.OutputPacketA <= 0.01 ) + if ( o.OutputEnergyA <= 0.01 ) Options.add( o ); } if ( Options.isEmpty() ) { for (PartP2PIC2Power o : outs) - if ( o.OutputPacketB <= 0.01 ) + if ( o.OutputEnergyB <= 0.01 ) Options.add( o ); } @@ -160,17 +168,19 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i PartP2PIC2Power x = (PartP2PIC2Power) Platform.pickRandom( Options ); - if ( x != null && x.OutputPacketA <= 0.001 ) + if ( x != null && x.OutputEnergyA <= 0.001 ) { QueueTunnelDrain( PowerUnits.EU, amount ); - x.OutputPacketA = amount; + x.OutputEnergyA = amount; + x.OutputVoltageA = voltage; return 0; } - if ( x != null && x.OutputPacketB <= 0.001 ) + if ( x != null && x.OutputEnergyB <= 0.001 ) { QueueTunnelDrain( PowerUnits.EU, amount ); - x.OutputPacketB = amount; + x.OutputEnergyB = amount; + x.OutputVoltageB = voltage; return 0; } @@ -178,28 +188,44 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } @Override - public int getMaxSafeInput() + public int getSinkTier() { - return Integer.MAX_VALUE; + return 4; } @Override public double getOfferedEnergy() { if ( output ) - return OutputPacketA; + return OutputEnergyA; return 0; } @Override public void drawEnergy(double amount) { - OutputPacketA -= amount; - if ( OutputPacketA < 0.001 ) + OutputEnergyA -= amount; + if ( OutputEnergyA < 0.001 ) { - OutputPacketA = OutputPacketB; - OutputPacketB = 0; + OutputEnergyA = OutputEnergyB; + OutputEnergyB = 0; + + OutputVoltageA = OutputVoltageB; + OutputVoltageB = 0; } } + @Override + public int getSourceTier() + { + if ( output ) + return calculateTierFromVoltage( OutputVoltageA ); + return 4; + } + + private int calculateTierFromVoltage(double voltage) + { + return ic2.api.energy.EnergyNet.instance.getTierFromPower( voltage ); + } + } diff --git a/tile/powersink/IC2.java b/tile/powersink/IC2.java index fd8f9e99d..200440406 100644 --- a/tile/powersink/IC2.java +++ b/tile/powersink/IC2.java @@ -25,13 +25,13 @@ public abstract class IC2 extends MinecraftJoules6 implements IEnergySink } @Override - final public double demandedEnergyUnits() + final public double getDemandedEnergy() { return getExternalPowerDemand( PowerUnits.EU, Double.MAX_VALUE ); } @Override - final public double injectEnergyUnits(ForgeDirection directionFrom, double amount) + final public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { // just store the excess in the current block, if I return the waste, // IC2 will just disintegrate it - Oct 20th 2013 @@ -41,7 +41,7 @@ public abstract class IC2 extends MinecraftJoules6 implements IEnergySink } @Override - final public int getMaxSafeInput() + final public int getSinkTier() { return Integer.MAX_VALUE; } From 297c957787aa5b168a234f89af25a4d685a40e11 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 20:32:07 -0500 Subject: [PATCH 11/18] Master requires 1.7.2 --- core/AppEng.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/AppEng.java b/core/AppEng.java index 248cc5039..a0e3027c7 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -37,7 +37,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkRegistry; -@Mod(modid = AppEng.modid, name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies) +@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.2]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies) public class AppEng { @@ -111,7 +111,7 @@ public class AppEng AELog.info( "Starting ( PreInit )" ); - CreativeTab.init(); + CreativeTab.init(); if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) ) CreativeTabFacade.init(); From 5c2d66aa28a19f79017c893e2f62f57bb52159b3 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Jun 2014 20:33:32 -0500 Subject: [PATCH 12/18] 1.7.10 - requires, guess what -- 1.7.10 --- core/AppEng.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/AppEng.java b/core/AppEng.java index a0e3027c7..5da22af38 100644 --- a/core/AppEng.java +++ b/core/AppEng.java @@ -37,7 +37,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import cpw.mods.fml.common.network.NetworkRegistry; -@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.2]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies) +@Mod(modid = AppEng.modid, acceptedMinecraftVersions = "[1.7.10]", name = AppEng.name, version = AEConfig.VERSION, dependencies = AppEng.dependencies) public class AppEng { From 36f81cf0b7b952fd17dc226fc90dd80ada3731f2 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 04:06:07 -0500 Subject: [PATCH 13/18] MORE Gui work for crafting --- .../gui/implementations/GuiCraftAmount.java | 8 +- .../gui/implementations/GuiCraftConfirm.java | 124 +++++++++++++++++- .../ContainerCraftConfirm.java | 118 ++++++++++++----- core/localization/GuiText.java | 2 +- core/sync/packets/PacketCraftRequest.java | 10 +- core/sync/packets/PacketValueConfig.java | 7 + crafting/CraftingTreeNode.java | 9 +- 7 files changed, 234 insertions(+), 44 deletions(-) diff --git a/client/gui/implementations/GuiCraftAmount.java b/client/gui/implementations/GuiCraftAmount.java index 9993e9b08..d8d49262e 100644 --- a/client/gui/implementations/GuiCraftAmount.java +++ b/client/gui/implementations/GuiCraftAmount.java @@ -118,7 +118,7 @@ public class GuiCraftAmount extends AEBaseGui try { NetworkHandler.instance.sendToServer( new PacketCraftRequest( inventorySlots.getSlot( 0 ).getStack(), Integer.parseInt( this.amountToCraft - .getText() ) ) ); + .getText() ), isShiftKeyDown() ) ); } catch (Throwable e) { @@ -185,6 +185,10 @@ public class GuiCraftAmount extends AEBaseGui { if ( !this.checkHotbarKeys( key ) ) { + if ( key == 28 ) + { + actionPerformed( next ); + } if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character )) && amountToCraft.textboxKeyTyped( character, key ) ) { @@ -226,6 +230,8 @@ public class GuiCraftAmount extends AEBaseGui @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { + next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal(); + bindTexture( "guis/craftAmt.png" ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); diff --git a/client/gui/implementations/GuiCraftConfirm.java b/client/gui/implementations/GuiCraftConfirm.java index b9be8ddef..9c03b2bd0 100644 --- a/client/gui/implementations/GuiCraftConfirm.java +++ b/client/gui/implementations/GuiCraftConfirm.java @@ -1,5 +1,6 @@ package appeng.client.gui.implementations; +import java.io.IOException; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Iterator; @@ -19,7 +20,16 @@ import appeng.api.storage.data.IItemList; import appeng.client.gui.AEBaseGui; import appeng.client.gui.widgets.GuiScrollbar; import appeng.container.implementations.ContainerCraftConfirm; +import appeng.core.AELog; import appeng.core.localization.GuiText; +import appeng.core.sync.GuiBridge; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketSwitchGuis; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.helpers.WirelessTerminalGuiObject; +import appeng.parts.reporting.PartCraftingTerminal; +import appeng.parts.reporting.PartPatternTerminal; +import appeng.parts.reporting.PartTerminal; import appeng.util.Platform; import com.google.common.base.Joiner; @@ -31,14 +41,40 @@ public class GuiCraftConfirm extends AEBaseGui IItemList storage = AEApi.instance().storage().createItemList(); IItemList pending = AEApi.instance().storage().createItemList(); + IItemList missing = AEApi.instance().storage().createItemList(); List visual = new ArrayList(); + GuiBridge OriginalGui; + + boolean isAutoStart() + { + return ((ContainerCraftConfirm) inventorySlots).autoStart; + } + + boolean isSimulation() + { + return ((ContainerCraftConfirm) inventorySlots).simulation; + } + public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) { super( new ContainerCraftConfirm( inventoryPlayer, te ) ); xSize = 238; ySize = 206; myScrollBar = new GuiScrollbar(); + + if ( te instanceof WirelessTerminalGuiObject ) + OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + + if ( te instanceof PartTerminal ) + OriginalGui = GuiBridge.GUI_ME; + + if ( te instanceof PartCraftingTerminal ) + OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + + if ( te instanceof PartPatternTerminal ) + OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + } GuiButton cancel; @@ -51,13 +87,17 @@ public class GuiCraftConfirm extends AEBaseGui super.initGui(); start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + ySize - 25, 50, 20, GuiText.Start.getLocal() ); + start.enabled = false; buttonList.add( start ); selectcpu = new GuiButton( 0, this.guiLeft + (219 - 150) / 2, this.guiTop + ySize - 68, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic ); + selectcpu.enabled = false; buttonList.add( selectcpu ); - cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + if ( OriginalGui != null ) + cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + buttonList.add( cancel ); } @@ -65,12 +105,38 @@ public class GuiCraftConfirm extends AEBaseGui protected void actionPerformed(GuiButton btn) { super.actionPerformed( btn ); + + if ( btn == cancel ) + { + try + { + NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) ); + } + catch (IOException e) + { + AELog.error( e ); + } + } + + if ( btn == start ) + { + try + { + NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) ); + } + catch (Throwable e) + { + AELog.error( e ); + } + } + } private long getTotal(IAEItemStack is) { IAEItemStack a = storage.findPrecise( is ); IAEItemStack c = pending.findPrecise( is ); + IAEItemStack m = missing.findPrecise( is ); long total = 0; @@ -80,6 +146,9 @@ public class GuiCraftConfirm extends AEBaseGui if ( c != null ) total += c.getStackSize(); + if ( m != null ) + total += m.getStackSize(); + return total; } @@ -96,6 +165,11 @@ public class GuiCraftConfirm extends AEBaseGui for (IAEItemStack l : list) handleInput( pending, l ); break; + + case 2: + for (IAEItemStack l : list) + handleInput( missing, l ); + break; } for (IAEItemStack l : list) @@ -173,6 +247,19 @@ public class GuiCraftConfirm extends AEBaseGui myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 ); } + @Override + protected void keyTyped(char character, int key) + { + if ( !this.checkHotbarKeys( key ) ) + { + if ( key == 28 ) + { + actionPerformed( start ); + } + super.keyTyped( character, key ); + } + } + @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { @@ -186,6 +273,9 @@ public class GuiCraftConfirm extends AEBaseGui @Override public void drawScreen(int mouse_x, int mouse_y, float btn) { + start.enabled = isSimulation() ? false : true; + selectcpu.enabled = isSimulation() ? false : true; + int x = 0; int y = 0; @@ -232,8 +322,14 @@ public class GuiCraftConfirm extends AEBaseGui String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal(); fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 ); - String dsp = c.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + c.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + c.cpuCoProcessors) - : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + String dsp = null; + + if ( isSimulation() ) + dsp = GuiText.Simulation.getLocal(); + else + dsp = c.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + c.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + c.cpuCoProcessors) + : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2; fontRendererObj.drawString( dsp, offset, 165, 4210752 ); @@ -263,6 +359,7 @@ public class GuiCraftConfirm extends AEBaseGui IAEItemStack stored = storage.findPrecise( refStack ); IAEItemStack pendingStack = pending.findPrecise( refStack ); + IAEItemStack missingStack = missing.findPrecise( refStack ); int lines = 0; @@ -270,6 +367,8 @@ public class GuiCraftConfirm extends AEBaseGui lines++; if ( pendingStack != null && pendingStack.getStackSize() > 0 ) lines++; + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) + lines++; int negY = ((lines - 1) * 5) / 2; int downY = 0; @@ -293,6 +392,25 @@ public class GuiCraftConfirm extends AEBaseGui downY += 5; } + if ( missingStack != null && missingStack.getStackSize() > 0 ) + { + String str = Long.toString( missingStack.getStackSize() ); + if ( missingStack.getStackSize() >= 10000 ) + str = Long.toString( missingStack.getStackSize() / 1000 ) + "k"; + if ( missingStack.getStackSize() >= 10000000 ) + str = Long.toString( missingStack.getStackSize() / 1000000 ) + "m"; + + str = GuiText.Missing.getLocal() + ": " + str; + int w = 4 + fontRendererObj.getStringWidth( str ); + fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo + + 6 - negY + downY) * 2), 4210752 ); + + if ( tooltip == z - viewStart ) + lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) ); + + downY += 5; + } + if ( pendingStack != null && pendingStack.getStackSize() > 0 ) { String str = Long.toString( pendingStack.getStackSize() ); diff --git a/container/implementations/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index 5472d00bf..1d8c923a3 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -10,11 +10,14 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import appeng.api.AEApi; +import appeng.api.config.Actionable; import appeng.api.config.SecurityPermissions; import appeng.api.networking.IGrid; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.IActionHost; import appeng.api.networking.security.PlayerSource; +import appeng.api.networking.storage.IStorageGrid; +import appeng.api.storage.IMEInventory; import appeng.api.storage.ITerminalHost; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; @@ -25,6 +28,7 @@ import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketMEInventoryUpdate; import appeng.crafting.CraftingJob; import appeng.crafting.ICraftingHost; +import appeng.me.cache.CraftingCache; public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingHost { @@ -42,6 +46,12 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH @GuiSync(2) public int cpuCoProcessors; + @GuiSync(3) + public boolean autoStart = false; + + @GuiSync(4) + public boolean simulation = true; + public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) { super( ip, te ); priHost = te; @@ -56,53 +66,83 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH try { result = job.get(); + if ( !result.isSimulation() ) { - try + simulation = false; + if ( autoStart ) { - PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); - PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); + startJob(); + return; + } + } + else + simulation = true; - IItemList plan = AEApi.instance().storage().createItemList(); - result.tree.getPlan( plan ); + try + { + PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); + PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); + PacketMEInventoryUpdate c = result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null; - bytesUsed = result.getByteTotal(); + IItemList plan = AEApi.instance().storage().createItemList(); + result.tree.getPlan( plan ); - for (IAEItemStack out : plan) + bytesUsed = result.getByteTotal(); + + for (IAEItemStack out : plan) + { + IAEItemStack m = null; + + IAEItemStack o = out.copy(); + o.reset(); + o.setStackSize( out.getStackSize() ); + + IAEItemStack p = out.copy(); + p.reset(); + p.setStackSize( out.getCountRequestable() ); + + IStorageGrid sg = getGrid().getCache( IStorageGrid.class ); + IMEInventory itemsg = sg.getItemInventory(); + + if ( c != null && result.isSimulation() ) { - IAEItemStack o = out.copy(); - o.reset(); - o.setStackSize( out.getStackSize() ); + m = o.copy(); + o = itemsg.extractItems( o, Actionable.SIMULATE, mySrc ); - IAEItemStack p = out.copy(); - p.reset(); - p.setStackSize( out.getCountRequestable() ); - - if ( o.getStackSize() > 0 ) - a.appendItem( o ); - - if ( p.getStackSize() > 0 ) - b.appendItem( p ); - } - - for (Object g : this.crafters) - { - if ( g instanceof EntityPlayer ) + if ( o == null ) { - NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g ); - NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g ); + o = m.copy(); + o.setStackSize( 0 ); } + + m.setStackSize( m.getStackSize() - o.getStackSize() ); } - } - catch (IOException e) - { - // :P + + if ( o.getStackSize() > 0 ) + a.appendItem( o ); + + if ( p.getStackSize() > 0 ) + b.appendItem( p ); + + if ( c != null && m != null && m.getStackSize() > 0 ) + c.appendItem( m ); } - // CraftingCache cc = getGrid().getCache( CraftingCache.class ); - // cc.submitJob( result, null, getActionSrc() ); - // AELog.info( "Job info is ready!" ); - // this.isContainerValid = false; + for (Object g : this.crafters) + { + if ( g instanceof EntityPlayer ) + { + NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g ); + NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g ); + if ( c != null ) + NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g ); + } + } + } + catch (IOException e) + { + // :P } } catch (Throwable e) @@ -118,6 +158,16 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH verifyPermissions( SecurityPermissions.CRAFT, false ); } + public void startJob() + { + if ( result != null && simulation == false ) + { + CraftingCache cc = getGrid().getCache( CraftingCache.class ); + cc.submitJob( result, null, getActionSrc() ); + this.isContainerValid = false; + } + } + @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 31874f5cc..133d0ac8f 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -32,7 +32,7 @@ public enum GuiText OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting, - Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors; + Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing; String root; diff --git a/core/sync/packets/PacketCraftRequest.java b/core/sync/packets/PacketCraftRequest.java index 05cde9f23..fc098c34e 100644 --- a/core/sync/packets/PacketCraftRequest.java +++ b/core/sync/packets/PacketCraftRequest.java @@ -26,7 +26,6 @@ import appeng.core.sync.AppEngPacket; import appeng.core.sync.GuiBridge; import appeng.core.sync.network.INetworkInfo; import appeng.crafting.CraftingJob; -import appeng.me.cache.CraftingCache; import appeng.util.Platform; import appeng.util.item.AEItemStack; @@ -34,6 +33,7 @@ public class PacketCraftRequest extends AppEngPacket { final public IAEItemStack slotItem; + final public boolean heldShift; final public static ExecutorService craftingPool; static @@ -53,6 +53,7 @@ public class PacketCraftRequest extends AppEngPacket // automatic. public PacketCraftRequest(ByteBuf stream) throws IOException { + heldShift = stream.readBoolean(); slotItem = AEItemStack.loadItemStackFromPacket( stream ); } @@ -74,8 +75,6 @@ public class PacketCraftRequest extends AppEngPacket if ( g == null ) return; - CraftingCache cc = g.getCache( CraftingCache.class ); - try { CraftingJob cj = new CraftingJob( cca.getWorld(), cca, slotItem, Actionable.SIMULATE ); @@ -89,6 +88,7 @@ public class PacketCraftRequest extends AppEngPacket if ( player.openContainer instanceof ContainerCraftConfirm ) { ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer; + ccc.autoStart = heldShift; ccc.job = craftingPool.submit( cj, cj ); cca.detectAndSendChanges(); } @@ -103,13 +103,15 @@ public class PacketCraftRequest extends AppEngPacket } } - public PacketCraftRequest(ItemStack stack, int parseInt) throws IOException { + public PacketCraftRequest(ItemStack stack, int parseInt, boolean shift) throws IOException { this.slotItem = AEApi.instance().storage().createItemStack( stack ); this.slotItem.setStackSize( parseInt ); + this.heldShift = shift; ByteBuf data = Unpooled.buffer(); data.writeInt( getPacketID() ); + data.writeBoolean( shift ); slotItem.writeToPacket( data ); configureWrite( data ); diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index b58cfe693..c5171eeee 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -17,6 +17,7 @@ import appeng.api.util.IConfigManager; import appeng.api.util.IConfigureableObject; import appeng.container.AEBaseContainer; import appeng.container.implementations.ContainerCellWorkbench; +import appeng.container.implementations.ContainerCraftConfirm; import appeng.container.implementations.ContainerCraftingCPU; import appeng.container.implementations.ContainerLevelEmitter; import appeng.container.implementations.ContainerPatternTerm; @@ -54,6 +55,12 @@ public class PacketValueConfig extends AppEngPacket si.onWheel( is, Value.equals( "WheelUp" ) ); return; } + else if ( Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm ) + { + ContainerCraftConfirm qk = (ContainerCraftConfirm) c; + qk.startJob(); + return; + } else if ( Name.equals( "TileCrafting.Cancel" ) && c instanceof ContainerCraftingCPU ) { ContainerCraftingCPU qk = (ContainerCraftingCPU) c; diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index 8d200e740..242b3f92b 100644 --- a/crafting/CraftingTreeNode.java +++ b/crafting/CraftingTreeNode.java @@ -193,7 +193,7 @@ public class CraftingTreeNode { if ( missing > 0 ) job.addMissing( getStack( missing ) ); - missing = 0; + // missing = 0; job.addBytes( 8 + bytes ); @@ -231,6 +231,13 @@ public class CraftingTreeNode public void getPlan(IItemList plan) { + if ( missing > 0 ) + { + IAEItemStack o = what.copy(); + o.setStackSize( missing ); + plan.add( o ); + } + for (IAEItemStack i : used) plan.add( i.copy() ); From e99d675897bfc50ba5eca937d53cdad751ab3ef1 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 04:06:21 -0500 Subject: [PATCH 14/18] Fixed Priority Screens. --- container/implementations/ContainerPriority.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/container/implementations/ContainerPriority.java b/container/implementations/ContainerPriority.java index 5479060e3..ec8aa6f5f 100644 --- a/container/implementations/ContainerPriority.java +++ b/container/implementations/ContainerPriority.java @@ -34,7 +34,7 @@ public class ContainerPriority extends AEBaseContainer } @GuiSync(2) - long PriorityValue = -1; + public long PriorityValue = -1; public void setPriority(int newValue, EntityPlayer player) { @@ -45,6 +45,7 @@ public class ContainerPriority extends AEBaseContainer @Override public void detectAndSendChanges() { + super.detectAndSendChanges(); verifyPermissions( SecurityPermissions.BUILD, false ); if ( Platform.isServer() ) From 4c999e1f2b6af87d9c2a9e8e62f3e6f7fbd15261 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 12:30:38 -0500 Subject: [PATCH 15/18] Fixed Minor Compile Error. --- items/tools/powered/ToolMassCannon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/items/tools/powered/ToolMassCannon.java b/items/tools/powered/ToolMassCannon.java index fc3eac36c..960854f86 100644 --- a/items/tools/powered/ToolMassCannon.java +++ b/items/tools/powered/ToolMassCannon.java @@ -133,7 +133,7 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell double d3 = 32.0D; Vec3 vec31 = vec3.addVector( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 ); - Vec3 direction = vec3.createVectorHelper( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 ); + Vec3 direction = Vec3.createVectorHelper( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 ); float penitration = AEApi.instance().registries().matterCannon().getPenetration( ammo ); // 196.96655f; if ( penitration <= 0 ) From 2c7724266798e3ba2ff92cdf843d903c536dae9f Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 12:43:09 -0500 Subject: [PATCH 16/18] Disassemble Storages Cells regardless of where your looking. --- items/storage/ItemBasicStorageCell.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/items/storage/ItemBasicStorageCell.java b/items/storage/ItemBasicStorageCell.java index ca54beecc..2268fbc7a 100644 --- a/items/storage/ItemBasicStorageCell.java +++ b/items/storage/ItemBasicStorageCell.java @@ -178,8 +178,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II return true; } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + private boolean dissassembleDrive(ItemStack stack, World world, EntityPlayer player) { if ( player.isSneaking() ) { @@ -213,4 +212,17 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II } return false; } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + { + dissassembleDrive( stack, world, player ); + return stack; + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + return dissassembleDrive( stack, world, player ); + } } From a5a92af74a41f68bc433e18b7a35b573e292a25c Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 21:03:00 -0500 Subject: [PATCH 17/18] Fixes for formation plane, also enabled fireworks to be shot using it. --- parts/automation/PartFormationPlane.java | 49 +++++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index c20998803..a3a511aaf 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -390,6 +391,16 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine EntityPlayer player = Platform.getPlayer( (WorldServer) w ); Platform.configurePlayer( player, side, tile ); + if ( i instanceof ItemFirework ) + { + Chunk c = w.getChunkFromBlockCoords( x, z ); + int sum = 0; + for (List Z : c.entityLists) + sum += Z.size(); + if ( sum > 32 ) + return input; + } + maxStorage = is.stackSize; worked = true; if ( type == Actionable.MODULATE ) @@ -435,21 +446,39 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine { if ( type == Actionable.MODULATE ) { + is.stackSize = (int) maxStorage; - if ( type == Actionable.MODULATE ) + EntityItem ei = new EntityItem( w, // w + ((side.offsetX != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetX * -0.3 + (double) x, // spawn + ((side.offsetY != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetY * -0.3 + (double) y, // spawn + ((side.offsetZ != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetZ * -0.3 + (double) z, // spawn + is.copy() ); + + Entity result = ei; + + ei.motionX = side.offsetX * 0.2; + ei.motionY = side.offsetY * 0.2; + ei.motionZ = side.offsetZ * 0.2; + + if ( is.getItem().hasCustomEntity( is ) ) { - EntityItem ei = new EntityItem( w, // w - ((side.offsetX != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetX * -0.3 + (double) x, // spawn - ((side.offsetY != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetY * -0.3 + (double) y, // spawn - ((side.offsetZ != 0 ? 0.0 : 0.7) * (Platform.getRandomFloat() - 0.5f)) + 0.5 + side.offsetZ * -0.3 + (double) z, // spawn - is.copy() ); - ei.motionX = side.offsetX * 0.2; - ei.motionY = side.offsetY * 0.2; - ei.motionZ = side.offsetZ * 0.2; - w.spawnEntityInWorld( ei ); + result = is.getItem().createEntity( w, ei, is ); + if ( result != null ) + ei.setDead(); + else + result = ei; } + + if ( !w.spawnEntityInWorld( result ) ) + { + result.setDead(); + worked = false; + } + } } + else + worked = false; } } From c74c18f81bfd834296ff10a0bb3776ccfdce3197 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 29 Jun 2014 21:48:27 -0500 Subject: [PATCH 18/18] missing import. --- parts/automation/PartFormationPlane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/parts/automation/PartFormationPlane.java b/parts/automation/PartFormationPlane.java index a3a511aaf..e875e5d65 100644 --- a/parts/automation/PartFormationPlane.java +++ b/parts/automation/PartFormationPlane.java @@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemFirework; import net.minecraft.item.ItemSkull; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound;