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 0bf52e3e1..b501a15e6 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) { 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; 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 7cbe5492a..9c03b2bd0 100644 --- a/client/gui/implementations/GuiCraftConfirm.java +++ b/client/gui/implementations/GuiCraftConfirm.java @@ -1,46 +1,471 @@ package appeng.client.gui.implementations; +import java.io.IOException; +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.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; public class GuiCraftConfirm extends AEBaseGui { + int rows = 5; + + 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; + 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() ); + 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 ); + + if ( OriginalGui != null ) + cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + + buttonList.add( cancel ); } @Override 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; + + if ( a != null ) + total += a.getStackSize(); + + if ( c != null ) + total += c.getStackSize(); + + if ( m != null ) + total += m.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; + + case 2: + for (IAEItemStack l : list) + handleInput( missing, 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 + 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) { + 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"; + start.enabled = isSimulation() ? false : true; + selectcpu.enabled = isSimulation() ? false : true; + + 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 = 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 ); + + 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 ); + IAEItemStack missingStack = missing.findPrecise( refStack ); + + int lines = 0; + + if ( stored != null && stored.getStackSize() > 0 ) + lines++; + if ( pendingStack != null && pendingStack.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 ( 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() ); + 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 17c7b1772..2a918faff 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) @@ -163,12 +187,10 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource private void setScrollBar() { - int size = 0; - for (IAEItemStack l : visual) - size++; + int size = 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 @@ -188,17 +210,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 +231,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource x++; - if ( x > 4 ) + if ( x > 2 ) { y++; x = 0; @@ -221,21 +244,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 +270,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 +372,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/ContainerCraftConfirm.java b/container/implementations/ContainerCraftConfirm.java index 9c42ff42a..1d8c923a3 100644 --- a/container/implementations/ContainerCraftConfirm.java +++ b/container/implementations/ContainerCraftConfirm.java @@ -1,20 +1,31 @@ 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.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; 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; @@ -26,6 +37,21 @@ 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; + + @GuiSync(3) + public boolean autoStart = false; + + @GuiSync(4) + public boolean simulation = true; + public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) { super( ip, te ); priHost = te; @@ -40,12 +66,83 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingH try { 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; + simulation = false; + if ( autoStart ) + { + startJob(); + return; + } + } + else + simulation = true; + + try + { + PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 ); + PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 ); + PacketMEInventoryUpdate c = result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null; + + IItemList plan = AEApi.instance().storage().createItemList(); + result.tree.getPlan( 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() ) + { + m = o.copy(); + o = itemsg.extractItems( o, Actionable.SIMULATE, mySrc ); + + if ( o == null ) + { + o = m.copy(); + o.setStackSize( 0 ); + } + + m.setStackSize( m.getStackSize() - o.getStackSize() ); + } + + 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 ); + } + + 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) @@ -61,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/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/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() ) diff --git a/core/AppEng.java b/core/AppEng.java index 248cc5039..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, 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 { @@ -111,7 +111,7 @@ public class AppEng AELog.info( "Starting ( PreInit )" ); - CreativeTab.init(); + CreativeTab.init(); if ( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) ) CreativeTabFacade.init(); diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 075463a6a..133d0ac8f 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, 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/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/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index 6ee0b386b..c5171eeee 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -17,6 +17,8 @@ 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; import appeng.container.implementations.ContainerPriority; @@ -53,6 +55,18 @@ 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; + qk.cancelCrafting(); + return; + } else if ( Name.equals( "QuartzKnife.Name" ) && c instanceof ContainerQuartzKnife ) { ContainerQuartzKnife qk = (ContainerQuartzKnife) c; diff --git a/crafting/CraftingTreeNode.java b/crafting/CraftingTreeNode.java index 668e48bd2..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 ); @@ -228,4 +228,20 @@ public class CraftingTreeNode for (CraftingTreeProcess pro : nodes) pro.setJob( storage, craftingCPUCluster, src ); } + + 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() ); + + 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/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/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 ); + } } 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 ) 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/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/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() 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..56475fde6 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; @@ -299,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) @@ -346,7 +340,14 @@ public class CraftingCPUCluster implements IAECluster, IBaseMonitor e : tasks.entrySet()) @@ -399,10 +400,22 @@ public class CraftingCPUCluster implements IAECluster, IBaseMonitor 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/crafting/TileMolecularAssembler.java b/tile/crafting/TileMolecularAssembler.java index b4dcd0618..8c650d81e 100644 --- a/tile/crafting/TileMolecularAssembler.java +++ b/tile/crafting/TileMolecularAssembler.java @@ -55,12 +55,12 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn { static final int[] sides = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - static final ItemStack is = AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ); + static final ItemStack assemblerStack = AEApi.instance().blocks().blockMolecularAssembler.stack( 1 ); private InventoryCrafting craftingInv = new InventoryCrafting( new ContainerNull(), 3, 3 ); private AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 + 2 ); private IConfigManager settings = new ConfigManager( this ); - private UpgradeInventory upgrades = new UpgradeInventory( is, this, getUpgradeSlots() ); + private UpgradeInventory upgrades = new UpgradeInventory( assemblerStack, this, getUpgradeSlots() ); private ForgeDirection pushDirection = ForgeDirection.UNKNOWN; private ItemStack myPattern = null; @@ -216,8 +216,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern ) { World w = getWorldObj(); - ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - ICraftingPatternDetails ph = iep.getPatternForItem( is, w ); + ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem(); + ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w ); if ( ph != null ) { forcePlan = true; @@ -391,22 +391,22 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn switch (upgrades.getInstalledUpgrades( Upgrades.SPEED )) { case 0: - progress += userPower( TicksSinceLastCall * 10 ); + progress += userPower( TicksSinceLastCall, 10, 1.0 ); break; case 1: - progress += userPower( TicksSinceLastCall * 13 ); + progress += userPower( TicksSinceLastCall, 13, 1.3 ); break; case 2: - progress += userPower( TicksSinceLastCall * 17 ); + progress += userPower( TicksSinceLastCall, 17, 1.7 ); break; case 3: - progress += userPower( TicksSinceLastCall * 20 ); + progress += userPower( TicksSinceLastCall, 20, 2.0 ); break; case 4: - progress += userPower( TicksSinceLastCall * 25 ); + progress += userPower( TicksSinceLastCall, 25, 2.5 ); break; case 5: - progress += userPower( TicksSinceLastCall * 50 ); + progress += userPower( TicksSinceLastCall, 50, 5.0 ); break; } @@ -459,11 +459,11 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn } } - private int userPower(int i) + private int userPower(int ticksPassed, int bonusValue, double acceleratorTax) { try { - return (int) gridProxy.getEnergy().extractAEPower( i, Actionable.MODULATE, PowerMultiplier.CONFIG ); + return (int) (gridProxy.getEnergy().extractAEPower( ticksPassed * bonusValue * acceleratorTax, Actionable.MODULATE, PowerMultiplier.CONFIG ) / acceleratorTax); } catch (GridAccessException e) { 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; } 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" );