From fd6eb37369c433b777dd7dcb661a0f3dd89fb613 Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Sat, 29 Oct 2022 18:59:33 +0800 Subject: [PATCH 1/7] fluid terminal add "use substitutions" button --- dependencies.gradle | 2 +- .../gui/GuiBaseFluidPatternTerminal.java | 72 ++++++++++++------- .../gui/GuiBaseFluidPatternTerminalEx.java | 65 ++++++++++------- .../ContainerFluidPatternTerminal.java | 1 + .../ContainerFluidPatternTerminalEx.java | 1 + .../gui/container/FCBasePartContainer.java | 41 ++++++----- .../gui/container/FCBasePartContainerEx.java | 38 +++++----- .../parts/PartFluidPatternTerminal.java | 28 +++++--- .../parts/PartFluidPatternTerminalEx.java | 33 +++++---- .../network/CPacketFluidPatternTermBtns.java | 6 ++ .../github/util/FluidPatternDetails.java | 10 +++ .../github/util/ModAndClassUtil.java | 8 +++ 12 files changed, 198 insertions(+), 107 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 8949a8fb..7328f9db 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ dependencies { compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev') - compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-116-GTNH:dev') + compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-117-GTNH:dev') compile('curse.maven:cofh-core-69162:2388751') compile('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false } compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev") diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java index d8ecad73..139fe602 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java @@ -2,6 +2,7 @@ package com.glodblock.github.client.gui; import appeng.api.config.ActionItems; import appeng.api.config.ItemSubstitution; +import appeng.api.config.PatternBeSubstitution; import appeng.api.config.Settings; import appeng.api.storage.ITerminalHost; import appeng.client.gui.widgets.GuiImgButton; @@ -37,13 +38,14 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { private GuiImgButton encodeBtn; private GuiImgButton clearBtn; private GuiImgButton doubleBtn; + private GuiImgButton beSubstitutionsEnabledBtn; + private GuiImgButton beSubstitutionsDisabledBtn; private GuiFCImgButton combineEnableBtn; private GuiFCImgButton combineDisableBtn; - public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) ); + public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(inventoryPlayer, te, new FCBasePartContainer(inventoryPlayer, te)); this.container = (FCBasePartContainer) this.inventorySlots; setReservedSpace(81); } @@ -73,9 +75,12 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { { FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0" ) ); } - else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") ); + else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0")); + } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1")); + } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0")); } } @@ -103,24 +108,37 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { this.buttonList.add( this.clearBtn ); this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ); - this.buttonList.add( this.encodeBtn ); + this.buttonList.add(this.encodeBtn); int combineLeft = 74; - + int combineTop = 153; if (ModAndClassUtil.isDoubleButton) { - this.doubleBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE ); - this.doubleBtn.setHalfSize( true ); - this.buttonList.add( this.doubleBtn ); + this.doubleBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE); + this.doubleBtn.setHalfSize(true); + this.buttonList.add(this.doubleBtn); combineLeft = 84; } + if (ModAndClassUtil.isBeSubstitutionsButton) { + combineLeft = 74; + combineTop -= 11; + this.beSubstitutionsEnabledBtn = new GuiImgButton( + this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.ENABLED); + this.beSubstitutionsEnabledBtn.setHalfSize(true); + this.buttonList.add(this.beSubstitutionsEnabledBtn); - this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "FORCE_COMBINE", "DO_COMBINE" ); - this.combineEnableBtn.setHalfSize( true ); - this.buttonList.add( this.combineEnableBtn ); + this.beSubstitutionsDisabledBtn = new GuiImgButton( + this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED); + this.beSubstitutionsDisabledBtn.setHalfSize(true); + this.buttonList.add(this.beSubstitutionsDisabledBtn); - this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + combineLeft, this.guiTop + this.ySize - 153, "NOT_COMBINE", "DONT_COMBINE" ); - this.combineDisableBtn.setHalfSize( true ); - this.buttonList.add( this.combineDisableBtn ); + } + this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn.setHalfSize(true); + this.buttonList.add(this.combineEnableBtn); + + this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn.setHalfSize(true); + this.buttonList.add(this.combineDisableBtn); } @Override @@ -159,20 +177,26 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { this.combineEnableBtn.visible = true; this.combineDisableBtn.visible = false; } - else - { + else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = true; } - } - else - { + } else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = false; } + if (ModAndClassUtil.isBeSubstitutionsButton) { + if (this.container.beSubstitute) { + this.beSubstitutionsEnabledBtn.visible = true; + this.beSubstitutionsDisabledBtn.visible = false; + } else { + this.beSubstitutionsEnabledBtn.visible = false; + this.beSubstitutionsDisabledBtn.visible = true; + } + } - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 ); + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752); } @Override diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java index 2e19ae6d..3c9938cd 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java @@ -1,9 +1,6 @@ package com.glodblock.github.client.gui; -import appeng.api.config.ActionItems; -import appeng.api.config.ItemSubstitution; -import appeng.api.config.PatternSlotConfig; -import appeng.api.config.Settings; +import appeng.api.config.*; import appeng.api.storage.ITerminalHost; import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiScrollbar; @@ -36,14 +33,15 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { private GuiImgButton invertBtn; private GuiImgButton clearBtn; private GuiImgButton doubleBtn; + private GuiImgButton beSubstitutionsEnabledBtn; + private GuiImgButton beSubstitutionsDisabledBtn; private GuiFCImgButton combineEnableBtn; private GuiFCImgButton combineDisableBtn; private final GuiScrollbar processingScrollBar = new GuiScrollbar(); - public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te ) - { - super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) ); + public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) { + super(inventoryPlayer, te, new FCBasePartContainerEx(inventoryPlayer, te)); this.container = (FCBasePartContainerEx) this.inventorySlots; setReservedSpace(81); @@ -80,9 +78,12 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { { FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0" ) ); } - else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) - { - FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") ); + else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0")); + } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "1")); + } else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "0")); } } @@ -122,17 +123,27 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { if (ModAndClassUtil.isDoubleButton) { this.doubleBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE ); this.doubleBtn.setHalfSize( true ); - this.buttonList.add( this.doubleBtn ); + this.buttonList.add(this.doubleBtn); } - this.combineEnableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE" ); - this.combineEnableBtn.setHalfSize( true ); - this.buttonList.add( this.combineEnableBtn ); + this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn.setHalfSize(true); + this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE" ); - this.combineDisableBtn.setHalfSize( true ); - this.buttonList.add( this.combineDisableBtn ); + this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn.setHalfSize(true); + this.buttonList.add(this.combineDisableBtn); + if (ModAndClassUtil.isBeSubstitutionsButton) { + this.beSubstitutionsEnabledBtn = new GuiImgButton( + this.guiLeft + 87, this.guiTop + this.ySize - 133, Settings.ACTIONS, PatternBeSubstitution.ENABLED); + this.beSubstitutionsEnabledBtn.setHalfSize(true); + this.buttonList.add(this.beSubstitutionsEnabledBtn); + this.beSubstitutionsDisabledBtn = new GuiImgButton( + this.guiLeft + 87, this.guiTop + this.ySize - 133, Settings.ACTIONS, PatternBeSubstitution.DISABLED); + this.beSubstitutionsDisabledBtn.setHalfSize(true); + this.buttonList.add(this.beSubstitutionsDisabledBtn); + } processingScrollBar.setTop(this.ySize - 164); } @@ -163,19 +174,25 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { this.fluidPrioritizedDisabledBtn.visible = false; } - if ( this.container.combine ) - { + if (this.container.combine) { this.combineEnableBtn.visible = true; this.combineDisableBtn.visible = false; - } - else - { + } else { this.combineEnableBtn.visible = false; this.combineDisableBtn.visible = true; } + if (ModAndClassUtil.isBeSubstitutionsButton) { + if (this.container.beSubstitute) { + this.beSubstitutionsEnabledBtn.visible = true; + this.beSubstitutionsDisabledBtn.visible = false; + } else { + this.beSubstitutionsEnabledBtn.visible = false; + this.beSubstitutionsDisabledBtn.visible = true; + } + } - super.drawFG( offsetX, offsetY, mouseX, mouseY ); - this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752 ); + super.drawFG(offsetX, offsetY, mouseX, mouseY); + this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752); this.processingScrollBar.draw(this); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java index e385eb32..9f06b5c9 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java @@ -119,6 +119,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement FluidPatternDetails pattern = new FluidPatternDetails(patternStack); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); + pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java index bea44102..6e4ec344 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java @@ -116,6 +116,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple pattern.setCombine(this.combine ? 1:0); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); + pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java index 5dccd5b3..61ee9226 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java @@ -54,20 +54,22 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE protected final SlotPatternTerm craftSlot; protected final SlotRestrictedInput patternSlotIN; protected final SlotRestrictedInput patternSlotOUT; - @GuiSync( 97 ) + @GuiSync(97) public boolean craftingMode = true; - @GuiSync( 96 ) + @GuiSync(96) public boolean substitute = false; - @GuiSync( 95 ) + @GuiSync(95) public boolean combine = false; + @GuiSync(94) + public boolean beSubstitute = false; - public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable ) - { - super( ip, monitorable, false ); + + public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable) { + super(ip, monitorable, false); this.patternTerminal = (PartFluidPatternTerminal) monitorable; - final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" ); - final IInventory output = this.getPatternTerminal().getInventoryByName( "output" ); + final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern"); + final IInventory output = this.getPatternTerminal().getInventoryByName("output"); this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" ); @@ -238,9 +240,9 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE encodedValue.setTag( "in", tagIn ); encodedValue.setTag( "out", tagOut ); encodedValue.setBoolean( "crafting", this.isCraftingMode() ); - encodedValue.setBoolean( "substitute", this.isSubstitute() ); - - output.setTagCompound( encodedValue ); + encodedValue.setBoolean("substitute", this.isSubstitute()); + encodedValue.setBoolean("beSubstitute", this.canBeSubstitute()); + output.setTagCompound(encodedValue); } private ItemStack[] getInputs() @@ -460,6 +462,7 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE this.substitute = this.patternTerminal.isSubstitution(); this.combine = this.patternTerminal.shouldCombine(); + this.beSubstitute = this.patternTerminal.canBeSubstitute(); } } @@ -543,23 +546,23 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE return this.craftingMode; } - private void setCraftingMode( final boolean craftingMode ) - { + private void setCraftingMode(final boolean craftingMode) { this.craftingMode = craftingMode; } - public PartFluidPatternTerminal getPatternTerminal() - { + public PartFluidPatternTerminal getPatternTerminal() { return this.patternTerminal; } - private boolean isSubstitute() - { + private boolean canBeSubstitute() { + return this.beSubstitute; + } + + private boolean isSubstitute() { return this.substitute; } - public void setSubstitute( final boolean substitute ) - { + public void setSubstitute(final boolean substitute) { this.substitute = substitute; } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java index 299f0e26..1e749db7 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java @@ -63,25 +63,26 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES]; protected final SlotRestrictedInput patternSlotIN; protected final SlotRestrictedInput patternSlotOUT; - @GuiSync( 96 + (17-9) + 11 ) + @GuiSync(96 + (17 - 9) + 11) public boolean combine = false; - @GuiSync( 96 + (17-9) + 12 ) + @GuiSync(96 + (17 - 9) + 12) public boolean substitute = false; - @GuiSync( 96 + (17-9) + 16 ) + @GuiSync(96 + (17 - 9) + 16) public boolean inverted; - @GuiSync( 96 + (17-9) + 17 ) + @GuiSync(96 + (17 - 9) + 17) public int activePage = 0; - @GuiSync( 96 + (17-9) + 13 ) + @GuiSync(96 + (17 - 9) + 13) public boolean prioritize = false; + @GuiSync(96 + (17 - 9) + 14) + public boolean beSubstitute = false; - public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable ) - { - super( ip, monitorable, false ); + public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) { + super(ip, monitorable, false); this.patternTerminal = (PartFluidPatternTerminalEx) monitorable; this.inverted = patternTerminal.isInverted(); - final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" ); - final IInventory output = this.getPatternTerminal().getInventoryByName( "output" ); + final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern"); + final IInventory output = this.getPatternTerminal().getInventoryByName("output"); IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting"); for (int page = 0; page < CRAFTING_GRID_PAGES; page++) { @@ -210,9 +211,9 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp encodedValue.setTag( "in", tagIn ); encodedValue.setTag( "out", tagOut ); - encodedValue.setBoolean( "substitute", this.isSubstitute() ); - - encodedValue.setTag( "in", tagIn ); + encodedValue.setBoolean("substitute", this.isSubstitute()); + encodedValue.setBoolean("beSubstitute", this.canBeSubstitute()); + encodedValue.setTag("in", tagIn); encodedValue.setTag( "out", tagOut ); encodedValue.setBoolean( "prioritize", this.isPrioritize() ); @@ -315,6 +316,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp { this.substitute = this.patternTerminal.isSubstitution(); this.combine = this.patternTerminal.shouldCombine(); //Check out + this.beSubstitute = this.patternTerminal.canBeSubstitute(); this.prioritize = this.patternTerminal.isPrioritize(); if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) { inverted = patternTerminal.isInverted(); @@ -451,10 +453,8 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); - if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) - { - while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { + if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) { + while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { doubleStacksInternal(this.craftingSlots); doubleStacksInternal(this.outputSlots); } @@ -463,6 +463,10 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp } } + private boolean canBeSubstitute() { + return this.beSubstitute; + } + static boolean containsFluid(SlotFake[] slots) { List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count(); diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java index 031803f1..5dc65c2d 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java @@ -41,6 +41,7 @@ public class PartFluidPatternTerminal extends FCBasePart { private boolean craftingMode = true; private boolean substitute = false; private boolean combine = false; + private boolean beSubstitute = false; public PartFluidPatternTerminal(ItemStack is) { super(is, true); @@ -82,8 +83,9 @@ public class PartFluidPatternTerminal extends FCBasePart { super.readFromNBT( data ); this.setCraftingRecipe( data.getBoolean( "craftingMode" ) ); this.setSubstitution( data.getBoolean( "substitute" ) ); - this.setCombineMode( data.getBoolean("combine") ); - this.pattern.readFromNBT( data, "pattern" ); + this.setCombineMode(data.getBoolean("combine")); + this.setBeSubstitute(data.getBoolean("beSubstitute")); + this.pattern.readFromNBT(data, "pattern"); this.output.readFromNBT( data, "outputList" ); this.crafting.readFromNBT( data, "craftingGrid" ); } @@ -94,8 +96,9 @@ public class PartFluidPatternTerminal extends FCBasePart { super.writeToNBT( data ); data.setBoolean( "craftingMode", this.craftingMode ); data.setBoolean( "substitute", this.substitute ); - data.setBoolean( "combine", this.combine ); - this.pattern.writeToNBT( data, "pattern" ); + data.setBoolean("combine", this.combine); + data.setBoolean("beSubstitute", this.beSubstitute); + this.pattern.writeToNBT(data, "pattern"); this.output.writeToNBT( data, "outputList" ); this.crafting.writeToNBT( data, "craftingGrid" ); } @@ -137,6 +140,7 @@ public class PartFluidPatternTerminal extends FCBasePart { if(newStack != null){ NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); + this.setBeSubstitute(data.getBoolean("beSubstitute")); } for (int i = 0; i < this.crafting.getSizeInventory(); i++) { this.crafting.setInventorySlotContents(i, null); @@ -209,23 +213,29 @@ public class PartFluidPatternTerminal extends FCBasePart { return this.combine; } - public void setSubstitution( boolean canSubstitute ) - { + public void setSubstitution(boolean canSubstitute) { this.substitute = canSubstitute; } - public void setCombineMode(boolean shouldCombine) - { + public void setCombineMode(boolean shouldCombine) { this.combine = shouldCombine; } + public void setBeSubstitute(boolean canBeSubstitute) { + this.beSubstitute = canBeSubstitute; + } + + public boolean canBeSubstitute() { + return this.beSubstitute; + } + public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) { IInventory crafting = this.getInventoryByName("crafting"); IInventory output = this.getInventoryByName("output"); if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) { for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) { final IAEItemStack item = newCrafting[x]; - crafting.setInventorySlotContents(x, item == null ? null: item.getItemStack()); + crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack()); } for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) { final IAEItemStack item = newOutput[x]; diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java index e01a3123..8f4ccbb6 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java @@ -42,6 +42,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart { private boolean combine = false; private boolean prioritize = false; private boolean inverted = false; + private boolean beSubstitute = false; private int activePage = 0; public PartFluidPatternTerminalEx(ItemStack is) { @@ -87,9 +88,9 @@ public class PartFluidPatternTerminalEx extends FCBasePart { this.setCombineMode( data.getBoolean("combine") ); this.pattern.readFromNBT( data, "pattern" ); this.output.readFromNBT( data, "outputList" ); - this.crafting.readFromNBT( data, "craftingGrid" ); - - this.setSubstitution( data.getBoolean( "substitute" ) ); + this.crafting.readFromNBT(data, "craftingGrid"); + this.setBeSubstitute(data.getBoolean("beSubstitute")); + this.setSubstitution(data.getBoolean("substitute")); this.setPrioritization( data.getBoolean( "priorization") ); this.setInverted( data.getBoolean( "inverted" ) ); this.setActivePage( data.getInteger( "activePage" ) ); @@ -104,7 +105,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart { data.setBoolean( "combine", this.combine ); this.pattern.writeToNBT( data, "pattern" ); this.output.writeToNBT( data, "outputList" ); - this.crafting.writeToNBT( data, "craftingGrid" ); + this.crafting.writeToNBT(data, "craftingGrid"); + data.setBoolean("beSubstitute", this.beSubstitute); data.setBoolean("priorization", this.prioritize); data.setBoolean( "substitute", this.substitute ); data.setBoolean( "inverted", this.inverted ); @@ -163,7 +165,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart { if(newStack != null){ NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); - this.setPrioritization(data.getInteger("prioritize") == 1); + this.setBeSubstitute(data.getBoolean("beSubstitute")); } this.setInverted(inputsCount <= 8 && outputCount > 8); this.setActivePage(0); @@ -224,22 +226,27 @@ public class PartFluidPatternTerminalEx extends FCBasePart { this.combine = shouldCombine; } - public boolean isSubstitution() - { + public boolean isSubstitution() { return this.substitute; } - public boolean isPrioritize() - { + public boolean isPrioritize() { return this.prioritize; } - public void setSubstitution( boolean canSubstitute ) - { + public void setBeSubstitute(boolean canBeSubstitute) { + this.beSubstitute = canBeSubstitute; + } + + public boolean canBeSubstitute() { + return this.beSubstitute; + } + + public void setSubstitution(boolean canSubstitute) { this.substitute = canSubstitute; } - public void setPrioritization( boolean canPrioritize ) - { + + public void setPrioritization(boolean canPrioritize) { this.prioritize = canPrioritize; } diff --git a/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java b/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java index eb8530cf..bf90a772 100644 --- a/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java +++ b/src/main/java/com/glodblock/github/network/CPacketFluidPatternTermBtns.java @@ -95,6 +95,9 @@ public class CPacketFluidPatternTermBtns implements IMessage { case "PatternTerminal.Combine": cpt.getPatternTerminal().setCombineMode(Value.equals("1")); break; + case "PatternTerminal.beSubstitute": + cpt.getPatternTerminal().setBeSubstitute(Value.equals("1")); + break; } } else if( Name.startsWith( "PatternTerminalEx." ) && (c instanceof ContainerFluidPatternTerminalEx)) { @@ -134,6 +137,9 @@ public class CPacketFluidPatternTermBtns implements IMessage { case "PatternTerminalEx.Prioritize": cpt.getPatternTerminal().setPrioritization(Value.equals("1")); break; + case "PatternTerminalEx.beSubstitute": + cpt.getPatternTerminal().setBeSubstitute(Value.equals("1")); + break; } } else if(Name.equals( "Terminal.Cpu" ) && c instanceof ContainerFluidCraftConfirm) { final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c; diff --git a/src/main/java/com/glodblock/github/util/FluidPatternDetails.java b/src/main/java/com/glodblock/github/util/FluidPatternDetails.java index 17769ef8..11cf70ea 100644 --- a/src/main/java/com/glodblock/github/util/FluidPatternDetails.java +++ b/src/main/java/com/glodblock/github/util/FluidPatternDetails.java @@ -22,12 +22,21 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< private IAEItemStack[] inputs = null, inputsCond = null, outputs = null, outputsCond = null; private int priority = 0; private int combine = 0; + private int beSubstitute = 0; public FluidPatternDetails(ItemStack stack) { this.patternStack = stack; this.patternStackAe = Objects.requireNonNull(AEItemStack.create(stack)); // s2g } + public boolean canBeSubstitute() { + return beSubstitute != 0; + } + + public void setCanBeSubstitute(int beSubstitute) { + this.beSubstitute = beSubstitute; + } + @Override public ItemStack getPattern() { return patternStack; @@ -150,6 +159,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable< tag.setTag("in", writeStackArray(checkInitialized(inputs))); tag.setTag("out", writeStackArray(checkInitialized(outputs))); tag.setInteger("combine", this.getCombine()); + tag.setBoolean("beSubstitute", this.canBeSubstitute()); patternStack.setTagCompound(tag); patternStackAe = Objects.requireNonNull(AEItemStack.create(patternStack)); return patternStack; diff --git a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java index c9b35617..bf1a2f72 100644 --- a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java +++ b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java @@ -33,6 +33,8 @@ public final class ModAndClassUtil { public static boolean isShiftTooltip; public static boolean isBigInterface; + public static boolean isBeSubstitutionsButton; + public static Class essentiaGas; @SuppressWarnings("all") @@ -69,6 +71,12 @@ public final class ModAndClassUtil { } catch (NoSuchFieldException e) { isDoubleButton = false; } + try { + Field d = ButtonToolTips.class.getDeclaredField("BeSubstitutionsDescEnabled"); + isBeSubstitutionsButton = true; + } catch (NoSuchFieldException e) { + isBeSubstitutionsButton = false; + } try { Field d = Settings.class.getDeclaredField("SAVE_SEARCH"); From ce1ac164dc1c5b2852f6f99d004da313c4141d85 Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Thu, 3 Nov 2022 09:27:02 +0800 Subject: [PATCH 2/7] update --- dependencies.gradle | 4 +- .../github/client/gui/FCGuiTextField.java | 45 ++++ .../github/client/gui/GuiFCImgButton.java | 46 ++-- .../github/client/gui/GuiLevelMaintainer.java | 246 +++++++++++++++++ .../ContainerFluidPatternEncoder.java | 2 +- .../container/ContainerLevelMaintainer.java | 89 +++++++ .../client/textures/FCPartsTexture.java | 8 +- .../common/block/BlockLevelMaintainer.java | 55 ++++ .../common/storage/FluidCellInventory.java | 19 +- .../common/tile/TileLevelMaintainer.java | 250 ++++++++++++++++++ .../github/coremod/FCClassTransformer.java | 3 + .../github/coremod/hooker/CoreModHooks.java | 6 + .../transform/TitleIOPortTransformer.java | 55 ++++ .../github/inventory/gui/GuiType.java | 10 + .../github/loader/ChannelLoader.java | 1 + .../github/loader/ItemAndBlockHolder.java | 1 + .../network/CPacketLevelMaintainer.java | 96 +++++++ .../network/SPacketMEInventoryUpdate.java | 3 + .../com/glodblock/github/util/NameConst.java | 4 + .../resources/assets/ae2fc/lang/en_US.lang | 6 + .../resources/assets/ae2fc/lang/zh_CN.lang | 6 + .../textures/blocks/level_maintainer.png | Bin 0 -> 202 bytes .../blocks/level_maintainerActive.png | Bin 0 -> 1343 bytes .../textures/blocks/level_maintainerFront.png | Bin 0 -> 1276 bytes .../ae2fc/textures/gui/level_maintainer.png | Bin 0 -> 9349 bytes .../assets/ae2fc/textures/gui/states.png | Bin 1122 -> 1106 bytes 26 files changed, 912 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java create mode 100644 src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java create mode 100644 src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java create mode 100644 src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java create mode 100644 src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java create mode 100644 src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java create mode 100644 src/main/resources/assets/ae2fc/textures/blocks/level_maintainer.png create mode 100644 src/main/resources/assets/ae2fc/textures/blocks/level_maintainerActive.png create mode 100644 src/main/resources/assets/ae2fc/textures/blocks/level_maintainerFront.png create mode 100644 src/main/resources/assets/ae2fc/textures/gui/level_maintainer.png diff --git a/dependencies.gradle b/dependencies.gradle index 7328f9db..2e6b4529 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -4,8 +4,8 @@ dependencies { compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev') compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-117-GTNH:dev') compile('curse.maven:cofh-core-69162:2388751') - compile('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false } - compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev") + compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false } + compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev") compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.7:dev') compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.27:dev') diff --git a/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java b/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java index c8933d18..c7147969 100644 --- a/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java +++ b/src/main/java/com/glodblock/github/client/gui/FCGuiTextField.java @@ -6,12 +6,15 @@ import net.minecraft.client.gui.GuiTextField; public class FCGuiTextField extends GuiTextField { private static final int PADDING = 2; + private final FontRenderer _fontRender; private String tooltip; private final int _xPos; private final int _yPos; private final int _width; private final int _height; + private int _border; + private int _color; /** * Uses the values to instantiate a padded version of a text field. @@ -30,6 +33,48 @@ public class FCGuiTextField extends GuiTextField { this._yPos = yPos; this._width = width; this._height = height; + this._fontRender = fontRenderer; + } + + @Override + public void drawTextBox() { + super.drawTextBox(); + if (this.getBorder() > 0 && this.getVisible()) { + GuiTextField.drawRect( + this._xPos - this.getBorder(), + this._yPos - this.getBorder(), + this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(), + this._height - 2 * PADDING + this.getBorder(), + this.getColor() + ); + } + } + + public int getBorder() { + return this._border; + } + + public void setBorder(int border) { + this._border = border; + this._color = 0; + } + + public void setBorder(int border, int color) { + this._border = border; + this._color = color; + } + + public void setBorder() { + this._border = 0; + this._color = 0; + } + + public int getColor() { + return this._color; + } + + public void setColor(int color) { + this._color = color; } @Override diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java index e405c881..c5038af9 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java @@ -35,10 +35,11 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { if( appearances == null ) { appearances = new HashMap<>(); - this.registerApp( 0, "NOT_COMBINE", "DONT_COMBINE", "not_combine" ); - this.registerApp( 1, "FORCE_COMBINE", "DO_COMBINE", "combine" ); - this.registerApp( 2, "FORCE_PRIO", "DO_PRIO", "prio" ); - this.registerApp( 3, "NOT_PRIO", "DONT_PRIO", "not_prio" ); + this.registerApp(0, "NOT_COMBINE", "DONT_COMBINE", "not_combine"); + this.registerApp(1, "FORCE_COMBINE", "DO_COMBINE", "combine"); + this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio"); + this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio"); + this.registerApp(4, "SUBMIT", "SUBMIT", "submit"); } } @@ -221,35 +222,34 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") ); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - final int uv_y = (int) Math.floor( iconIndex / 3.0 ); + final int uv_y = (int) Math.floor(iconIndex / 3.0); final int uv_x = iconIndex - uv_y * 3; - this.drawTexturedModalRect( 0, 0, Math.round(32F * 16F / 3F), Math.round(32F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) ); - this.drawTexturedModalRect( 0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F) ); - this.mouseDragged( par1Minecraft, par2, par3 ); + this.drawTexturedModalRect(0, 0, Math.round(32F * 16F / 3F), Math.round(32F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F)); + this.drawTexturedModalRect(0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F)); + this.mouseDragged(par1Minecraft, par2, par3); GL11.glPopMatrix(); - } - else - { - if( this.enabled ) - { - GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); - } - else - { - GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); + } else { + GL11.glPushMatrix(); + GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F); + GL11.glScalef(0.5f / 16 * 6, 0.5f / 16 * 6, 0.5f / 16 * 6); + if (this.enabled) { + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } else { + GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f); } - par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") ); + par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png")); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - final int uv_y = (int) Math.floor( iconIndex / 3.0 ); + final int uv_y = (int) Math.floor(iconIndex / 3.0); final int uv_x = iconIndex - uv_y * 3; - this.drawTexturedModalRect( this.xPosition, this.yPosition, 32, 32, 16, 16 ); - this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 ); - this.mouseDragged( par1Minecraft, par2, par3 ); + this.drawTexturedModalRect(0, 0, Math.round(32F * 16F / 3F), Math.round(32F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F)); + this.drawTexturedModalRect(0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F)); + this.mouseDragged(par1Minecraft, par2, par3); + GL11.glPopMatrix(); } } GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java new file mode 100644 index 00000000..dc48fda2 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -0,0 +1,246 @@ +package com.glodblock.github.client.gui; + +import appeng.api.storage.data.IAEItemStack; +import appeng.client.gui.AEBaseGui; +import appeng.client.render.AppEngRenderItem; +import appeng.container.slot.SlotFake; +import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.gui.container.ContainerLevelMaintainer; +import com.glodblock.github.common.item.ItemFluidPacket; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import com.glodblock.github.inventory.gui.MouseRegionManager; +import com.glodblock.github.inventory.slot.SlotSingleItem; +import com.glodblock.github.network.CPacketLevelMaintainer; +import com.glodblock.github.util.Ae2ReflectClient; +import com.glodblock.github.util.ModAndClassUtil; +import com.glodblock.github.util.NameConst; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; + +import java.util.List; + +public class GuiLevelMaintainer extends AEBaseGui { + + private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_maintainer.png"); + private final ContainerLevelMaintainer cont; + private final Widget[] qtyInputs = new Widget[TileLevelMaintainer.REQ_COUNT]; + private final Widget[] batchInputs = new Widget[TileLevelMaintainer.REQ_COUNT]; + private final MouseRegionManager mouseRegions = new MouseRegionManager(this); + private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this); + private TileLevelMaintainer tile; + private FCGuiTextField input; + + public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) { + super(new ContainerLevelMaintainer(ipl, tile)); + this.cont = (ContainerLevelMaintainer) inventorySlots; + this.xSize = 195; + this.ySize = 214; + this.tile = tile; + } + + public void postUpdate(List list) { + for (IAEItemStack is : list) { + long size = is.getItemStack().getTagCompound().getLong("BatchSize"); + int i = is.getItemStack().getTagCompound().getInteger("Index"); + qtyInputs[i].textField.setText(String.valueOf(is.getStackSize())); + batchInputs[i].textField.setText(String.valueOf(size)); + } + } + + public void drawScreen(final int mouseX, final int mouseY, final float btn) { + super.drawScreen(mouseX, mouseY, btn); + if (ModAndClassUtil.isSearchBar) { + for (Widget i : qtyInputs) { + handleTooltip(mouseX, mouseY, i.textField.new TooltipProvider()); + } + for (Widget i : batchInputs) { + handleTooltip(mouseX, mouseY, i.textField.new TooltipProvider()); + } + } + } + + public void initGui() { + super.initGui(); + for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { + qtyInputs[i] = new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_REQUEST_SIZE), + i, 0); + this.buttonList.add(qtyInputs[i].btn()); + batchInputs[i] = new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_BATCH_SIZE), + i, 1 + ); + this.buttonList.add(batchInputs[i].btn()); + } + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(-1)); + } + + @Override + public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { + mc.getTextureManager().bindTexture(TEX_BG); + drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize); + for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { + qtyInputs[i].draw(); + batchInputs[i].draw(); + } + } + + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { + fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040); + mouseRegions.render(mouseX, mouseY); + } + + @Override + public void func_146977_a(final Slot s) { + if (drawSlot0(s)) + super.func_146977_a(s); + } + + public boolean drawSlot0(Slot slot) { + if (slot instanceof SlotFake) { + IAEItemStack stack = ((ContainerLevelMaintainer.FakeSlot) slot).getAeStack(); + super.func_146977_a(new SlotSingleItem(slot)); + if (stack == null) return true; + IAEItemStack fake = stack.copy(); + if (fake.getItemStack().getItem() instanceof ItemFluidPacket) { + if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0) + fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount); + } + stackSizeRenderer.setAeStack(fake); + stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition); + return false; + } + return true; + } + + @Override + protected void mouseClicked(final int xCoord, final int yCoord, final int btn) { + if (btn == 0) { + if (input != null) { + input.setFocused(false); + } + for (Widget i : qtyInputs) { + if (i.textField.isMouseIn(xCoord, yCoord)) { + i.textField.setFocused(true); + this.input = i.textField; + super.mouseClicked(xCoord, yCoord, btn); + return; + } + } + for (Widget i : batchInputs) { + if (i.textField.isMouseIn(xCoord, yCoord)) { + i.textField.setFocused(true); + this.input = i.textField; + super.mouseClicked(xCoord, yCoord, btn); + return; + } + } + this.input = null; + } + super.mouseClicked(xCoord, yCoord, btn); + } + + @Override + protected void keyTyped(final char character, final int key) { + if (this.input == null) { + super.keyTyped(character, key); + return; + } + if (!this.checkHotbarKeys(key)) { + if (!((character == ' ') && this.input.getText().isEmpty())) { + this.input.textboxKeyTyped(character, key); + } + super.keyTyped(character, key); + if (!this.input.getText().matches("[0-9]+")) { + this.input.setTextColor(0xFF0000); + } else { + this.input.setTextColor(0xFFFFFF); + } + if (key == Keyboard.KEY_RETURN) { + this.input.setFocused(false); + this.input = null; + } + } + } + + @Override + protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { + super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); + if (slot instanceof ContainerLevelMaintainer.FakeSlot && this.cont.getPlayerInv().getItemStack() != null) { + this.qtyInputs[slot.getSlotIndex()].textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); + } + } + + public void updateAmount(int idx, int stackSize) { + this.qtyInputs[idx].textField.setText(String.valueOf(stackSize)); + } + + private boolean sendToServer(Widget widget) { + if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) { + if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("[0-9]+") && Long.parseLong(widget.textField.getText()) <= Integer.MAX_VALUE) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); + widget.textField.setTextColor(0xFFFFFF); + return true; + } else { + widget.textField.setTextColor(0xFF0000); + return false; + } + } + return false; + } + + @Override + protected void actionPerformed(final GuiButton btn) { + super.actionPerformed(btn); + for (Widget widget : qtyInputs) { + if (widget.button == btn) { + sendToServer(widget); + return; + } + } + for (Widget widget : batchInputs) { + if (widget.button == btn) { + sendToServer(widget); + return; + } + } + } + + private class Widget { + public final int idx; + public final int action; + private FCGuiTextField textField; + private GuiFCImgButton button; + + public Widget(FCGuiTextField textField, GuiFCImgButton button, String tooltip, int idx, int action) { + this.textField = textField; + this.textField.setMessage(tooltip); + this.textField.setEnableBackgroundDrawing(false); + this.textField.setText("0"); + this.button = button; + this.idx = idx; + this.action = action; + } + + public void draw() { + this.textField.drawTextBox(); + } + + public GuiFCImgButton btn() { + return this.button; + } + + public void setTooltip(String message) { + this.textField.setMessage(message); + } + + } + +} diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java index fe2d6dcf..5fe9e0e4 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternEncoder.java @@ -168,7 +168,7 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat } } - private static class SlotFluidConvertingFake extends SlotFake implements SlotFluid { + public static class SlotFluidConvertingFake extends SlotFake implements SlotFluid { private final AeStackInventory inv; diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java new file mode 100644 index 00000000..74693780 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java @@ -0,0 +1,89 @@ +package com.glodblock.github.client.gui.container; + +import appeng.container.AEBaseContainer; +import appeng.container.slot.OptionalSlotFake; +import appeng.container.slot.SlotFakeCraftingMatrix; +import appeng.util.Platform; +import appeng.util.item.AEItemStack; +import com.glodblock.github.client.gui.GuiLevelMaintainer; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import com.glodblock.github.inventory.AeItemStackHandler; +import net.minecraft.client.Minecraft; +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.inventory.Slot; +import net.minecraft.item.ItemStack; + + +public class ContainerLevelMaintainer extends AEBaseContainer { + private final TileLevelMaintainer tile; + private final FakeSlot[] craftingSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT]; + + public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) { + super(ipl, tile); + this.tile = tile; + AeItemStackHandler crafting = new AeItemStackHandler(tile.getCraftingSlots()); + for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) { + FakeSlot slot = new FakeSlot(crafting, y, 17, 19 + y * 20); + addSlotToContainer(slot); + craftingSlots[y] = slot; + } + bindPlayerInventory(ipl, 0, 132); + } + + public TileLevelMaintainer getTile() { + return tile; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int idx) { + for (ContainerFluidPatternEncoder.SlotFluidConvertingFake slot : craftingSlots) { + if (!slot.getHasStack()) { + slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true); + if (Platform.isClient()) { + GuiLevelMaintainer gui = (GuiLevelMaintainer) Minecraft.getMinecraft().currentScreen; + gui.updateAmount(slot.getSlotIndex(), ((Slot) this.inventorySlots.get(idx)).getStack().stackSize); + } + break; + } + } + this.detectAndSendChanges(); + return null; + } + + + public void handleClientInteraction(int action, int idx, long size) { + if (action == 0) { + tile.updateQuantity(idx, size); + } else if (action == 1) { + tile.updateBatchSize(idx, size); + } + } + + @Override + public void onSlotChange(final Slot s) { + if (Platform.isServer()) { + for (final Object crafter : this.crafters) { + final ICrafting icrafting = (ICrafting) crafter; + + for (final Object g : this.inventorySlots) { + if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) { + final Slot sri = (Slot) g; + icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack()); + } + } + ((EntityPlayerMP) icrafting).isChangingQuantityOnly = false; + } + this.detectAndSendChanges(); + } + } + + public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake { + + public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) { + super(inv, idx, x, y); + } + } +} diff --git a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java index f556d0bc..db2f9d6b 100644 --- a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java +++ b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java @@ -14,18 +14,16 @@ public enum FCPartsTexture { PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"), PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"), BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), BlockInterfaceAlternate("fluid_interface_a"), - BlockInterface_Face("fluid_interface"); + BlockInterface_Face("fluid_interface"), BlockLevelMaintainer("level_maintainer"); private final String name; public net.minecraft.util.IIcon IIcon; - FCPartsTexture(final String name) - { + FCPartsTexture(final String name) { this.name = name; } - public static ResourceLocation GuiTexture(final String string) - { + public static ResourceLocation GuiTexture(final String string) { return null; } diff --git a/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java b/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java new file mode 100644 index 00000000..c853bf9d --- /dev/null +++ b/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java @@ -0,0 +1,55 @@ +package com.glodblock.github.common.block; + +import appeng.block.AEBaseItemBlock; +import com.glodblock.github.common.tabs.FluidCraftingTabs; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import com.glodblock.github.inventory.InventoryHandler; +import com.glodblock.github.inventory.gui.GuiType; +import com.glodblock.github.util.BlockPos; +import com.glodblock.github.util.NameConst; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class BlockLevelMaintainer extends FCBaseBlock { + + public BlockLevelMaintainer() { + super(Material.iron, NameConst.BLOCK_LEVEL_MAINTAINER); + setFullBlock(true); + setOpaque(true); + setTileEntity(TileLevelMaintainer.class); + } + + public BlockLevelMaintainer register() { + GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER); + GameRegistry.registerTileEntity(TileLevelMaintainer.class, NameConst.BLOCK_LEVEL_MAINTAINER); + setCreativeTab(FluidCraftingTabs.INSTANCE); + return this; + } + + @Override + public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { + if (player.isSneaking()) { + return false; + } + TileLevelMaintainer tile = getTileEntity(world, x, y, z); + if (tile != null) { + if (!world.isRemote) { + InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.LEVEL_MAINTAINER); + } + return true; + } + return false; + } + + public ItemStack stack(int size) { + return new ItemStack(this, size); + } + + public ItemStack stack() { + return new ItemStack(this, 1); + } +} diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java index 5fdc5c64..23ba5217 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -34,6 +34,7 @@ public class FluidCellInventory implements IFluidCellInventory { private short storedFluids; private IItemList cellItems; private final NBTTagCompound tagCompound; + public static final int singleByteAmount = 256 * 8; public FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException { @@ -147,8 +148,8 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public long getUsedBytes() { - long bytesForItemCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / (8 * 256); - long tmp = this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount; + long bytesForItemCount = this.getStoredFluidCount() / singleByteAmount; + long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) * singleByteAmount + bytesForItemCount; if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++; return tmp; } @@ -177,20 +178,14 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public long getRemainingFluidCount() { - final long remaining = (this.getTotalBytes() - (this.getTotalFluidTypes() * 8)) * 8 * 256 - this.getStoredFluidCount(); + final long remaining = this.getTotalBytes() * singleByteAmount - this.getStoredFluidCount(); return remaining > 0 ? remaining : 0; } @Override public int getUnusedFluidCount() { - final int div = (int) ( this.getStoredFluidCount() % 8 ); + return (int) (this.getStoredFluidCount() % singleByteAmount); - if( div == 0 ) - { - return 0; - } - - return 8 - div; } @Override @@ -349,7 +344,7 @@ public class FluidCellInventory implements IFluidCellInventory { if( l != null ) { - final long remainingItemSlots = this.getRemainingFluidCount(); + final long remainingItemSlots = this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount; if( remainingItemSlots < 0 ) { @@ -384,7 +379,7 @@ public class FluidCellInventory implements IFluidCellInventory { if( this.canHoldNewFluid() ) // room for new type, and for at least one item! { - final long remainingItemCount = this.getRemainingFluidCount() - this.getBytesPerType() * 8; + final long remainingItemCount = this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount); if( remainingItemCount > 0 ) { diff --git a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java new file mode 100644 index 00000000..b0f0c426 --- /dev/null +++ b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java @@ -0,0 +1,250 @@ +package com.glodblock.github.common.tile; + +import appeng.api.config.Actionable; +import appeng.api.networking.GridFlags; +import appeng.api.networking.IGrid; +import appeng.api.networking.IGridNode; +import appeng.api.networking.crafting.ICraftingGrid; +import appeng.api.networking.crafting.ICraftingJob; +import appeng.api.networking.crafting.ICraftingLink; +import appeng.api.networking.crafting.ICraftingRequester; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.networking.security.MachineSource; +import appeng.api.networking.storage.IStackWatcher; +import appeng.api.networking.storage.IStackWatcherHost; +import appeng.api.networking.ticking.IGridTickable; +import appeng.api.networking.ticking.TickRateModulation; +import appeng.api.networking.ticking.TickingRequest; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IAEStack; +import appeng.api.storage.data.IItemList; +import appeng.helpers.MultiCraftingTracker; +import appeng.me.GridAccessException; +import appeng.tile.TileEvent; +import appeng.tile.events.TileEventType; +import appeng.tile.grid.AENetworkTile; +import appeng.tile.inventory.IAEAppEngInventory; +import appeng.tile.inventory.InvOperation; +import com.glodblock.github.inventory.AeStackInventory; +import com.glodblock.github.inventory.AeStackInventoryImpl; +import com.google.common.collect.ImmutableSet; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.concurrent.Future; + +public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IStackWatcherHost, IGridTickable, ICraftingRequester { + + public static final int REQ_COUNT = 5; + public final InventoryRequest requests = new InventoryRequest(this); + private final BaseActionSource source; + private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, REQ_COUNT); + + + public TileLevelMaintainer() { + getProxy().setIdlePowerUsage(1D); + getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); + this.source = new MachineSource(this); + } + + public AeStackInventory getCraftingSlots() { + return requests.getCraftingSlots(); + } + + @Override + public ImmutableSet getRequestedJobs() { + return this.craftingTracker.getRequestedJobs(); + } + + @Override + public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) { + return null; + } + + @Override + public void jobStateChange(ICraftingLink link) { + this.craftingTracker.jobStateChange(link); + } + + @Override + public TickingRequest getTickingRequest(IGridNode node) { + return new TickingRequest(5, 120, false, true); + } + + @Override + public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) { + return this.canDoBusWork() ? this.doWork() : TickRateModulation.IDLE; + } + + private TickRateModulation doWork() { + if (!this.getProxy().isActive() || !this.canDoBusWork()) { + return TickRateModulation.IDLE; + } + boolean didSomething = false; + try { + ICraftingGrid cg = this.getProxy().getCrafting(); + IGrid grid = this.getProxy().getGrid(); + final IItemList inv = this.getProxy().getStorage().getItemInventory().getStorageList(); + for (int i = 0; i < REQ_COUNT; i++) { + IAEItemStack is = requests.getQuantity(i); + if (is != null && requests.getBatchSize(i) > 0) { + IAEItemStack craftItem = requests.getCraftItem(i); + if (inv.findPrecise(is) == null || inv.findPrecise(is).getStackSize() >= is.getStackSize() || cg.isRequesting(craftItem)) + continue; + + // do crafting + + Future jobTask = requests.getJobs()[i]; + + if (jobTask == null) { + requests.getJobs()[i] = cg.beginCraftingJob(getWorldObj(), grid, this.source, craftItem, null); + } else if (jobTask.isDone()) { + try { + ICraftingJob job = jobTask.get(); + if (job != null) { + ICraftingLink link = cg.submitJob(job, null, null, false, this.source); + didSomething = true; + requests.jobs[i] = null; + if (link != null) { + requests.links[i] = link; + } + } + } catch (Exception ignored) { + + } + } + } + } + } catch (final GridAccessException e) { + // :P + } + return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER; + } + + @Override + public void saveChanges() { + super.saveChanges(); + } + + @Override + public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) { + try { + getProxy().getTick().alertDevice(getProxy().getNode()); + } catch (GridAccessException e) { + // NO-OP + } + } + + @Override + public void updateWatcher(IStackWatcher newWatcher) { + + } + + protected boolean canDoBusWork() { + return this.getProxy().isActive(); + } + + @Override + public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan) { + } + + public InventoryRequest getRequestInventory() { + return this.requests; + } + + public IInventory getInventory() { + return (IInventory) this.requests.getCraftingSlots(); + } + + public void updateQuantity(int idx, long size) { + this.requests.updateQuantity(idx, size); + } + + public void updateBatchSize(int idx, long size) { + this.requests.updateBatchSize(idx, size); + } + + @TileEvent(TileEventType.WORLD_NBT_WRITE) + public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { + this.requests.crafting.writeToNbt(data, "Inventory"); + this.requests.batchSize.writeToNbt(data, "BatchSize"); + return data; + } + + @TileEvent(TileEventType.WORLD_NBT_READ) + public void readFromNBTEvent(NBTTagCompound data) { + this.requests.crafting.readFromNbt(data, "Inventory"); + this.requests.batchSize.readFromNbt(data, "BatchSize"); + } + + public static class InventoryRequest { + private final AeStackInventoryImpl crafting; + private final AeStackInventoryImpl batchSize; + private Future[] jobs; + private ICraftingLink[] links; + + public InventoryRequest(TileLevelMaintainer tile) { + this.crafting = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); + this.batchSize = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); + this.jobs = new Future[REQ_COUNT]; + this.links = new ICraftingLink[REQ_COUNT]; + } + + public Future[] getJobs() { + return jobs; + } + + public ICraftingLink[] getLinks() { + return links; + } + + public AeStackInventory getBatchInputs() { + return this.batchSize; + } + + public AeStackInventory getCraftingSlots() { + return this.crafting; + } + + public void updateQuantity(int idx, long size) { + IAEItemStack is = this.crafting.getStack(idx); + if (is != null) { + is.setStackSize(size); + } + } + + public void updateBatchSize(int idx, long size) { + IAEItemStack is = this.crafting.getStack(idx); + if (is != null) { + IAEItemStack i = is.copy(); + i.setStackSize(size); + this.batchSize.setStack(idx, i); + } + } + + public IAEItemStack getQuantity(int idx) { + return this.crafting.getStack(idx); + } + + public long getBatchSize(int idx) { + IAEItemStack is = this.crafting.getStack(idx); + IAEItemStack is1 = this.batchSize.getStack(idx); + if (is != null && is1 != null && is.isSameType(is1)) { + return is1.getStackSize(); + } + return 0; + } + + public IAEItemStack getCraftItem(int idx) { + IAEItemStack is = this.crafting.getStack(idx); + if (is != null) { + IAEItemStack ias = is.copy(); + ias.setStackSize(this.getBatchSize(idx)); + return ias; + } + return null; + } + } +} diff --git a/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java b/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java index 921a754e..a742faa5 100644 --- a/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java +++ b/src/main/java/com/glodblock/github/coremod/FCClassTransformer.java @@ -32,6 +32,9 @@ public class FCClassTransformer implements IClassTransformer { case "appeng.integration.modules.NEI": tform = NEITransfermer.INSTANCE; break; + case "appeng.tile.storage.TileIOPort": + tform = TitleIOPortTransformer.INSTANCE; + break; default: return code; } diff --git a/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java b/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java index 6f7da80e..2c157c52 100644 --- a/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java +++ b/src/main/java/com/glodblock/github/coremod/hooker/CoreModHooks.java @@ -7,6 +7,7 @@ import appeng.api.networking.IGridNode; import appeng.api.networking.IMachineSet; import appeng.api.networking.storage.IStorageGrid; import appeng.api.storage.IMEInventory; +import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; import appeng.crafting.MECraftingInventory; @@ -19,6 +20,7 @@ import com.glodblock.github.client.gui.GuiFluidCraftConfirm; import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.parts.PartFluidInterface; +import com.glodblock.github.common.storage.FluidCellInventory; import com.glodblock.github.common.tile.TileFluidInterface; import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor; import com.glodblock.github.inventory.FluidConvertingInventoryCrafting; @@ -197,4 +199,8 @@ public class CoreModHooks { whatToSend.setTagCompound(Result.getTagCompound()); } } + + public static long IOPortMinSpeed(long possible, long itemsToMove, final StorageChannel chan) { + return chan == StorageChannel.FLUIDS ? Math.min(possible, itemsToMove * FluidCellInventory.singleByteAmount) : Math.min(possible, itemsToMove); + } } diff --git a/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java b/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java new file mode 100644 index 00000000..8adf6e74 --- /dev/null +++ b/src/main/java/com/glodblock/github/coremod/transform/TitleIOPortTransformer.java @@ -0,0 +1,55 @@ +package com.glodblock.github.coremod.transform; + +import com.glodblock.github.coremod.FCClassTransformer; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class TitleIOPortTransformer extends FCClassTransformer.ClassMapper { + public static final TitleIOPortTransformer INSTANCE = new TitleIOPortTransformer(); + + private TitleIOPortTransformer() { + // NO-OP + } + + @Override + protected ClassVisitor getClassMapper(ClassVisitor downstream) { + return new TitleIOPortTransformer.TransformTitleIOPort(Opcodes.ASM5, downstream); + } + + private static class TransformTitleIOPort extends ClassVisitor { + + TransformTitleIOPort(int api, ClassVisitor cv) { + super(api, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + if (name.equals("transferContents")) { + return new TitleIOPortTransformer.TransformTransferContents(api, super.visitMethod(access, name, desc, signature, exceptions)); + } + return super.visitMethod(access, name, desc, signature, exceptions); + } + } + + private static class TransformTransferContents extends MethodVisitor { + + TransformTransferContents(int api, MethodVisitor mv) { + super(api, mv); + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { + if (opcode == Opcodes.INVOKESTATIC && owner.equals("java/lang/Math") && name.equals("min")) { + super.visitVarInsn(Opcodes.ALOAD, 6); + super.visitMethodInsn(Opcodes.INVOKESTATIC, + "com/glodblock/github/coremod/hooker/CoreModHooks", + "IOPortMinSpeed", + "(JJLappeng/api/storage/StorageChannel;)J", + false); + } else { + super.visitMethodInsn(opcode, owner, name, desc, itf); + } + } + } +} diff --git a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java index 76ae169c..4d8c972d 100644 --- a/src/main/java/com/glodblock/github/inventory/gui/GuiType.java +++ b/src/main/java/com/glodblock/github/inventory/gui/GuiType.java @@ -19,7 +19,17 @@ import javax.annotation.Nullable; import java.util.List; public enum GuiType { + LEVEL_MAINTAINER(new TileGuiFactory(TileLevelMaintainer.class) { + @Override + protected Object createServerGui(EntityPlayer player, TileLevelMaintainer inv) { + return new ContainerLevelMaintainer(player.inventory, inv); + } + @Override + protected Object createClientGui(EntityPlayer player, TileLevelMaintainer inv) { + return new GuiLevelMaintainer(player.inventory, inv); + } + }), OC_PATTERN_EDITOR(new TileGuiFactory(TileOCPatternEditor.class) { @Override protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) { diff --git a/src/main/java/com/glodblock/github/loader/ChannelLoader.java b/src/main/java/com/glodblock/github/loader/ChannelLoader.java index 62304638..6fe5978a 100644 --- a/src/main/java/com/glodblock/github/loader/ChannelLoader.java +++ b/src/main/java/com/glodblock/github/loader/ChannelLoader.java @@ -22,5 +22,6 @@ public class ChannelLoader implements Runnable { FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT); FluidCraft.proxy.netHandler.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id++, Side.SERVER); FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER); + FluidCraft.proxy.netHandler.registerMessage(new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.class, id++, Side.SERVER); } } diff --git a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java index dced9a28..a627125d 100644 --- a/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java +++ b/src/main/java/com/glodblock/github/loader/ItemAndBlockHolder.java @@ -8,6 +8,7 @@ import com.glodblock.github.common.storage.CellType; public class ItemAndBlockHolder { public static BlockFluidDiscretizer DISCRETIZER = new BlockFluidDiscretizer().register(); + public static BlockLevelMaintainer LEVEL_MAINTAINER = new BlockLevelMaintainer().register(); public static BlockFluidPatternEncoder ENCODER = new BlockFluidPatternEncoder().register(); public static BlockFluidPacketDecoder DECODER = new BlockFluidPacketDecoder().register(); public static BlockFluidInterface INTERFACE = new BlockFluidInterface().register(); diff --git a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java new file mode 100644 index 00000000..a383cd9e --- /dev/null +++ b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java @@ -0,0 +1,96 @@ +package com.glodblock.github.network; + +import appeng.api.storage.data.IAEItemStack; +import appeng.util.item.AEItemStack; +import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.gui.container.ContainerLevelMaintainer; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import javax.annotation.Nullable; + +public class CPacketLevelMaintainer implements IMessage { + + private int action; + private long size; + private int slotIndex; + + public CPacketLevelMaintainer() { + } + + public CPacketLevelMaintainer(int action) { + this.action = action; + this.size = 0; + this.slotIndex = 0; + } + + public CPacketLevelMaintainer(int action, int slotIndex, long size) { + this.action = action; + this.size = size; + this.slotIndex = slotIndex; + } + + public CPacketLevelMaintainer(int action, int slotIndex, String size) { + this.action = action; + this.slotIndex = slotIndex; + this.size = Long.parseLong(size); + } + + public static IAEItemStack setTag(IAEItemStack ias, long size, int slotIndex) { + NBTTagCompound data = new NBTTagCompound(); + ItemStack is = ias.getItemStack(); + data.setLong("BatchSize", size); + data.setLong("Index", slotIndex); + is.setTagCompound(data); + IAEItemStack iaeItemStack = AEItemStack.create(is); + iaeItemStack.setStackSize(ias.getStackSize()); + return iaeItemStack; + } + + @Override + public void fromBytes(ByteBuf buf) { + this.action = buf.readInt(); + this.slotIndex = buf.readInt(); + this.size = buf.readLong(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(this.action); + buf.writeInt(this.slotIndex); + buf.writeLong(this.size); + } + + public static class Handler implements IMessageHandler { + + @Nullable + @Override + public IMessage onMessage(CPacketLevelMaintainer message, MessageContext ctx) { + if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) { + EntityPlayerMP player = ctx.getServerHandler().playerEntity; + final ContainerLevelMaintainer cca = (ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer; + if (message.action == -1) { + SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(false); + for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { + IAEItemStack is = cca.getTile().requests.getCraftingSlots().getStack(i); + IAEItemStack is1 = cca.getTile().requests.getBatchInputs().getStack(i); + if (is != null) { + piu.appendItem(setTag(is, is1 != null ? is1.getStackSize() : 0, i)); + } + } + FluidCraft.proxy.netHandler.sendTo(piu, player); + } else { + cca.handleClientInteraction(message.action, message.slotIndex, message.size); + } + + } + return null; + } + } +} diff --git a/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java b/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java index a557f70c..4bd67a0c 100644 --- a/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java +++ b/src/main/java/com/glodblock/github/network/SPacketMEInventoryUpdate.java @@ -7,6 +7,7 @@ import appeng.util.item.AEItemStack; import com.glodblock.github.client.gui.GuiFCBaseFluidMonitor; import com.glodblock.github.client.gui.GuiFCBaseMonitor; import com.glodblock.github.client.gui.GuiFluidCraftConfirm; +import com.glodblock.github.client.gui.GuiLevelMaintainer; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -102,6 +103,8 @@ public class SPacketMEInventoryUpdate implements IMessage { ((GuiFCBaseMonitor) gs).postUpdate((List) (List) message.list); } else if (gs instanceof GuiFluidCraftConfirm) { ((GuiFluidCraftConfirm) gs).postUpdate((List) (List) message.list, message.ref); + } else if (gs instanceof GuiLevelMaintainer) { + ((GuiLevelMaintainer) gs).postUpdate((List) (List) message.list); } return null; } diff --git a/src/main/java/com/glodblock/github/util/NameConst.java b/src/main/java/com/glodblock/github/util/NameConst.java index bbbf4783..2d463855 100644 --- a/src/main/java/com/glodblock/github/util/NameConst.java +++ b/src/main/java/com/glodblock/github/util/NameConst.java @@ -11,6 +11,7 @@ public class NameConst { public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer"; public static final String BLOCK_LARGE_INGREDIENT_BUFFER = "large_ingredient_buffer"; public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor"; + public static final String BLOCK_LEVEL_MAINTAINER = "level_maintainer"; public static final String ITEM_FLUID_DROP = "fluid_drop"; public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern"; @@ -31,6 +32,8 @@ public class NameConst { public static final String TT_ENCODE_PATTERN = TT_KEY + "encode_pattern"; public static final String TT_EMPTY = TT_KEY + "empty"; public static final String TT_DUMP_TANK = TT_KEY + "dump_tank"; + public static final String TT_REQUEST_SIZE = TT_KEY + "request_size"; + public static final String TT_BATCH_SIZE = TT_KEY + "batch_size"; public static final String RES_KEY = FluidCraft.MODID + ":"; @@ -38,6 +41,7 @@ public class NameConst { public static final String GUI_FLUID_TERMINAL = GUI_KEY + ITEM_PART_FLUID_TERMINAL; public static final String GUI_FLUID_PATTERN_TERMINAL = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL; public static final String GUI_FLUID_PATTERN_TERMINAL_EX = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL_EX; + public static final String GUI_LEVEL_MAINTAINER = GUI_KEY + BLOCK_LEVEL_MAINTAINER; public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER; public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER; public static final String GUI_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER; diff --git a/src/main/resources/assets/ae2fc/lang/en_US.lang b/src/main/resources/assets/ae2fc/lang/en_US.lang index e7e74d14..4115ba1e 100644 --- a/src/main/resources/assets/ae2fc/lang/en_US.lang +++ b/src/main/resources/assets/ae2fc/lang/en_US.lang @@ -29,7 +29,10 @@ tile.fluid_interface.name=ME Dual Interface tile.ingredient_buffer.name=Ingredient Buffer tile.large_ingredient_buffer.name=Large Ingredient Buffer tile.oc_pattern_editor.name=OC Pattern Editor +tile.level_maintainer.name=ME Level Maintainer +ae2fc.tooltip.request_size=Amount to Maintain +ae2fc.tooltip.batch_size=Crafting Batch Size ae2fc.tooltip.fluid_terminal=uh So we don't need EC2 anymore? ae2fc.tooltip.invalid_fluid=Invalid fluid! ae2fc.tooltip.encode_pattern=Encode Patter @@ -46,6 +49,8 @@ ae2fc.tooltip.not_prio=Allow fluids to be placed first ae2fc.tooltip.not_prio.hint=Enabled ae2fc.tooltip.prio=Allow fluids to be placed first ae2fc.tooltip.prio.hint=Disabled +ae2fc.tooltip.submit=Submit +ae2fc.tooltip.submit.hint=Submit Request ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal @@ -54,6 +59,7 @@ ae2fc.gui.fluid_packet_decoder=ME Fluid Packet Decoder ae2fc.gui.ingredient_buffer=Ingredient Buffer ae2fc.gui.large_ingredient_buffer=Large Ingredient Buffer ae2fc.gui.fluid_interface=ME Dual Interface +ae2fc.gui.level_maintainer=ME Level Maintainer ae2fc.gui.fluid_interface.0=D ae2fc.gui.fluid_interface.1=U ae2fc.gui.fluid_interface.2=N diff --git a/src/main/resources/assets/ae2fc/lang/zh_CN.lang b/src/main/resources/assets/ae2fc/lang/zh_CN.lang index a12846d5..12123dab 100644 --- a/src/main/resources/assets/ae2fc/lang/zh_CN.lang +++ b/src/main/resources/assets/ae2fc/lang/zh_CN.lang @@ -29,7 +29,10 @@ tile.fluid_interface.name=ME二合一接口 tile.ingredient_buffer.name=原材料缓存仓 tile.large_ingredient_buffer.name=大型原材料缓存仓 tile.oc_pattern_editor.name=OC样板编辑器 +tile.level_maintainer.name=ME缓存指令器 +ae2fc.tooltip.request_size=缓存量 +ae2fc.tooltip.batch_size=批量制作数量 ae2fc.tooltip.fluid_terminal=我们不再需要EC2了吗? ae2fc.tooltip.invalid_fluid=流体无效! ae2fc.tooltip.encode_pattern=编写样板 @@ -46,6 +49,8 @@ ae2fc.tooltip.not_prio=优先放置流体 ae2fc.tooltip.not_prio.hint=启用 ae2fc.tooltip.prio=优先放置流体 ae2fc.tooltip.prio.hint=禁用 +ae2fc.tooltip.submit=提交 +ae2fc.tooltip.submit.hint=提交请求 ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端 ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端 @@ -54,6 +59,7 @@ ae2fc.gui.fluid_packet_decoder=ME流体封包解码器 ae2fc.gui.ingredient_buffer=原材料缓存仓 ae2fc.gui.large_ingredient_buffer=大型原材料缓存仓 ae2fc.gui.fluid_interface=ME二合一接口 +ae2fc.gui.level_maintainer=ME缓存指令器 ae2fc.gui.fluid_interface.0=下 ae2fc.gui.fluid_interface.1=上 ae2fc.gui.fluid_interface.2=北 diff --git a/src/main/resources/assets/ae2fc/textures/blocks/level_maintainer.png b/src/main/resources/assets/ae2fc/textures/blocks/level_maintainer.png new file mode 100644 index 0000000000000000000000000000000000000000..3a4500f9e5f1986cef7e43e2a1f3a3d61249355d GIT binary patch literal 202 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=De8Ak0{?)V>TT$X?><>&pI^RfK`hOlp}4P>w;e#5JPCIX^cyHLrxhxhOTUBsE2$ zJhLQ2!QIn0AiR-J9H_|1)5S5w;&if!x$)2Q4vYzj2?+@kCQnxO{=C?|Ut)%Y2Fqf$ m9w~z?hM>HfFE0dd0$t|%l|4&uP3aAwZU#?RKbLh*2~7abvN+HH literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/ae2fc/textures/blocks/level_maintainerActive.png b/src/main/resources/assets/ae2fc/textures/blocks/level_maintainerActive.png new file mode 100644 index 0000000000000000000000000000000000000000..a87a3e061077f9bbffa64f8cb2bdc059dffacf48 GIT binary patch literal 1343 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 }~T?BFvmgzCjI(0fG6m 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 jepeK@{oCO|{#S9GG z!XV7ZFl&wkP=RBBPlzi}(#6GP#flaG|Np;n+(P$XW|+OZ zsHkYw{g?Ii^-WDpK=n6xc(krc{AXCjz{v1_->T)SmakmBa{0>TD^{&owQAMs)vF5& z3k|fDjP+EFbyb$FSXNM6kXw+OUzlG|P>`3Gm!F>>5)xvhqg)**Zl@` zQ&3otRhktX931N=nd`4Kefspu%F1j{sVr}K1sU;WE0^UIB zPfAKsRgxAL6C+|^K#?5D?(&tr9@*V#Kv^TB-JKG^h6|8C*|hmX8MXobVVdrCkF)uMfOIf z*QF~+i^@xj$x4Yyhzf>=hK7ZOJ$?GLySux+z1?j?(rI9zWS0c_1v3BxkxszvsGRHouw_|qs~vCpYn7p=-#^q{iQN^5b`bMGo&&r_uh z=ZdGSH3@27q#DY*;Iquvv&y|!7G!yb8uQG34ooM(%s#uiLY0jQWTdx5d2(0g>WVpR zT*q9|$2;W=L)Xslw9|Eb3-Inpw8TEaqShC1%` z`_khqUNmLFnu%*oXIoybD6uD6WWZ^cR!ya_a|fjje>in zch~Bk|IBtHarf=L4St}8EtV%|xU zjP1`QLToObKbc}A;ZyfFjm_%s<@w*1Uw#;15OgtCN%UQi+*RH`U!VPdP&ngw&Pvtu z{OKK)f2N(5bg)^UG-L7dC5-#erfH=*)ZST~(^ffYaY|cAyq(GE*i4mayIUBaAGDon wsNx>0c=%9c_{o4@4=#1LxBX90d;U>etL+xgtpX!pS-`;H>FVdQ&MBb@0K_pFBme*a delta 1112 zcmV-e1gHDb2;vBk8Gi-<00374`G)`i00DDSM?wIu&K&6g00bOKL_t(&fz_8!NF+xT z#(zECZgypp2_7`Z&5}%(2$IVj!osi_%0P}0jN~|Az!|*e9&+7e@E|BeaLGXzJ>(cB ziVJ$|2ojPt8W)TtLEV!$V^-~+%3-G4?&&|a_C(w7VpUmRzkl!5d#~yZM1&AR3L#|F z{q5!lK|9Z=H69)wwuW+XaZ!o#@wogb@Ho(FbZBUZjg1YQYhfbd@-GS{$SB}4?8MsI z8dFnKSR&%`V>uv%kOKn)6pKZBG05=P*qCd+y1Gg_ohA-n*Yyx5K9x`dehS>90Thcx zCMG7x=kuXP`+xfSJObLm4-!B4>}%$?cHs+TkP~(d z?}x#A-3{^E`=R?ZfaT?7a=9Fvo0}e^04pmi=( z(}BX~xA&tvu&}T|e}6x@T+Y|1uIv1M_bv}~okF2NsZ_G(LWpzuPSKWw<#O3R055(} z=0B>*&z^nTEaJxm6|o|OkmKXy0E~`~a&U0qYt$B9t=fOH*(~XFnkal{RLbQt@Bj7| z&wF>F`F|Gq*-RFijKvg_SNR+<)|ny}dnq&6EcJ z9)F))wZ>4m98eW_^v>CQe}A7^t>#!$`0>~FTwLvfTTM!(yQ>2L^VJdR_EX+V!O825 zn!VMbQJ2S8E;0wdxaq@Nd=Jac~l6?ySe1E@OMWS%lCRuNrLR}tndYa&OAW1K5RNVMp z=*G9x%5@9)=kJG?=FZH_G;81*`*}-97!1Qe)4Ux(rBX>|4H$;uJN8539Pm4BYwqVv zVmdQRT$p&jG)hzi`~-scOa~ Date: Sun, 23 Oct 2022 18:10:37 +0800 Subject: [PATCH 3/7] fluid terminal clean up --- .../github/client/gui/GuiFCBaseFluidMonitor.java | 8 ++++---- .../com/glodblock/github/client/me/FluidRepo.java | 9 +++------ .../github/common/item/ItemFluidDrop.java | 7 ++++++- .../github/common/parts/PartFluidTerminal.java | 4 ++-- src/main/java/com/glodblock/github/util/Util.java | 1 + src/main/resources/META-INF/ae2fc_at.cfg | 2 ++ src/main/resources/assets/ae2fc/lang/en_US.lang | 4 ++++ .../textures/blocks/fluid_terminal_board.png | Bin 244 -> 0 bytes 8 files changed, 22 insertions(+), 13 deletions(-) delete mode 100644 src/main/resources/assets/ae2fc/textures/blocks/fluid_terminal_board.png diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java index 5470b1a9..ea5cda31 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java @@ -39,8 +39,10 @@ import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.network.CPacketInventoryAction; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; +import com.glodblock.github.util.NameConst; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; @@ -52,8 +54,6 @@ import org.lwjgl.input.Mouse; import java.io.IOException; import java.util.List; -import static com.glodblock.github.common.item.ItemFluidDrop.newStack1; - public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost { public static int craftingGridOffsetX; @@ -105,7 +105,7 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I public void postUpdate(final List list) { for (final IAEFluidStack is : list) { - IAEItemStack stack = AEItemStack.create(newStack1(is.getFluidStack())); + IAEItemStack stack = AEItemStack.create(ItemFluidDrop.newDisplayStack(is.getFluidStack())); stack.setStackSize(is.getStackSize()); this.repo.postUpdate(stack); } @@ -302,7 +302,7 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I @Override public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { - this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752); + this.fontRendererObj.drawString(this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_TERMINAL)), 8, 6, 4210752); this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752); } diff --git a/src/main/java/com/glodblock/github/client/me/FluidRepo.java b/src/main/java/com/glodblock/github/client/me/FluidRepo.java index e102d1de..36885231 100644 --- a/src/main/java/com/glodblock/github/client/me/FluidRepo.java +++ b/src/main/java/com/glodblock/github/client/me/FluidRepo.java @@ -89,15 +89,12 @@ public class FluidRepo extends ItemRepo { } public void postUpdate(final IAEItemStack is) { - IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(is); - IAEItemStack i = AEItemStack.create(is.getItemStack().setStackDisplayName(fluid.getFluid().getLocalizedName())); - i.setStackSize(is.getStackSize()); - final IAEItemStack st = this.list.findPrecise(i); + final IAEItemStack st = this.list.findPrecise(is); if (st != null) { st.reset(); - st.add(i); + st.add(is); } else { - this.list.add(i); + this.list.add(is); } } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java index 1c033d0c..9ce6d1a9 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java @@ -46,6 +46,9 @@ public class ItemFluidDrop extends Item { @Override public String getItemStackDisplayName(ItemStack stack) { FluidStack fluid = getFluidStack(stack); + if (ItemFluidPacket.isDisplay(stack)) { + return fluid != null ? fluid.getLocalizedName() : StatCollector.translateToLocalFormatted("error.unknown"); + } return StatCollector.translateToLocalFormatted("item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName()); } @@ -54,6 +57,7 @@ public class ItemFluidDrop extends Item { @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flag) { FluidStack fluid = getFluidStack(stack); + if (ItemFluidPacket.isDisplay(stack)) return; if (fluid != null) { tooltip.add(String.format(EnumChatFormatting.GRAY + "%s, 1 mB", fluid.getLocalizedName())); } else { @@ -79,13 +83,14 @@ public class ItemFluidDrop extends Item { return stack; } - public static ItemStack newStack1(FluidStack fluid) { + public static ItemStack newDisplayStack(FluidStack fluid) { if (fluid == null) { return null; } ItemStack stack = new ItemStack(ItemAndBlockHolder.DROP, fluid.amount); NBTTagCompound tag = new NBTTagCompound(); tag.setString("Fluid", fluid.getFluid().getName()); + tag.setBoolean("DisplayOnly", true); stack.setTagCompound(tag); return stack; } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java b/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java index dd518eb6..655f036a 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidTerminal.java @@ -19,8 +19,8 @@ import java.util.Objects; public class PartFluidTerminal extends FCBasePart { private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright; - private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Dark; - private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Colored; + private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Colored; + private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Dark; public PartFluidTerminal(ItemStack is) { super(is, true); diff --git a/src/main/java/com/glodblock/github/util/Util.java b/src/main/java/com/glodblock/github/util/Util.java index 080ef938..5eadad50 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -18,6 +18,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; import org.apache.commons.lang3.tuple.MutablePair; + public final class Util { public static EnumFacing from(ForgeDirection direction) { diff --git a/src/main/resources/META-INF/ae2fc_at.cfg b/src/main/resources/META-INF/ae2fc_at.cfg index d9650cf7..43816380 100644 --- a/src/main/resources/META-INF/ae2fc_at.cfg +++ b/src/main/resources/META-INF/ae2fc_at.cfg @@ -5,3 +5,5 @@ public net.minecraft.client.gui.inventory.GuiContainer field_147003_i # guiLeft public net.minecraft.client.gui.inventory.GuiContainer field_147009_r # guiTop #Pattern Value Setting public net.minecraft.client.gui.inventory.GuiContainer field_147006_u #theSlot + +public net.minecraft.client.renderer.texture.TextureMap field_110574_e # mapRegisteredSprites diff --git a/src/main/resources/assets/ae2fc/lang/en_US.lang b/src/main/resources/assets/ae2fc/lang/en_US.lang index 4115ba1e..5c9a862d 100644 --- a/src/main/resources/assets/ae2fc/lang/en_US.lang +++ b/src/main/resources/assets/ae2fc/lang/en_US.lang @@ -70,4 +70,8 @@ ae2fc.gui.oc_pattern_editor=OC Pattern Editor ae2fc.gui.button.set=Set ae2fc.gui.part_fluid_import=ME Fluid Import Bus ae2fc.gui.part_fluid_export=ME Fluid Export Bus +ae2fc.gui.part_fluid_terminal=Fluid Terminal + +error.unknown=Unknown + itemGroup.ae2fc=Fluid Craft For AE2 diff --git a/src/main/resources/assets/ae2fc/textures/blocks/fluid_terminal_board.png b/src/main/resources/assets/ae2fc/textures/blocks/fluid_terminal_board.png deleted file mode 100644 index c5c2a4c1edaa8f868bb93b8996ca72dde1ea2609..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8X6a5n0T@z_$#98Qbry z%m)femAFQf1m~xflqVLYG6W=M=9TFAxrQi|8S9zq85+8Ob}|R5a`AL=46*P}mauW~ z4*j-&<2)^i+0v_$Qx9)w>v~ha!i(pe2|&l_TRY8Ht+i(Xn#bVj>gTe~DWM4f%JW2x From 89068c4dff6ff8a6eef7e9cad1400082c47588b5 Mon Sep 17 00:00:00 2001 From: Guinea Wheek Date: Mon, 31 Oct 2022 19:34:47 -0700 Subject: [PATCH 4/7] fix silly NPE crash --- .../github/inventory/FluidConvertingInventoryAdaptor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java index ebf9cd5b..712d294d 100644 --- a/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java +++ b/src/main/java/com/glodblock/github/inventory/FluidConvertingInventoryAdaptor.java @@ -201,7 +201,10 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor { } if (p2p == invFluidsP2P || p2p == null) continue; - tankInfos.add(Ae2Reflect.getP2PLiquidTarget(p2p).getTankInfo(p2p.getSide().getOpposite())); + IFluidHandler target = Ae2Reflect.getP2PLiquidTarget(p2p); + if (target == null) + continue; + tankInfos.add(target.getTankInfo(p2p.getSide().getOpposite())); } } catch (GridAccessException e) { // ignore From 5d31d6d6fb58aded6b82b52aec7b4d75fd00b9da Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Mon, 7 Nov 2022 19:45:37 +0800 Subject: [PATCH 5/7] Add LevelMaintainer --- .../gui/GuiBaseFluidPatternTerminal.java | 1 - .../gui/GuiBaseFluidPatternTerminalEx.java | 16 +- .../client/gui/GuiFCBaseFluidMonitor.java | 57 +++++- .../github/client/gui/GuiFCBaseMonitor.java | 77 +++++--- .../github/client/gui/GuiLevelMaintainer.java | 73 +++++++- .../container/ContainerLevelMaintainer.java | 43 +---- .../gui/container/FCBasePartContainer.java | 34 ++-- .../gui/container/FCBasePartContainerEx.java | 32 ++-- .../github/common/item/ItemFluidDrop.java | 19 ++ .../common/storage/FluidCellInventory.java | 2 +- .../common/tile/TileLevelMaintainer.java | 170 ++++++++++++------ .../glodblock/github/loader/RecipeLoader.java | 3 + .../network/CPacketLevelMaintainer.java | 8 +- .../resources/assets/ae2fc/lang/en_US.lang | 4 +- .../resources/assets/ae2fc/lang/zh_CN.lang | 4 +- 15 files changed, 373 insertions(+), 170 deletions(-) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java index 139fe602..fcedaf8f 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java @@ -130,7 +130,6 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED); this.beSubstitutionsDisabledBtn.setHalfSize(true); this.buttonList.add(this.beSubstitutionsDisabledBtn); - } this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE"); this.combineEnableBtn.setHalfSize(true); diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java index 3c9938cd..db90f6e2 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java @@ -101,12 +101,12 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { this.substitutionsDisabledBtn.setHalfSize( true ); this.buttonList.add( this.substitutionsDisabledBtn ); - this.fluidPrioritizedEnabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "FORCE_PRIO", "DO_PRIO" ); - this.fluidPrioritizedEnabledBtn.setHalfSize( true ); + this.fluidPrioritizedEnabledBtn = new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "FORCE_PRIO", "DO_PRIO"); + this.fluidPrioritizedEnabledBtn.setHalfSize(true); this.buttonList.add( this.fluidPrioritizedEnabledBtn ); - this.fluidPrioritizedDisabledBtn = new GuiFCImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 143, "NOT_PRIO", "DONT_PRIO" ); - this.fluidPrioritizedDisabledBtn.setHalfSize( true ); + this.fluidPrioritizedDisabledBtn = new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "NOT_PRIO", "DONT_PRIO"); + this.fluidPrioritizedDisabledBtn.setHalfSize(true); this.buttonList.add( this.fluidPrioritizedDisabledBtn ); invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4); @@ -126,21 +126,21 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { this.buttonList.add(this.doubleBtn); } - this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "FORCE_COMBINE", "DO_COMBINE"); + this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "FORCE_COMBINE", "DO_COMBINE"); this.combineEnableBtn.setHalfSize(true); this.buttonList.add(this.combineEnableBtn); - this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 143, "NOT_COMBINE", "DONT_COMBINE"); + this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE"); this.combineDisableBtn.setHalfSize(true); this.buttonList.add(this.combineDisableBtn); if (ModAndClassUtil.isBeSubstitutionsButton) { this.beSubstitutionsEnabledBtn = new GuiImgButton( - this.guiLeft + 87, this.guiTop + this.ySize - 133, Settings.ACTIONS, PatternBeSubstitution.ENABLED); + this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.ENABLED); this.beSubstitutionsEnabledBtn.setHalfSize(true); this.buttonList.add(this.beSubstitutionsEnabledBtn); this.beSubstitutionsDisabledBtn = new GuiImgButton( - this.guiLeft + 87, this.guiTop + this.ySize - 133, Settings.ACTIONS, PatternBeSubstitution.DISABLED); + this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.DISABLED); this.beSubstitutionsDisabledBtn.setHalfSize(true); this.buttonList.add(this.beSubstitutionsDisabledBtn); } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java index ea5cda31..df9342c3 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseFluidMonitor.java @@ -8,10 +8,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.client.gui.AEBaseMEGui; -import appeng.client.gui.widgets.GuiImgButton; -import appeng.client.gui.widgets.GuiScrollbar; -import appeng.client.gui.widgets.GuiTabButton; -import appeng.client.gui.widgets.ISortSource; +import appeng.client.gui.widgets.*; import appeng.client.me.InternalSlotME; import appeng.client.me.SlotDisconnected; import appeng.client.me.SlotME; @@ -32,6 +29,8 @@ import appeng.integration.IntegrationType; import appeng.util.IConfigManagerHost; import appeng.util.Platform; import appeng.util.item.AEItemStack; +import codechicken.nei.LayoutManager; +import codechicken.nei.util.TextHistory; import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain; import com.glodblock.github.client.me.FluidRepo; @@ -40,6 +39,7 @@ import com.glodblock.github.network.CPacketInventoryAction; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; import com.glodblock.github.util.NameConst; +import com.glodblock.github.util.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.resources.I18n; @@ -52,9 +52,10 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import java.io.IOException; +import java.lang.reflect.Field; import java.util.List; -public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost { +public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField { public static int craftingGridOffsetX; public static int craftingGridOffsetY; @@ -309,11 +310,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I @Override protected void mouseClicked(final int xCoord, final int yCoord, final int btn) { final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); - if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) { this.searchField.mouseClicked(xCoord, yCoord, btn); } - if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) { setSearchString("", true); } @@ -321,6 +320,39 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I super.mouseClicked(xCoord, yCoord, btn); } + @Override + public void handleMouseInput() { + final int wheel = Mouse.getEventDWheel(); + final int x = Mouse.getEventX() * this.width / this.mc.displayWidth; + final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight; + + if (wheel != 0 && this.searchField.isMouseIn(x, y) && isCtrlKeyDown()) { + final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); + if (searchMode == SearchBoxMode.NEI_MANUAL_SEARCH || searchMode == SearchBoxMode.NEI_AUTOSEARCH) { + try { + Field cls = LayoutManager.searchField.getClass().getDeclaredField("history"); + cls.setAccessible(true); + TextHistory history = ((TextHistory) cls.get("get")); + TextHistory.Direction direction; + if (wheel > 0) { + direction = TextHistory.Direction.PREVIOUS; + } else { + direction = TextHistory.Direction.NEXT; + } + history.get(direction, this.searchField.getText()) + .map(newText -> { + setSearchString(newText, true); + return true; + }) + .orElse(false); + return; + } catch (NoSuchFieldException | IllegalAccessException e) { + } + } + } + super.handleMouseInput(); + } + @Override protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { final EntityPlayer player = Minecraft.getMinecraft().thePlayer; @@ -686,4 +718,15 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I return false; } + @Override + public boolean isOverTextField(int mousex, int mousey) { + return searchField.isMouseIn(mousex, mousey); + } + + @Override + public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) { + if (Util.getFluidFromItem(stack) != null) { + setSearchString(Util.getFluidFromItem(stack).getFluid().getLocalizedName(), true); + } + } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java index 9512ca57..598c86f3 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCBaseMonitor.java @@ -7,10 +7,7 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.client.gui.AEBaseMEGui; -import appeng.client.gui.widgets.GuiImgButton; -import appeng.client.gui.widgets.GuiScrollbar; -import appeng.client.gui.widgets.GuiTabButton; -import appeng.client.gui.widgets.ISortSource; +import appeng.client.gui.widgets.*; import appeng.client.me.InternalSlotME; import appeng.client.me.ItemRepo; import appeng.client.me.SlotDisconnected; @@ -32,6 +29,8 @@ import appeng.integration.IntegrationType; import appeng.util.IConfigManagerHost; import appeng.util.Platform; import appeng.util.item.AEItemStack; +import codechicken.nei.LayoutManager; +import codechicken.nei.util.TextHistory; import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.container.FCBaseMonitorContain; import com.glodblock.github.network.CPacketInventoryAction; @@ -48,10 +47,10 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import java.io.IOException; +import java.lang.reflect.Field; import java.util.List; -public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost -{ +public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField { public static int craftingGridOffsetX; public static int craftingGridOffsetY; @@ -343,29 +342,58 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi } @Override - protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) - { - final Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ); - - if( searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH ) - { - this.searchField.mouseClicked( xCoord, yCoord, btn ); + protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) { + final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); + final EntityPlayer player = Minecraft.getMinecraft().thePlayer; + ItemStack is = player.inventory.getItemStack(); + if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) { + this.searchField.mouseClicked(xCoord, yCoord, btn); } - - if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) ) - { + if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) { setSearchString("", true); } - super.mouseClicked( xCoord, yCoord, btn ); + super.mouseClicked(xCoord, yCoord, btn); } @Override - protected void handleMouseClick( final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton ) - { + public void handleMouseInput() { + final int wheel = Mouse.getEventDWheel(); + final int x = Mouse.getEventX() * this.width / this.mc.displayWidth; + final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight; + + if (wheel != 0 && this.searchField.isMouseIn(x, y) && isCtrlKeyDown()) { + final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); + if (searchMode == SearchBoxMode.NEI_MANUAL_SEARCH || searchMode == SearchBoxMode.NEI_AUTOSEARCH) { + try { + Field cls = LayoutManager.searchField.getClass().getDeclaredField("history"); + cls.setAccessible(true); + TextHistory history = ((TextHistory) cls.get("get")); + TextHistory.Direction direction; + if (wheel > 0) { + direction = TextHistory.Direction.PREVIOUS; + } else { + direction = TextHistory.Direction.NEXT; + } + history.get(direction, this.searchField.getText()) + .map(newText -> { + setSearchString(newText, true); + return true; + }) + .orElse(false); + return; + } catch (NoSuchFieldException | IllegalAccessException e) { + } + } + } + super.handleMouseInput(); + } + + @Override + protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { final EntityPlayer player = Minecraft.getMinecraft().thePlayer; - if (mouseButton == 3 ){ + if (mouseButton == 3) { if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) { if (slot.getHasStack()) { InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE"); @@ -790,4 +818,13 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi return false; } + @Override + public boolean isOverTextField(int mousex, int mousey) { + return searchField.isMouseIn(mousex, mousey); + } + + @Override + public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) { + setSearchString(displayName, true); + } } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java index dc48fda2..b7f4468c 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -4,9 +4,13 @@ import appeng.api.storage.data.IAEItemStack; import appeng.client.gui.AEBaseGui; import appeng.client.render.AppEngRenderItem; import appeng.container.slot.SlotFake; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketNEIDragClick; +import codechicken.nei.VisiblityData; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.TaggedInventoryArea; import com.glodblock.github.FluidCraft; import com.glodblock.github.client.gui.container.ContainerLevelMaintainer; -import com.glodblock.github.common.item.ItemFluidPacket; import com.glodblock.github.common.tile.TileLevelMaintainer; import com.glodblock.github.inventory.gui.MouseRegionManager; import com.glodblock.github.inventory.slot.SlotSingleItem; @@ -14,16 +18,22 @@ import com.glodblock.github.network.CPacketLevelMaintainer; import com.glodblock.github.util.Ae2ReflectClient; import com.glodblock.github.util.ModAndClassUtil; import com.glodblock.github.util.NameConst; +import cpw.mods.fml.common.Optional; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; +import java.awt.*; +import java.util.Collections; import java.util.List; -public class GuiLevelMaintainer extends AEBaseGui { +@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler") +public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_maintainer.png"); private final ContainerLevelMaintainer cont; @@ -44,7 +54,7 @@ public class GuiLevelMaintainer extends AEBaseGui { public void postUpdate(List list) { for (IAEItemStack is : list) { - long size = is.getItemStack().getTagCompound().getLong("BatchSize"); + long size = is.getItemStack().getTagCompound().getLong("Batch"); int i = is.getItemStack().getTagCompound().getInteger("Index"); qtyInputs[i].textField.setText(String.valueOf(is.getStackSize())); batchInputs[i].textField.setText(String.valueOf(size)); @@ -109,9 +119,10 @@ public class GuiLevelMaintainer extends AEBaseGui { super.func_146977_a(new SlotSingleItem(slot)); if (stack == null) return true; IAEItemStack fake = stack.copy(); - if (fake.getItemStack().getItem() instanceof ItemFluidPacket) { - if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0) - fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount); + if (this.qtyInputs[slot.getSlotIndex()].textField.getText().matches("[0-9]+")) { + fake.setStackSize(Long.parseLong(this.qtyInputs[slot.getSlotIndex()].textField.getText())); + } else { + fake.setStackSize(0); } stackSizeRenderer.setAeStack(fake); stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition); @@ -172,10 +183,11 @@ public class GuiLevelMaintainer extends AEBaseGui { @Override protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { - super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); if (slot instanceof ContainerLevelMaintainer.FakeSlot && this.cont.getPlayerInv().getItemStack() != null) { this.qtyInputs[slot.getSlotIndex()].textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); + return; } + super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); } public void updateAmount(int idx, int stackSize) { @@ -184,7 +196,8 @@ public class GuiLevelMaintainer extends AEBaseGui { private boolean sendToServer(Widget widget) { if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) { - if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("[0-9]+") && Long.parseLong(widget.textField.getText()) <= Integer.MAX_VALUE) { + if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("[0-9]+")) { + widget.textField.setText(widget.textField.getText().replaceAll("^(0+)", "")); FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); widget.textField.setTextColor(0xFFFFFF); return true; @@ -213,6 +226,49 @@ public class GuiLevelMaintainer extends AEBaseGui { } } + @Override + public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { + return currentVisibility; + } + + @Override + public Iterable getItemSpawnSlots(GuiContainer gui, ItemStack item) { + return Collections.emptyList(); + } + + @Override + public List getInventoryAreas(GuiContainer gui) { + return null; + } + + private Rectangle getSlotArea(SlotFake slot) { + return new Rectangle(guiLeft + slot.getX(), guiTop + slot.getY(), 16, 16); + } + + @Override + public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) { + for (ContainerLevelMaintainer.FakeSlot slot : this.cont.getRequestSlots()) { + if (getSlotArea(slot).contains(mouseX, mouseY)) { + slot.putStack(draggedStack); + NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex())); + if (draggedStack != null) { + this.updateAmount(slot.getSlotIndex(), draggedStack.stackSize); + draggedStack.stackSize = 0; + } + return true; + } + } + if (draggedStack != null) { + draggedStack.stackSize = 0; + } + return false; + } + + @Override + public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { + return false; + } + private class Widget { public final int idx; public final int action; @@ -224,6 +280,7 @@ public class GuiLevelMaintainer extends AEBaseGui { this.textField.setMessage(tooltip); this.textField.setEnableBackgroundDrawing(false); this.textField.setText("0"); + this.textField.setMaxStringLength(10); // it's enough to useful this.button = button; this.idx = idx; this.action = action; diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java index 74693780..71337aef 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java @@ -1,34 +1,27 @@ package com.glodblock.github.client.gui.container; import appeng.container.AEBaseContainer; -import appeng.container.slot.OptionalSlotFake; -import appeng.container.slot.SlotFakeCraftingMatrix; -import appeng.util.Platform; import appeng.util.item.AEItemStack; -import com.glodblock.github.client.gui.GuiLevelMaintainer; import com.glodblock.github.common.tile.TileLevelMaintainer; import com.glodblock.github.inventory.AeItemStackHandler; -import net.minecraft.client.Minecraft; 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.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerLevelMaintainer extends AEBaseContainer { private final TileLevelMaintainer tile; - private final FakeSlot[] craftingSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT]; + private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT]; public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) { super(ipl, tile); this.tile = tile; - AeItemStackHandler crafting = new AeItemStackHandler(tile.getCraftingSlots()); + AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots()); for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) { - FakeSlot slot = new FakeSlot(crafting, y, 17, 19 + y * 20); + FakeSlot slot = new FakeSlot(request, y, 17, 19 + y * 20); addSlotToContainer(slot); - craftingSlots[y] = slot; + requestSlots[y] = slot; } bindPlayerInventory(ipl, 0, 132); } @@ -37,15 +30,15 @@ public class ContainerLevelMaintainer extends AEBaseContainer { return tile; } + public FakeSlot[] getRequestSlots() { + return this.requestSlots; + } + @Override public ItemStack transferStackInSlot(EntityPlayer player, int idx) { - for (ContainerFluidPatternEncoder.SlotFluidConvertingFake slot : craftingSlots) { + for (FakeSlot slot : this.getRequestSlots()) { if (!slot.getHasStack()) { slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true); - if (Platform.isClient()) { - GuiLevelMaintainer gui = (GuiLevelMaintainer) Minecraft.getMinecraft().currentScreen; - gui.updateAmount(slot.getSlotIndex(), ((Slot) this.inventorySlots.get(idx)).getStack().stackSize); - } break; } } @@ -62,24 +55,6 @@ public class ContainerLevelMaintainer extends AEBaseContainer { } } - @Override - public void onSlotChange(final Slot s) { - if (Platform.isServer()) { - for (final Object crafter : this.crafters) { - final ICrafting icrafting = (ICrafting) crafter; - - for (final Object g : this.inventorySlots) { - if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) { - final Slot sri = (Slot) g; - icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack()); - } - } - ((EntityPlayerMP) icrafting).isChangingQuantityOnly = false; - } - this.detectAndSendChanges(); - } - } - public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake { public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) { diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java index 61ee9226..5e729316 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainer.java @@ -613,22 +613,10 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE assert !ow.hasNext(); } - public void doubleStacks(boolean isShift) - { - if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { - doubleStacksInternal(this.craftingSlots); - doubleStacksInternal(this.outputSlots); - if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) - { - while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { - doubleStacksInternal(this.craftingSlots); - doubleStacksInternal(this.outputSlots); - } - } - this.detectAndSendChanges(); - } + static boolean containsItem(SlotFake[] slots) { + List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count(); + return item > 0; } static boolean containsFluid(SlotFake[] slots) { @@ -637,4 +625,18 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE return fluid > 0; } + public void doubleStacks(boolean isShift) { + if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { + doubleStacksInternal(this.craftingSlots); + doubleStacksInternal(this.outputSlots); + if (isShift && (containsItem(outputSlots) || containsItem(craftingSlots))) { + while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { + doubleStacksInternal(this.craftingSlots); + doubleStacksInternal(this.outputSlots); + } + } + this.detectAndSendChanges(); + } + } + } diff --git a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java index 1e749db7..72e394f6 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/FCBasePartContainerEx.java @@ -447,20 +447,10 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp assert !ow.hasNext(); } - public void doubleStacks(boolean isShift) - { - if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) - { - doubleStacksInternal(this.craftingSlots); - doubleStacksInternal(this.outputSlots); - if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots)) { - while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { - doubleStacksInternal(this.craftingSlots); - doubleStacksInternal(this.outputSlots); - } - } - this.detectAndSendChanges(); - } + static boolean containsItem(SlotFake[] slots) { + List enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList()); + long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count(); + return item > 0; } private boolean canBeSubstitute() { @@ -473,6 +463,20 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp return fluid > 0; } + public void doubleStacks(boolean isShift) { + if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { + doubleStacksInternal(this.craftingSlots); + doubleStacksInternal(this.outputSlots); + if (isShift && (containsItem(outputSlots) || containsItem(craftingSlots))) { + while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) { + doubleStacksInternal(this.craftingSlots); + doubleStacksInternal(this.outputSlots); + } + } + this.detectAndSendChanges(); + } + } + public void setActivePage(final int activePage) { this.activePage = activePage; } diff --git a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java index 9ce6d1a9..1389b413 100644 --- a/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java +++ b/src/main/java/com/glodblock/github/common/item/ItemFluidDrop.java @@ -95,6 +95,25 @@ public class ItemFluidDrop extends Item { return stack; } + public static boolean isFluidStack(ItemStack stack) { + if (getFluidStack(stack) != null) { + return true; + } else { + return false; + } + } + + public static boolean isFluidStack(@Nullable IAEItemStack stack) { + if (stack == null) { + return false; + } + if (getFluidStack(stack.getItemStack()) != null) { + return true; + } else { + return false; + } + } + public static FluidStack getFluidStack(ItemStack stack) { if (stack == null || stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) { return null; diff --git a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java index 23ba5217..3ec27129 100644 --- a/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java +++ b/src/main/java/com/glodblock/github/common/storage/FluidCellInventory.java @@ -149,7 +149,7 @@ public class FluidCellInventory implements IFluidCellInventory { @Override public long getUsedBytes() { long bytesForItemCount = this.getStoredFluidCount() / singleByteAmount; - long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) * singleByteAmount + bytesForItemCount; + long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) + bytesForItemCount; if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++; return tmp; } diff --git a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java index b0f0c426..ee19d286 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java @@ -1,6 +1,8 @@ package com.glodblock.github.common.tile; +import appeng.api.AEApi; import appeng.api.config.Actionable; +import appeng.api.config.PowerMultiplier; import appeng.api.networking.GridFlags; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; @@ -8,24 +10,26 @@ import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.crafting.ICraftingJob; import appeng.api.networking.crafting.ICraftingLink; import appeng.api.networking.crafting.ICraftingRequester; +import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.MachineSource; -import appeng.api.networking.storage.IStackWatcher; -import appeng.api.networking.storage.IStackWatcherHost; import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEFluidStack; import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IItemList; -import appeng.helpers.MultiCraftingTracker; +import appeng.core.AELog; +import appeng.crafting.CraftingLink; +import appeng.helpers.NonNullArrayIterator; import appeng.me.GridAccessException; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkTile; import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; +import com.glodblock.github.common.item.ItemFluidDrop; import com.glodblock.github.inventory.AeStackInventory; import com.glodblock.github.inventory.AeStackInventoryImpl; import com.google.common.collect.ImmutableSet; @@ -35,12 +39,11 @@ import net.minecraft.nbt.NBTTagCompound; import java.util.concurrent.Future; -public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IStackWatcherHost, IGridTickable, ICraftingRequester { +public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IGridTickable, ICraftingRequester { public static final int REQ_COUNT = 5; public final InventoryRequest requests = new InventoryRequest(this); private final BaseActionSource source; - private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, REQ_COUNT); public TileLevelMaintainer() { @@ -49,23 +52,46 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven this.source = new MachineSource(this); } - public AeStackInventory getCraftingSlots() { - return requests.getCraftingSlots(); + public AeStackInventory getRequestSlots() { + return requests.getRequestStacks(); } @Override public ImmutableSet getRequestedJobs() { - return this.craftingTracker.getRequestedJobs(); + return ImmutableSet.copyOf(new NonNullArrayIterator(this.requests.getLinks())); } @Override public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) { - return null; + try { + if (this.getProxy().isActive()) { + final IEnergyGrid energy = this.getProxy().getEnergy(); + final double power = Math.ceil(ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize()); + if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) { + if (ItemFluidDrop.isFluidStack(items)) { + IAEFluidStack notInserted = this.getProxy().getStorage().getFluidInventory().injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source); + items.setStackSize(notInserted.getStackSize()); + return items; + } else { + return this.getProxy().getStorage().getItemInventory().injectItems(items, mode, this.source); + } + } + } + } catch (GridAccessException e) { + AELog.debug(e); + } + return items; } - @Override public void jobStateChange(ICraftingLink link) { - this.craftingTracker.jobStateChange(link); + if (this.requests.getLinks() != null) { + for (int x = 0; x < this.requests.getLinks().length; x++) { + if (this.requests.getLinks()[x] == link) { + this.requests.getLinks()[x] = link; + return; + } + } + } } @Override @@ -77,7 +103,6 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) { return this.canDoBusWork() ? this.doWork() : TickRateModulation.IDLE; } - private TickRateModulation doWork() { if (!this.getProxy().isActive() || !this.canDoBusWork()) { return TickRateModulation.IDLE; @@ -91,24 +116,23 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven IAEItemStack is = requests.getQuantity(i); if (is != null && requests.getBatchSize(i) > 0) { IAEItemStack craftItem = requests.getCraftItem(i); - if (inv.findPrecise(is) == null || inv.findPrecise(is).getStackSize() >= is.getStackSize() || cg.isRequesting(craftItem)) + if (cg.canEmitFor(craftItem) || cg.isRequesting(craftItem) || + (inv.findPrecise(is) != null && inv.findPrecise(is).getStackSize() >= is.getStackSize()) || !this.requests.isDone(i) + ) continue; - // do crafting - Future jobTask = requests.getJobs()[i]; - if (jobTask == null) { requests.getJobs()[i] = cg.beginCraftingJob(getWorldObj(), grid, this.source, craftItem, null); } else if (jobTask.isDone()) { try { ICraftingJob job = jobTask.get(); if (job != null) { - ICraftingLink link = cg.submitJob(job, null, null, false, this.source); + ICraftingLink link = cg.submitJob(job, this, null, false, this.source); didSomething = true; requests.jobs[i] = null; if (link != null) { - requests.links[i] = link; + requests.getLinks()[i] = link; } } } catch (Exception ignored) { @@ -137,25 +161,16 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } } - @Override - public void updateWatcher(IStackWatcher newWatcher) { - - } - protected boolean canDoBusWork() { return this.getProxy().isActive(); } - @Override - public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan) { - } - public InventoryRequest getRequestInventory() { return this.requests; } public IInventory getInventory() { - return (IInventory) this.requests.getCraftingSlots(); + return (IInventory) this.requests.getRequestStacks(); } public void updateQuantity(int idx, long size) { @@ -166,71 +181,120 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven this.requests.updateBatchSize(idx, size); } + private void readLinkFromNBT(NBTTagCompound data) { + try { + for (int i = 0; i < this.requests.getLinks().length; i++) { + final NBTTagCompound link = data.getCompoundTag("links-" + i); + if (link != null && link.hasNoTags()) { + this.requests.getLinks()[i] = null; + } else { + this.requests.getLinks()[i] = AEApi.instance().storage().loadCraftingLink(link, this); + } + } + } catch (Exception e) { + // :P You don't have job to do XD + } + } + + private NBTTagCompound writeLinkToNBT(NBTTagCompound data) { + for (int i = 0; i < this.requests.getLinks().length; i++) { + if (this.requests.getLinks()[i] != null) { + CraftingLink link = (CraftingLink) this.requests.getLinks()[i]; + NBTTagCompound linkData = new NBTTagCompound(); + link.writeToNBT(linkData); + data.setTag("links-" + i, linkData); + } + } + return data; + } + @TileEvent(TileEventType.WORLD_NBT_WRITE) public NBTTagCompound writeToNBTEvent(NBTTagCompound data) { - this.requests.crafting.writeToNbt(data, "Inventory"); - this.requests.batchSize.writeToNbt(data, "BatchSize"); - return data; + this.requests.requestStacks.writeToNbt(data, "Inventory"); + this.requests.requestBatches.writeToNbt(data, "Batch"); + this.requests.requestQtys.writeToNbt(data, "Count"); + return writeLinkToNBT(data); } @TileEvent(TileEventType.WORLD_NBT_READ) public void readFromNBTEvent(NBTTagCompound data) { - this.requests.crafting.readFromNbt(data, "Inventory"); - this.requests.batchSize.readFromNbt(data, "BatchSize"); + this.requests.requestStacks.readFromNbt(data, "Inventory"); + this.requests.requestBatches.readFromNbt(data, "Batch"); + this.requests.requestQtys.readFromNbt(data, "Count"); + this.readLinkFromNBT(data); } public static class InventoryRequest { - private final AeStackInventoryImpl crafting; - private final AeStackInventoryImpl batchSize; - private Future[] jobs; - private ICraftingLink[] links; + private final AeStackInventoryImpl requestStacks; + private final AeStackInventoryImpl requestBatches; + private final AeStackInventoryImpl requestQtys; + private final Future[] jobs; + private final ICraftingLink[] links; public InventoryRequest(TileLevelMaintainer tile) { - this.crafting = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); - this.batchSize = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); + this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); + this.requestBatches = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); + this.requestQtys = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile); this.jobs = new Future[REQ_COUNT]; this.links = new ICraftingLink[REQ_COUNT]; } + public boolean isDone(int index) { + if (this.getLinks()[index] != null) { + return this.getLinks()[index].isDone() || this.getLinks()[index].isCanceled(); + } + return true; + } + public Future[] getJobs() { - return jobs; + return this.jobs; } public ICraftingLink[] getLinks() { return links; } - public AeStackInventory getBatchInputs() { - return this.batchSize; + public AeStackInventory getRequestQtys() { + return this.requestQtys; } - public AeStackInventory getCraftingSlots() { - return this.crafting; + public AeStackInventory getRequestBatches() { + return this.requestBatches; + } + + public AeStackInventory getRequestStacks() { + return this.requestStacks; } public void updateQuantity(int idx, long size) { - IAEItemStack is = this.crafting.getStack(idx); + IAEItemStack is = this.getRequestStacks().getStack(idx); if (is != null) { - is.setStackSize(size); + IAEItemStack i = is.copy(); + i.setStackSize(size); + this.getRequestQtys().setStack(idx, i); } } public void updateBatchSize(int idx, long size) { - IAEItemStack is = this.crafting.getStack(idx); + IAEItemStack is = this.getRequestStacks().getStack(idx); if (is != null) { IAEItemStack i = is.copy(); i.setStackSize(size); - this.batchSize.setStack(idx, i); + this.getRequestBatches().setStack(idx, i); } } public IAEItemStack getQuantity(int idx) { - return this.crafting.getStack(idx); + IAEItemStack is = this.getRequestStacks().getStack(idx); + if (is == null) return null; + IAEItemStack qis = this.getRequestQtys().getStack(idx); + if (qis == null || !is.isSameType(qis)) return null; + return this.getRequestQtys().getStack(idx); } public long getBatchSize(int idx) { - IAEItemStack is = this.crafting.getStack(idx); - IAEItemStack is1 = this.batchSize.getStack(idx); + IAEItemStack is = this.getRequestStacks().getStack(idx); + IAEItemStack is1 = this.getRequestBatches().getStack(idx); if (is != null && is1 != null && is.isSameType(is1)) { return is1.getStackSize(); } @@ -238,7 +302,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } public IAEItemStack getCraftItem(int idx) { - IAEItemStack is = this.crafting.getStack(idx); + IAEItemStack is = this.getQuantity(idx); if (is != null) { IAEItemStack ias = is.copy(); ias.setStackSize(this.getBatchSize(idx)); diff --git a/src/main/java/com/glodblock/github/loader/RecipeLoader.java b/src/main/java/com/glodblock/github/loader/RecipeLoader.java index a464276f..7ea8bb96 100644 --- a/src/main/java/com/glodblock/github/loader/RecipeLoader.java +++ b/src/main/java/com/glodblock/github/loader/RecipeLoader.java @@ -35,6 +35,8 @@ public class RecipeLoader implements Runnable { public final static ItemStack PISTON = new ItemStack(Blocks.piston, 1); public final static ItemStack AE2_BLANK_PATTERN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 52); public final static ItemStack AE2_TERMINAL = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 380); + public final static ItemStack AE2_CRAFTING_CP_UNIT = new ItemStack(GameRegistry.findItem("appliedenergistics2", "tile.BlockCraftingUnit"), 1, 1); + public final static ItemStack AE2_PATTERN_CAPACITY_CARD = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 54); public final static ItemStack BUCKET = new ItemStack(Items.bucket, 1); public final static ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1); @@ -52,6 +54,7 @@ public class RecipeLoader implements Runnable { GameRegistry.addRecipe(new ShapedOreRecipe(LARGE_BUFFER.stack(), "BGB", "GEG", "BGB", 'B', BUFFER.stack(), 'G', AE2_QUARTZ_GLASS, 'E', AE2_PROCESS_ENG)); GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN, PATTERN.stack()); GameRegistry.addShapelessRecipe(FLUID_TERM.stack(), AE2_TERMINAL, BUFFER); + GameRegistry.addShapelessRecipe(LEVEL_MAINTAINER.stack(), AE2_CRAFTING_CP_UNIT, ENCODER, AE2_PATTERN_CAPACITY_CARD); if (Config.fluidCells) { OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS); for (ItemStack it : OreDictionary.getOres("crystalCertusQuartz")) diff --git a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java index a383cd9e..a4a37b52 100644 --- a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java @@ -42,10 +42,10 @@ public class CPacketLevelMaintainer implements IMessage { this.size = Long.parseLong(size); } - public static IAEItemStack setTag(IAEItemStack ias, long size, int slotIndex) { + public static IAEItemStack setTag(IAEItemStack ias, long batch, int slotIndex) { NBTTagCompound data = new NBTTagCompound(); ItemStack is = ias.getItemStack(); - data.setLong("BatchSize", size); + data.setLong("Batch", batch); data.setLong("Index", slotIndex); is.setTagCompound(data); IAEItemStack iaeItemStack = AEItemStack.create(is); @@ -78,8 +78,8 @@ public class CPacketLevelMaintainer implements IMessage { if (message.action == -1) { SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(false); for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { - IAEItemStack is = cca.getTile().requests.getCraftingSlots().getStack(i); - IAEItemStack is1 = cca.getTile().requests.getBatchInputs().getStack(i); + IAEItemStack is = cca.getTile().requests.getQuantity(i); + IAEItemStack is1 = cca.getTile().requests.getRequestBatches().getStack(i); if (is != null) { piu.appendItem(setTag(is, is1 != null ? is1.getStackSize() : 0, i)); } diff --git a/src/main/resources/assets/ae2fc/lang/en_US.lang b/src/main/resources/assets/ae2fc/lang/en_US.lang index 5c9a862d..43fbe7c9 100644 --- a/src/main/resources/assets/ae2fc/lang/en_US.lang +++ b/src/main/resources/assets/ae2fc/lang/en_US.lang @@ -49,8 +49,8 @@ ae2fc.tooltip.not_prio=Allow fluids to be placed first ae2fc.tooltip.not_prio.hint=Enabled ae2fc.tooltip.prio=Allow fluids to be placed first ae2fc.tooltip.prio.hint=Disabled -ae2fc.tooltip.submit=Submit -ae2fc.tooltip.submit.hint=Submit Request +ae2fc.tooltip.submit=Submit Request +ae2fc.tooltip.submit.hint=Submit ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal diff --git a/src/main/resources/assets/ae2fc/lang/zh_CN.lang b/src/main/resources/assets/ae2fc/lang/zh_CN.lang index 12123dab..67137050 100644 --- a/src/main/resources/assets/ae2fc/lang/zh_CN.lang +++ b/src/main/resources/assets/ae2fc/lang/zh_CN.lang @@ -49,8 +49,8 @@ ae2fc.tooltip.not_prio=优先放置流体 ae2fc.tooltip.not_prio.hint=启用 ae2fc.tooltip.prio=优先放置流体 ae2fc.tooltip.prio.hint=禁用 -ae2fc.tooltip.submit=提交 -ae2fc.tooltip.submit.hint=提交请求 +ae2fc.tooltip.submit=提交请求 +ae2fc.tooltip.submit.hint=提交 ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端 ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端 From 244e7fb4f8707a4c3458b572ae3a6cc16633b5dc Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Fri, 11 Nov 2022 13:47:43 +0800 Subject: [PATCH 6/7] Level Maintainer add control button Level Maintainer add oc support fix Level Maintainer render error --- .../github/client/gui/GuiFCImgButton.java | 59 +++-- .../github/client/gui/GuiLevelMaintainer.java | 189 ++++++++++------ .../container/ContainerLevelMaintainer.java | 9 - .../render/RenderBlockLevelMaintainer.java | 36 +++ .../client/textures/FCPartsTexture.java | 2 +- .../common/block/BlockLevelMaintainer.java | 9 + .../common/tile/TileLevelMaintainer.java | 129 ++++++++++- .../opencomputers/DriverLevelMaintainer.java | 212 ++++++++++++++++++ .../crossmod/opencomputers/OCDriverInit.java | 2 + .../network/CPacketLevelMaintainer.java | 77 +++++-- .../resources/assets/ae2fc/lang/en_US.lang | 5 +- .../resources/assets/ae2fc/lang/zh_CN.lang | 5 +- ...Active.png => level_maintainer_active.png} | Bin .../assets/ae2fc/textures/gui/states.png | Bin 1106 -> 1695 bytes 14 files changed, 592 insertions(+), 142 deletions(-) create mode 100644 src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java create mode 100644 src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java rename src/main/resources/assets/ae2fc/textures/blocks/{level_maintainerActive.png => level_maintainer_active.png} (100%) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java index c5038af9..60bbca6d 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java @@ -40,16 +40,21 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio"); this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio"); this.registerApp(4, "SUBMIT", "SUBMIT", "submit"); + this.registerApp(6, "DISABLE", "DISABLE", "disable"); + this.registerApp(7, "ENABLE", "ENABLE", "enable"); } } - private void registerApp(final int iconIndex, final String setting, final String val, final String title ) - { + private void registerApp(final int iconIndex, final String setting, final String val, final String title ) { final ButtonAppearance a = new ButtonAppearance(); a.displayName = StatCollector.translateToLocal(prefix + title); - a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint"); + if (StatCollector.translateToLocal(prefix + title + ".hint").equals(prefix + title + ".hint")) { + a.displayValue = null; + } else { + a.displayValue = StatCollector.translateToLocal(prefix + title + ".hint"); + } a.index = iconIndex; - appearances.put( new EnumPair( setting, val ), a ); + appearances.put(new EnumPair(setting, val), a); } public void setVisibility( final boolean vis ) @@ -157,39 +162,31 @@ public class GuiFCImgButton extends GuiButton implements ITooltip { displayValue = buttonAppearance.displayValue; } - if( displayName != null ) - { - String name = StatCollector.translateToLocal( displayName ); - String value = StatCollector.translateToLocal( displayValue ); - - if( name == null || name.isEmpty() ) - { + if( displayName != null ) { + String name = StatCollector.translateToLocal(displayName); + if (name == null || name.isEmpty()) { name = displayName; } - if( value == null || value.isEmpty() ) - { - value = displayValue; - } + if (displayValue != null) { + String value = StatCollector.translateToLocal(displayValue); - if( this.fillVar != null ) - { - value = COMPILE.matcher( value ).replaceFirst( this.fillVar ); - } + if (this.fillVar != null) { + value = COMPILE.matcher(value).replaceFirst(this.fillVar); + } - value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); - final StringBuilder sb = new StringBuilder( value ); + value = PATTERN_NEW_LINE.matcher(value).replaceAll("\n"); + final StringBuilder sb = new StringBuilder(value); - int i = sb.lastIndexOf( "\n" ); - if( i <= 0 ) - { - i = 0; + int i = sb.lastIndexOf("\n"); + if (i <= 0) { + i = 0; + } + while (i + 30 < sb.length() && (i = sb.lastIndexOf(" ", i + 30)) != -1) { + sb.replace(i, i + 1, "\n"); + } + return name + '\n' + sb; } - while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) - { - sb.replace( i, i + 1, "\n" ); - } - - return name + '\n' + sb; + return name; } return null; } diff --git a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java index b7f4468c..ff6cbefd 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiLevelMaintainer.java @@ -37,8 +37,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/level_maintainer.png"); private final ContainerLevelMaintainer cont; - private final Widget[] qtyInputs = new Widget[TileLevelMaintainer.REQ_COUNT]; - private final Widget[] batchInputs = new Widget[TileLevelMaintainer.REQ_COUNT]; + private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT]; private final MouseRegionManager mouseRegions = new MouseRegionManager(this); private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this); private TileLevelMaintainer tile; @@ -56,19 +55,19 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { for (IAEItemStack is : list) { long size = is.getItemStack().getTagCompound().getLong("Batch"); int i = is.getItemStack().getTagCompound().getInteger("Index"); - qtyInputs[i].textField.setText(String.valueOf(is.getStackSize())); - batchInputs[i].textField.setText(String.valueOf(size)); + boolean isEnable = is.getItemStack().getTagCompound().getBoolean("Enable"); + component[i].getQty().textField.setText(String.valueOf(is.getStackSize())); + component[i].getBatch().textField.setText(String.valueOf(size)); + component[i].setEnable(isEnable); } } public void drawScreen(final int mouseX, final int mouseY, final float btn) { super.drawScreen(mouseX, mouseY, btn); if (ModAndClassUtil.isSearchBar) { - for (Widget i : qtyInputs) { - handleTooltip(mouseX, mouseY, i.textField.new TooltipProvider()); - } - for (Widget i : batchInputs) { - handleTooltip(mouseX, mouseY, i.textField.new TooltipProvider()); + for (Component com : this.component) { + handleTooltip(mouseX, mouseY, com.getQty().textField.new TooltipProvider()); + handleTooltip(mouseX, mouseY, com.getBatch().textField.new TooltipProvider()); } } } @@ -76,19 +75,21 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { public void initGui() { super.initGui(); for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { - qtyInputs[i] = new Widget( - new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16), - new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_REQUEST_SIZE), - i, 0); - this.buttonList.add(qtyInputs[i].btn()); - batchInputs[i] = new Widget( - new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16), - new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_BATCH_SIZE), - i, 1 + component[i] = new Component( + new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_REQUEST_SIZE), + i, "TileLevelMaintainer.Quantity"), + new Widget( + new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16), + new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"), I18n.format(NameConst.TT_BATCH_SIZE), + i, "TileLevelMaintainer.Batch"), + new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"), + new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"), + this.buttonList ); - this.buttonList.add(batchInputs[i].btn()); } - FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(-1)); + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh")); } @Override @@ -96,8 +97,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { mc.getTextureManager().bindTexture(TEX_BG); drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize); for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { - qtyInputs[i].draw(); - batchInputs[i].draw(); + this.component[i].draw(); } } @@ -119,8 +119,8 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { super.func_146977_a(new SlotSingleItem(slot)); if (stack == null) return true; IAEItemStack fake = stack.copy(); - if (this.qtyInputs[slot.getSlotIndex()].textField.getText().matches("[0-9]+")) { - fake.setStackSize(Long.parseLong(this.qtyInputs[slot.getSlotIndex()].textField.getText())); + if (this.component[slot.getSlotIndex()].getQty().textField.getText().matches("[0-9]+")) { + fake.setStackSize(Long.parseLong(this.component[slot.getSlotIndex()].getQty().textField.getText())); } else { fake.setStackSize(0); } @@ -137,18 +137,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { if (input != null) { input.setFocused(false); } - for (Widget i : qtyInputs) { - if (i.textField.isMouseIn(xCoord, yCoord)) { - i.textField.setFocused(true); - this.input = i.textField; - super.mouseClicked(xCoord, yCoord, btn); - return; - } - } - for (Widget i : batchInputs) { - if (i.textField.isMouseIn(xCoord, yCoord)) { - i.textField.setFocused(true); - this.input = i.textField; + for (Component com : this.component) { + FCGuiTextField textField = com.isMouseIn(xCoord, yCoord); + if (textField != null) { + textField.setFocused(true); + this.input = textField; super.mouseClicked(xCoord, yCoord, btn); return; } @@ -169,7 +162,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { this.input.textboxKeyTyped(character, key); } super.keyTyped(character, key); - if (!this.input.getText().matches("[0-9]+")) { + if (!this.input.getText().matches("^[0-9]+")) { this.input.setTextColor(0xFF0000); } else { this.input.setTextColor(0xFFFFFF); @@ -184,44 +177,23 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { @Override protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) { if (slot instanceof ContainerLevelMaintainer.FakeSlot && this.cont.getPlayerInv().getItemStack() != null) { - this.qtyInputs[slot.getSlotIndex()].textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); + this.component[slot.getSlotIndex()].getQty().textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize)); return; } super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); } public void updateAmount(int idx, int stackSize) { - this.qtyInputs[idx].textField.setText(String.valueOf(stackSize)); + this.component[idx].getQty().textField.setText(String.valueOf(stackSize)); } - private boolean sendToServer(Widget widget) { - if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) { - if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("[0-9]+")) { - widget.textField.setText(widget.textField.getText().replaceAll("^(0+)", "")); - FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); - widget.textField.setTextColor(0xFFFFFF); - return true; - } else { - widget.textField.setTextColor(0xFF0000); - return false; - } - } - return false; - } @Override protected void actionPerformed(final GuiButton btn) { super.actionPerformed(btn); - for (Widget widget : qtyInputs) { - if (widget.button == btn) { - sendToServer(widget); - return; - } - } - for (Widget widget : batchInputs) { - if (widget.button == btn) { - sendToServer(widget); - return; + for (Component com : this.component) { + if (com.sendToServer(btn)) { + break; } } } @@ -269,13 +241,100 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler { return false; } + private class Component { + public boolean isEnable = true; + private Widget qty; + private Widget batch; + private GuiFCImgButton disable; + private GuiFCImgButton enable; + + public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton enableBtn, GuiFCImgButton disableBtn, List buttonList) { + this.qty = qtyInput; + this.batch = batchInput; + this.enable = enableBtn; + this.disable = disableBtn; + this.enable.setHalfSize(true); + this.disable.setHalfSize(true); + buttonList.add(this.qty.button); + buttonList.add(this.batch.button); + buttonList.add(this.enable); + buttonList.add(this.disable); + } + + public int getIndex() { + return this.getQty().idx; + } + + public void setEnable(boolean enable) { + this.isEnable = enable; + } + + private boolean send(Widget widget) { + if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) { + if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) { + String str = widget.textField.getText().replaceAll("^(0+)", ""); + widget.textField.setText(str.isEmpty() ? "0" : str); + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText())); + widget.textField.setTextColor(0xFFFFFF); + return true; + } else { + widget.textField.setTextColor(0xFF0000); + return false; + } + } + return false; + } + + protected boolean sendToServer(GuiButton btn) { + if (this.getQty().button == btn) { + return this.send(this.getQty()); + } + if (this.getBatch().button == btn) { + return this.send(this.getBatch()); + } + if (this.enable == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex())); + } else if (this.disable == btn) { + FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex())); + } + return false; + } + + public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) { + if (this.getQty().textField.isMouseIn(xCoord, yCoord)) return this.getQty().textField; + if (this.getBatch().textField.isMouseIn(xCoord, yCoord)) return this.getBatch().textField; + return null; + } + + public Widget getQty() { + return this.qty; + } + + public Widget getBatch() { + return this.batch; + } + + public void draw() { + this.getQty().draw(); + this.getBatch().draw(); + if (this.isEnable) { + this.enable.visible = true; + this.disable.visible = false; + } else { + this.enable.visible = false; + this.disable.visible = true; + } + } + + } + private class Widget { public final int idx; - public final int action; + public final String action; private FCGuiTextField textField; private GuiFCImgButton button; - public Widget(FCGuiTextField textField, GuiFCImgButton button, String tooltip, int idx, int action) { + public Widget(FCGuiTextField textField, GuiFCImgButton button, String tooltip, int idx, String action) { this.textField = textField; this.textField.setMessage(tooltip); this.textField.setEnableBackgroundDrawing(false); diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java index 71337aef..3be49d0c 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerLevelMaintainer.java @@ -46,15 +46,6 @@ public class ContainerLevelMaintainer extends AEBaseContainer { return null; } - - public void handleClientInteraction(int action, int idx, long size) { - if (action == 0) { - tile.updateQuantity(idx, size); - } else if (action == 1) { - tile.updateBatchSize(idx, size); - } - } - public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake { public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) { diff --git a/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java b/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java new file mode 100644 index 00000000..24d23c78 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/render/RenderBlockLevelMaintainer.java @@ -0,0 +1,36 @@ +package com.glodblock.github.client.render; + +import appeng.client.render.BaseBlockRender; +import appeng.client.render.BlockRenderInfo; +import com.glodblock.github.client.textures.FCPartsTexture; +import com.glodblock.github.common.block.BlockLevelMaintainer; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class RenderBlockLevelMaintainer extends BaseBlockRender { + + public RenderBlockLevelMaintainer() { + super(false, 20); + } + + + @Override + public boolean renderInWorld(final BlockLevelMaintainer block, final IBlockAccess world, final int x, final int y, final int z, final RenderBlocks renderer) { + final TileLevelMaintainer ti = block.getTileEntity(world, x, y, z); + final BlockRenderInfo info = block.getRendererInstance(); + + if (ti != null && ti.isActive()) { + final IIcon activeIcon = FCPartsTexture.BlockLevelMaintainer_Active.getIcon(); + final IIcon side = FCPartsTexture.BlockLevelMaintainer.getIcon(); + info.setTemporaryRenderIcons(side, side, activeIcon, side, side, side); + } + + final boolean fz = super.renderInWorld(block, world, x, y, z, renderer); + + info.setTemporaryRenderIcon(null); + + return fz; + } +} diff --git a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java index db2f9d6b..5be5b3eb 100644 --- a/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java +++ b/src/main/java/com/glodblock/github/client/textures/FCPartsTexture.java @@ -14,7 +14,7 @@ public enum FCPartsTexture { PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"), PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"), BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), BlockInterfaceAlternate("fluid_interface_a"), - BlockInterface_Face("fluid_interface"), BlockLevelMaintainer("level_maintainer"); + BlockInterface_Face("fluid_interface"), BlockLevelMaintainer("level_maintainer"), BlockLevelMaintainer_Active("level_maintainer_active"); private final String name; public net.minecraft.util.IIcon IIcon; diff --git a/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java b/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java index c853bf9d..8f726bac 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/common/block/BlockLevelMaintainer.java @@ -1,6 +1,7 @@ package com.glodblock.github.common.block; import appeng.block.AEBaseItemBlock; +import com.glodblock.github.client.render.RenderBlockLevelMaintainer; import com.glodblock.github.common.tabs.FluidCraftingTabs; import com.glodblock.github.common.tile.TileLevelMaintainer; import com.glodblock.github.inventory.InventoryHandler; @@ -8,6 +9,8 @@ import com.glodblock.github.inventory.gui.GuiType; import com.glodblock.github.util.BlockPos; import com.glodblock.github.util.NameConst; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -30,6 +33,12 @@ public class BlockLevelMaintainer extends FCBaseBlock { return this; } + @Override + @SideOnly(Side.CLIENT) + protected RenderBlockLevelMaintainer getRenderer() { + return new RenderBlockLevelMaintainer(); + } + @Override public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { diff --git a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java index ee19d286..bdfbe672 100644 --- a/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/common/tile/TileLevelMaintainer.java @@ -3,6 +3,7 @@ package com.glodblock.github.common.tile; import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.PowerMultiplier; +import appeng.api.implementations.IPowerChannelState; import appeng.api.networking.GridFlags; import appeng.api.networking.IGrid; import appeng.api.networking.IGridNode; @@ -11,6 +12,9 @@ import appeng.api.networking.crafting.ICraftingJob; import appeng.api.networking.crafting.ICraftingLink; import appeng.api.networking.crafting.ICraftingRequester; import appeng.api.networking.energy.IEnergyGrid; +import appeng.api.networking.events.MENetworkBootingStatusChange; +import appeng.api.networking.events.MENetworkEventSubscribe; +import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.networking.security.BaseActionSource; import appeng.api.networking.security.MachineSource; import appeng.api.networking.ticking.IGridTickable; @@ -29,22 +33,26 @@ import appeng.tile.events.TileEventType; import appeng.tile.grid.AENetworkTile; import appeng.tile.inventory.IAEAppEngInventory; import appeng.tile.inventory.InvOperation; +import appeng.util.item.AEItemStack; import com.glodblock.github.common.item.ItemFluidDrop; +import com.glodblock.github.inventory.AeItemStackHandler; import com.glodblock.github.inventory.AeStackInventory; import com.glodblock.github.inventory.AeStackInventoryImpl; import com.google.common.collect.ImmutableSet; +import io.netty.buffer.ByteBuf; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import java.util.concurrent.Future; -public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IGridTickable, ICraftingRequester { +public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState { public static final int REQ_COUNT = 5; public final InventoryRequest requests = new InventoryRequest(this); private final BaseActionSource source; - + private final IInventory inv = new AeItemStackHandler(requests.getRequestStacks()); + private boolean isPowered = false; public TileLevelMaintainer() { getProxy().setIdlePowerUsage(1D); @@ -103,6 +111,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) { return this.canDoBusWork() ? this.doWork() : TickRateModulation.IDLE; } + private TickRateModulation doWork() { if (!this.getProxy().isActive() || !this.canDoBusWork()) { return TickRateModulation.IDLE; @@ -113,7 +122,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven IGrid grid = this.getProxy().getGrid(); final IItemList inv = this.getProxy().getStorage().getItemInventory().getStorageList(); for (int i = 0; i < REQ_COUNT; i++) { - IAEItemStack is = requests.getQuantity(i); + IAEItemStack is = requests.getRequestQtyStack(i); if (is != null && requests.getBatchSize(i) > 0) { IAEItemStack craftItem = requests.getCraftItem(i); if (cg.canEmitFor(craftItem) || cg.isRequesting(craftItem) || @@ -165,12 +174,27 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven return this.getProxy().isActive(); } + @Override + public void gridChanged() { + + } + + @Override + public boolean isPowered() { + return this.isPowered; + } + + @Override + public boolean isActive() { + return this.isPowered; + } + public InventoryRequest getRequestInventory() { return this.requests; } public IInventory getInventory() { - return (IInventory) this.requests.getRequestStacks(); + return inv; } public void updateQuantity(int idx, long size) { @@ -181,6 +205,10 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven this.requests.updateBatchSize(idx, size); } + public void setRequestStatus(int idx, boolean enable) { + this.requests.setEnable(idx, enable); + } + private void readLinkFromNBT(NBTTagCompound data) { try { for (int i = 0; i < this.requests.getLinks().length; i++) { @@ -224,6 +252,45 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven this.readLinkFromNBT(data); } + @TileEvent(TileEventType.NETWORK_READ) + public boolean readFromStream(final ByteBuf data) { + final boolean oldPower = this.isPowered; + this.isPowered = data.readBoolean(); + return this.isPowered != oldPower; + } + + @TileEvent(TileEventType.NETWORK_WRITE) + public void writeToStream(final ByteBuf data) { + data.writeBoolean(this.isActive()); + } + + @MENetworkEventSubscribe + public void stateChange(final MENetworkPowerStatusChange p) { + this.updatePowerState(); + } + + @MENetworkEventSubscribe + public final void bootingRender(final MENetworkBootingStatusChange c) { + this.updatePowerState(); + } + + private void updatePowerState() { + boolean newState = false; + + try { + newState = this.getProxy().isActive() + && this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) + > 0.0001; + } catch (final GridAccessException ignored) { + + } + + if (newState != this.isPowered) { + this.isPowered = newState; + this.markForUpdate(); + } + } + public static class InventoryRequest { private final AeStackInventoryImpl requestStacks; private final AeStackInventoryImpl requestBatches; @@ -239,6 +306,35 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven this.links = new ICraftingLink[REQ_COUNT]; } + public void setEnable(int idx, boolean enable) { + IAEItemStack ias = this.getRequestStacks().getStack(idx); + IAEItemStack ias1 = this.getRequestBatches().getStack(idx); + if (ias != null && ias1 != null) { + ItemStack is = ias1.getItemStack(); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("Enable", enable); + is.setTagCompound(data); + IAEItemStack i = AEItemStack.create(is); + i.setStackSize(ias1.getStackSize()); + this.getRequestBatches().setStack(idx, i); + } + } + + public boolean isEnable(int idx) { + IAEItemStack ias = this.getRequestBatches().getStack(idx); + if (ias != null) { + ItemStack is = ias.getItemStack(); + try { + return is.getTagCompound().getBoolean("Enable"); + } catch (NullPointerException e) { + // support old version + return true; + } + } else { + return true; + } + } + public boolean isDone(int index) { if (this.getLinks()[index] != null) { return this.getLinks()[index].isDone() || this.getLinks()[index].isCanceled(); @@ -276,15 +372,19 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven } public void updateBatchSize(int idx, long size) { - IAEItemStack is = this.getRequestStacks().getStack(idx); - if (is != null) { - IAEItemStack i = is.copy(); + IAEItemStack ias = this.getRequestStacks().getStack(idx); + if (ias != null) { + ItemStack is = ias.copy().getItemStack(); + NBTTagCompound data = new NBTTagCompound(); + data.setBoolean("Enable", true); + is.setTagCompound(data); + IAEItemStack i = AEItemStack.create(is); i.setStackSize(size); this.getRequestBatches().setStack(idx, i); } } - public IAEItemStack getQuantity(int idx) { + public IAEItemStack getRequestQtyStack(int idx) { IAEItemStack is = this.getRequestStacks().getStack(idx); if (is == null) return null; IAEItemStack qis = this.getRequestQtys().getStack(idx); @@ -292,17 +392,26 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven return this.getRequestQtys().getStack(idx); } + public long getQuantity(int idx) { + IAEItemStack ias = this.getRequestQtyStack(idx); + if (ias == null) { + return 0; + } + return ias.getStackSize(); + } + public long getBatchSize(int idx) { + if (!this.isEnable(idx)) return 0; IAEItemStack is = this.getRequestStacks().getStack(idx); IAEItemStack is1 = this.getRequestBatches().getStack(idx); - if (is != null && is1 != null && is.isSameType(is1)) { + if (is != null && is1 != null) { return is1.getStackSize(); } return 0; } public IAEItemStack getCraftItem(int idx) { - IAEItemStack is = this.getQuantity(idx); + IAEItemStack is = this.getRequestQtyStack(idx); if (is != null) { IAEItemStack ias = is.copy(); ias.setStackSize(this.getBatchSize(idx)); diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java new file mode 100644 index 00000000..dc884b49 --- /dev/null +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/DriverLevelMaintainer.java @@ -0,0 +1,212 @@ +package com.glodblock.github.crossmod.opencomputers; + +import appeng.util.item.AEItemStack; +import com.glodblock.github.common.item.ItemFluidDrop; +import com.glodblock.github.common.tile.TileLevelMaintainer; +import com.glodblock.github.inventory.AeItemStackHandler; +import com.glodblock.github.loader.ItemAndBlockHolder; +import com.glodblock.github.util.NameConst; +import cpw.mods.fml.common.registry.GameRegistry; +import li.cil.oc.api.driver.EnvironmentProvider; +import li.cil.oc.api.driver.NamedBlock; +import li.cil.oc.api.internal.Database; +import li.cil.oc.api.machine.Arguments; +import li.cil.oc.api.machine.Callback; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.Component; +import li.cil.oc.api.network.ManagedEnvironment; +import li.cil.oc.api.network.Node; +import li.cil.oc.api.prefab.DriverSidedTileEntity; +import li.cil.oc.integration.ManagedTileEntityEnvironment; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.HashMap; +import java.util.Map; + + +public class DriverLevelMaintainer extends DriverSidedTileEntity { + @Override + public Class getTileEntityClass() { + return TileLevelMaintainer.class; + } + + @Override + public ManagedEnvironment createEnvironment(World world, int x, int y, int z, ForgeDirection forgeDirection) { + return new DriverLevelMaintainer.Environment((TileLevelMaintainer) world.getTileEntity(x, y, z)); + } + + public static class Environment extends ManagedTileEntityEnvironment + implements NamedBlock { + + public Environment(TileLevelMaintainer tileEntity) { + super(tileEntity, NameConst.BLOCK_LEVEL_MAINTAINER); + } + + private int getSlot(Arguments args, IInventory inv, int index, int def) { + if (index >= 0 && index < args.count()) { + int slot = args.checkInteger(index) - 1; + if (slot < 0 || slot >= inv.getSizeInventory()) { + throw new IllegalArgumentException("Invalid slot"); + } + return slot; + } else { + return def; + } + } + + private boolean isDone(Arguments args) { + int slot = args.checkInteger(0) - 1; + if (slot < 0 || slot >= TileLevelMaintainer.REQ_COUNT) { + throw new IllegalArgumentException("Invalid slot"); + } + return tileEntity.requests.isDone(slot); + } + + private boolean isEnable(Arguments args) { + int slot = args.checkInteger(0) - 1; + if (slot < 0 || slot >= TileLevelMaintainer.REQ_COUNT) { + throw new IllegalArgumentException("Invalid slot"); + } + return tileEntity.requests.isEnable(slot); + } + + private boolean setEnable(Arguments args) { + if (args.count() != 2) { + throw new IllegalArgumentException("Invalid args!"); + } else { + int slot = args.checkInteger(0) - 1; + if (slot < 0 || slot >= TileLevelMaintainer.REQ_COUNT) { + throw new IllegalArgumentException("Invalid slot"); + } + boolean enable = args.checkBoolean(1); + tileEntity.requests.setEnable(slot, enable); + return true; + } + } + + private void updateOrder(int slot, int quantity, int batch) { + tileEntity.updateQuantity(slot, quantity); + tileEntity.updateBatchSize(slot, batch); + } + + @Callback(doc = "function([slot:number]):table -- Get the slot status.") + public Object[] getSlot(Context context, Arguments args) { + IInventory config = tileEntity.getInventory(); + int slot = getSlot(args, config, 0, 0); + ItemStack stack = config.getStackInSlot(slot); + if (stack != null) { + Map result = new HashMap<>(); + result.put("damage", stack.getItemDamage()); + result.put("hasTag", stack.hasTagCompound()); + result.put("label", stack.getDisplayName()); + result.put("maxDamage", stack.getMaxDamage()); + result.put("name", GameRegistry.findUniqueIdentifierFor(stack.getItem()).toString()); + result.put("quantity", tileEntity.requests.getQuantity(slot)); + result.put("batch", tileEntity.requests.getBatchSize(slot)); + result.put("isFluid", ItemFluidDrop.isFluidStack(stack)); + if (ItemFluidDrop.isFluidStack(stack)) result.put("fluid", ItemFluidDrop.getFluidStack(stack)); + result.put("isEnable", tileEntity.requests.isEnable(slot)); + result.put("isDone", tileEntity.requests.isDone(slot)); + return new Object[]{result}; + } + return new Object[]{null}; + } + + private void setSlot(int slot, String address, int index) { + Node node = node().network().node(address); + if (node instanceof Component) { + if (node.host() instanceof Database) { + ItemStack dbStack = ((Database) node.host()).getStackInSlot(index); + if (dbStack == null) { + throw new IllegalArgumentException("Invalid slot"); + } + dbStack.stackSize = 1; + ((AeItemStackHandler) tileEntity.getInventory()).getAeInventory().setStack(slot, AEItemStack.create(dbStack)); + } else { + throw new IllegalArgumentException("Not a database"); + } + } else { + throw new IllegalArgumentException("No such component"); + } + } + + @Callback(doc = "function(slot:number[,database:address[,index:number]],quantity:number,batch:number):boolean -- Configuration the slot.") + public Object[] setSlot(Context context, Arguments args) { + int slot; + String address; + int index; + int quantity; + int batch; + slot = args.checkInteger(0) - 1; + + if (slot < 0 || slot >= TileLevelMaintainer.REQ_COUNT) { + throw new IllegalArgumentException("Invalid slot"); + } + if (args.count() == 5) { + address = args.checkString(1); + index = args.checkInteger(2) - 1; + quantity = args.checkInteger(3); + batch = args.checkInteger(4); + setSlot(slot, address, index); + updateOrder(slot, quantity, batch); + } else if (args.count() == 3) { + quantity = args.checkInteger(1); + batch = args.checkInteger(2); + updateOrder(slot, quantity, batch); + } else { + throw new IllegalArgumentException("Invalid args"); + } + return new Object[]{true}; + } + + private boolean isActive() { + return tileEntity.isActive(); + } + + @Callback(doc = "function(slot:number):boolean -- Get the crafting task state.") + public Object[] isDone(Context context, Arguments args) { + return new Object[]{this.isDone(args)}; + } + + @Callback(doc = "function(slot:number):boolean -- Get the crafting state of slot.") + public Object[] isEnable(Context context, Arguments args) { + return new Object[]{this.isEnable(args)}; + } + + @Callback(doc = "function(slot:number,value:boolean):boolean -- Set the crafting state of slot.") + public Object[] setEnable(Context context, Arguments args) { + return new Object[]{this.setEnable(args)}; + } + + @Callback(doc = "function():boolean Get Level Maintainer state") + public Object[] active(Context context, Arguments args) { + return new Object[]{this.isActive()}; + } + + @Override + public String preferredName() { + return NameConst.BLOCK_LEVEL_MAINTAINER; + } + + @Override + public int priority() { + return 6; + } + } + + public static class Provider implements EnvironmentProvider { + Provider() { + } + + @Override + public Class getEnvironment(ItemStack itemStack) { + if (itemStack != null && itemStack.isItemEqual(ItemAndBlockHolder.LEVEL_MAINTAINER.stack())) { + return DriverLevelMaintainer.Environment.class; + } + return null; + } + } +} diff --git a/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java b/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java index 35cd6554..50192001 100644 --- a/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java +++ b/src/main/java/com/glodblock/github/crossmod/opencomputers/OCDriverInit.java @@ -7,6 +7,8 @@ public class OCDriverInit { public static void run() { Driver.add(new DriverOCPatternEditor()); Driver.add(new DriverOCPatternEditor.Provider()); + Driver.add(new DriverLevelMaintainer()); + Driver.add(new DriverLevelMaintainer.Provider()); } } diff --git a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java index a4a37b52..0fa007c3 100644 --- a/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java +++ b/src/main/java/com/glodblock/github/network/CPacketLevelMaintainer.java @@ -17,36 +17,43 @@ import javax.annotation.Nullable; public class CPacketLevelMaintainer implements IMessage { - private int action; + private String action; private long size; private int slotIndex; public CPacketLevelMaintainer() { } - public CPacketLevelMaintainer(int action) { + public CPacketLevelMaintainer(String action, int slotIndex) { + this.action = action; + this.size = 0; + this.slotIndex = slotIndex; + } + + public CPacketLevelMaintainer(String action) { this.action = action; this.size = 0; this.slotIndex = 0; } - public CPacketLevelMaintainer(int action, int slotIndex, long size) { + public CPacketLevelMaintainer(String action, int slotIndex, long size) { this.action = action; this.size = size; this.slotIndex = slotIndex; } - public CPacketLevelMaintainer(int action, int slotIndex, String size) { + public CPacketLevelMaintainer(String action, int slotIndex, String size) { this.action = action; this.slotIndex = slotIndex; - this.size = Long.parseLong(size); + this.size = size.isEmpty() ? 0 : Long.parseLong(size); } - public static IAEItemStack setTag(IAEItemStack ias, long batch, int slotIndex) { + public static IAEItemStack setTag(IAEItemStack ias, long batch, int slotIndex, boolean enable) { NBTTagCompound data = new NBTTagCompound(); ItemStack is = ias.getItemStack(); data.setLong("Batch", batch); data.setLong("Index", slotIndex); + data.setBoolean("Enable", enable); is.setTagCompound(data); IAEItemStack iaeItemStack = AEItemStack.create(is); iaeItemStack.setStackSize(ias.getStackSize()); @@ -55,40 +62,66 @@ public class CPacketLevelMaintainer implements IMessage { @Override public void fromBytes(ByteBuf buf) { - this.action = buf.readInt(); + int leAction = buf.readInt(); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < leAction; i++) { + sb.append(buf.readChar()); + } + this.action = sb.toString(); this.slotIndex = buf.readInt(); this.size = buf.readLong(); } @Override public void toBytes(ByteBuf buf) { - buf.writeInt(this.action); + buf.writeInt(this.action.length()); + for (int i = 0; i < this.action.length(); i++) { + buf.writeChar(this.action.charAt(i)); + } buf.writeInt(this.slotIndex); buf.writeLong(this.size); } public static class Handler implements IMessageHandler { + private void refresh(ContainerLevelMaintainer cca, EntityPlayerMP player) { + SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(false); + for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { + IAEItemStack is = cca.getTile().requests.getRequestQtyStack(i); + IAEItemStack is1 = cca.getTile().requests.getRequestBatches().getStack(i); + if (is != null) { + if (is1 != null) { + NBTTagCompound data; + data = is1.getItemStack().getTagCompound(); + piu.appendItem(setTag(is, is1.getStackSize(), i, data.getBoolean("Enable"))); + } else { + piu.appendItem(setTag(is, 0, i, true)); + } + } + } + FluidCraft.proxy.netHandler.sendTo(piu, player); + } @Nullable @Override public IMessage onMessage(CPacketLevelMaintainer message, MessageContext ctx) { - if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) { + if (message.action.startsWith("TileLevelMaintainer.") && ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; final ContainerLevelMaintainer cca = (ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer; - if (message.action == -1) { - SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(false); - for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) { - IAEItemStack is = cca.getTile().requests.getQuantity(i); - IAEItemStack is1 = cca.getTile().requests.getRequestBatches().getStack(i); - if (is != null) { - piu.appendItem(setTag(is, is1 != null ? is1.getStackSize() : 0, i)); - } - } - FluidCraft.proxy.netHandler.sendTo(piu, player); - } else { - cca.handleClientInteraction(message.action, message.slotIndex, message.size); + switch (message.action) { + case "TileLevelMaintainer.Quantity": + cca.getTile().updateQuantity(message.slotIndex, message.size); + break; + case "TileLevelMaintainer.Batch": + cca.getTile().updateBatchSize(message.slotIndex, message.size); + break; + case "TileLevelMaintainer.Enable": + cca.getTile().setRequestStatus(message.slotIndex, false); + break; + case "TileLevelMaintainer.Disable": + cca.getTile().setRequestStatus(message.slotIndex, true); + break; } - + this.refresh(cca, player); } return null; } diff --git a/src/main/resources/assets/ae2fc/lang/en_US.lang b/src/main/resources/assets/ae2fc/lang/en_US.lang index 43fbe7c9..ab8f2e35 100644 --- a/src/main/resources/assets/ae2fc/lang/en_US.lang +++ b/src/main/resources/assets/ae2fc/lang/en_US.lang @@ -49,8 +49,9 @@ ae2fc.tooltip.not_prio=Allow fluids to be placed first ae2fc.tooltip.not_prio.hint=Enabled ae2fc.tooltip.prio=Allow fluids to be placed first ae2fc.tooltip.prio.hint=Disabled -ae2fc.tooltip.submit=Submit Request -ae2fc.tooltip.submit.hint=Submit +ae2fc.tooltip.submit=Submit +ae2fc.tooltip.enable=enable +ae2fc.tooltip.disable=disable ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal diff --git a/src/main/resources/assets/ae2fc/lang/zh_CN.lang b/src/main/resources/assets/ae2fc/lang/zh_CN.lang index 67137050..3e21bb7d 100644 --- a/src/main/resources/assets/ae2fc/lang/zh_CN.lang +++ b/src/main/resources/assets/ae2fc/lang/zh_CN.lang @@ -49,8 +49,9 @@ ae2fc.tooltip.not_prio=优先放置流体 ae2fc.tooltip.not_prio.hint=启用 ae2fc.tooltip.prio=优先放置流体 ae2fc.tooltip.prio.hint=禁用 -ae2fc.tooltip.submit=提交请求 -ae2fc.tooltip.submit.hint=提交 +ae2fc.tooltip.submit=提交 +ae2fc.tooltip.enable=启用 +ae2fc.tooltip.disable=禁用 ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端 ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端 diff --git a/src/main/resources/assets/ae2fc/textures/blocks/level_maintainerActive.png b/src/main/resources/assets/ae2fc/textures/blocks/level_maintainer_active.png similarity index 100% rename from src/main/resources/assets/ae2fc/textures/blocks/level_maintainerActive.png rename to src/main/resources/assets/ae2fc/textures/blocks/level_maintainer_active.png diff --git a/src/main/resources/assets/ae2fc/textures/gui/states.png b/src/main/resources/assets/ae2fc/textures/gui/states.png index d0fee811794344a7a17d1f30670c4268986d394b..4f0fe51ddc814bb67c66e5ce42ed3377ee501554 100644 GIT binary patch delta 1690 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 From dc7c33bfa05f490922dadd718bd29e7cee393475 Mon Sep 17 00:00:00 2001 From: asdflj <854865755@qq.com> Date: Tue, 15 Nov 2022 09:15:30 +0800 Subject: [PATCH 7/7] uh substitutions mode is not complete yet --- .../gui/GuiBaseFluidPatternTerminal.java | 27 +++++++++---------- .../gui/GuiBaseFluidPatternTerminalEx.java | 27 ++++++++++--------- .../ContainerFluidPatternTerminal.java | 2 +- .../ContainerFluidPatternTerminalEx.java | 2 +- .../parts/PartFluidPatternTerminal.java | 2 +- .../parts/PartFluidPatternTerminalEx.java | 2 +- .../github/util/ModAndClassUtil.java | 2 +- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java index fcedaf8f..233b88a8 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminal.java @@ -2,7 +2,6 @@ package com.glodblock.github.client.gui; import appeng.api.config.ActionItems; import appeng.api.config.ItemSubstitution; -import appeng.api.config.PatternBeSubstitution; import appeng.api.config.Settings; import appeng.api.storage.ITerminalHost; import appeng.client.gui.widgets.GuiImgButton; @@ -118,19 +117,19 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor { this.buttonList.add(this.doubleBtn); combineLeft = 84; } - if (ModAndClassUtil.isBeSubstitutionsButton) { - combineLeft = 74; - combineTop -= 11; - this.beSubstitutionsEnabledBtn = new GuiImgButton( - this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.ENABLED); - this.beSubstitutionsEnabledBtn.setHalfSize(true); - this.buttonList.add(this.beSubstitutionsEnabledBtn); - - this.beSubstitutionsDisabledBtn = new GuiImgButton( - this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED); - this.beSubstitutionsDisabledBtn.setHalfSize(true); - this.buttonList.add(this.beSubstitutionsDisabledBtn); - } +// if (ModAndClassUtil.isBeSubstitutionsButton) { +// combineLeft = 74; +// combineTop -= 11; +// this.beSubstitutionsEnabledBtn = new GuiImgButton( +// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.ENABLED); +// this.beSubstitutionsEnabledBtn.setHalfSize(true); +// this.buttonList.add(this.beSubstitutionsEnabledBtn); +// +// this.beSubstitutionsDisabledBtn = new GuiImgButton( +// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED); +// this.beSubstitutionsDisabledBtn.setHalfSize(true); +// this.buttonList.add(this.beSubstitutionsDisabledBtn); +// } this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE"); this.combineEnableBtn.setHalfSize(true); this.buttonList.add(this.combineEnableBtn); diff --git a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java index db90f6e2..5102b5a4 100644 --- a/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/GuiBaseFluidPatternTerminalEx.java @@ -1,6 +1,9 @@ package com.glodblock.github.client.gui; -import appeng.api.config.*; +import appeng.api.config.ActionItems; +import appeng.api.config.ItemSubstitution; +import appeng.api.config.PatternSlotConfig; +import appeng.api.config.Settings; import appeng.api.storage.ITerminalHost; import appeng.client.gui.widgets.GuiImgButton; import appeng.client.gui.widgets.GuiScrollbar; @@ -133,17 +136,17 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor { this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE"); this.combineDisableBtn.setHalfSize(true); this.buttonList.add(this.combineDisableBtn); - if (ModAndClassUtil.isBeSubstitutionsButton) { - this.beSubstitutionsEnabledBtn = new GuiImgButton( - this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.ENABLED); - this.beSubstitutionsEnabledBtn.setHalfSize(true); - this.buttonList.add(this.beSubstitutionsEnabledBtn); - - this.beSubstitutionsDisabledBtn = new GuiImgButton( - this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.DISABLED); - this.beSubstitutionsDisabledBtn.setHalfSize(true); - this.buttonList.add(this.beSubstitutionsDisabledBtn); - } +// if (ModAndClassUtil.isBeSubstitutionsButton) { +// this.beSubstitutionsEnabledBtn = new GuiImgButton( +// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.ENABLED); +// this.beSubstitutionsEnabledBtn.setHalfSize(true); +// this.buttonList.add(this.beSubstitutionsEnabledBtn); +// +// this.beSubstitutionsDisabledBtn = new GuiImgButton( +// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.DISABLED); +// this.beSubstitutionsDisabledBtn.setHalfSize(true); +// this.buttonList.add(this.beSubstitutionsDisabledBtn); +// } processingScrollBar.setTop(this.ySize - 164); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java index 9f06b5c9..be5a58d4 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminal.java @@ -119,7 +119,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement FluidPatternDetails pattern = new FluidPatternDetails(patternStack); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); - pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); +// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java index 6e4ec344..95645a9d 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidPatternTerminalEx.java @@ -116,7 +116,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple pattern.setCombine(this.combine ? 1:0); pattern.setInputs(collectInventory(craftingSlots)); pattern.setOutputs(collectInventory(outputSlots)); - pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); +// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0); patternSlotOUT.putStack(pattern.writeToStack()); } diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java index 5dc65c2d..e6611ddb 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminal.java @@ -140,7 +140,7 @@ public class PartFluidPatternTerminal extends FCBasePart { if(newStack != null){ NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); - this.setBeSubstitute(data.getBoolean("beSubstitute")); +// this.setBeSubstitute(data.getBoolean("beSubstitute")); } for (int i = 0; i < this.crafting.getSizeInventory(); i++) { this.crafting.setInventorySlotContents(i, null); diff --git a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java index 8f4ccbb6..47fdee81 100644 --- a/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java +++ b/src/main/java/com/glodblock/github/common/parts/PartFluidPatternTerminalEx.java @@ -165,7 +165,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart { if(newStack != null){ NBTTagCompound data = newStack.getTagCompound(); this.setCombineMode(data.getInteger("combine") == 1); - this.setBeSubstitute(data.getBoolean("beSubstitute")); +// this.setBeSubstitute(data.getBoolean("beSubstitute")); } this.setInverted(inputsCount <= 8 && outputCount > 8); this.setActivePage(0); diff --git a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java index bf1a2f72..48a687d0 100644 --- a/src/main/java/com/glodblock/github/util/ModAndClassUtil.java +++ b/src/main/java/com/glodblock/github/util/ModAndClassUtil.java @@ -73,7 +73,7 @@ public final class ModAndClassUtil { } try { Field d = ButtonToolTips.class.getDeclaredField("BeSubstitutionsDescEnabled"); - isBeSubstitutionsButton = true; +// isBeSubstitutionsButton = true; } catch (NoSuchFieldException e) { isBeSubstitutionsButton = false; }