Merge pull request #68 from GTNewHorizons/refactor

refactor code
This commit is contained in:
Yang Xizhi authored and GitHub committed 2023-01-23 17:06:44 +08:00
commit e69a0fc977
140 files changed
+2765 -5868

No files matched your search

@@ -69,14 +69,9 @@ public class FluidCraft {
if (!Config.removeRecipe) {
(new RecipeLoader()).run();
}
try {
Class<?> calculatorV2 = Class.forName("appeng.crafting.v2.CraftingCalculations");
if (calculatorV2 != null) {
// Only run this if GTNH AE2 is installed
CalculatorV2PluginLoader.installCalculatorV2Plugins();
}
} catch (ClassNotFoundException e) {
// no-op
if (ModAndClassUtil.isV2) {
CalculatorV2PluginLoader.installCalculatorV2Plugins();
}
proxy.postInit(event);
@@ -1,223 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.slot.AppEngSlot;
import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String CRAFTMODE_CRFTING = "1";
private static final String CRAFTMODE_PROCESSING = "0";
public FCBasePartContainer container;
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
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));
this.container = (FCBasePartContainer) this.inventorySlots;
setReservedSpace(81);
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.CraftMode",
this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING));
} else if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
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.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"));
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.tabCraftButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.crafting_table),
GuiText.CraftingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.furnace),
GuiText.ProcessingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
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);
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);
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);
}
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
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (!this.container.isCraftingMode()) {
this.tabCraftButton.visible = false;
this.tabProcessButton.visible = true;
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true;
} else {
this.tabCraftButton.visible = true;
this.tabProcessButton.visible = false;
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = false;
}
if (this.container.substitute) {
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
} else {
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if (!this.container.isCraftingMode()) {
if (this.container.combine) {
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
} else {
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
} 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);
}
@Override
protected String getBackground() {
if (this.container.isCraftingMode()) {
return "gui/pattern.png";
}
return "gui/pattern2.png";
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -1,304 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
private static final String SUBSITUTION_DISABLE = "0";
private static final String SUBSITUTION_ENABLE = "1";
private static final String PRIORITY_DISABLE = "0";
private static final String PRIORITY_ENABLE = "1";
public FCBasePartContainerEx container;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiFCImgButton fluidPrioritizedEnabledBtn;
private GuiFCImgButton fluidPrioritizedDisabledBtn;
private GuiImgButton encodeBtn;
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));
this.container = (FCBasePartContainerEx) this.inventorySlots;
setReservedSpace(81);
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
} else if (this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE));
} else if (this.invertBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminalEx.Invert", container.inverted ? "0" : "1"));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
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.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"));
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
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 - 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);
invertBtn.setHalfSize(true);
this.buttonList.add(this.invertBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
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);
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.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 - 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);
}
processingScrollBar.setTop(this.ySize - 164);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true;
if (this.container.substitute) {
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
} else {
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if (this.container.prioritize) {
this.fluidPrioritizedEnabledBtn.visible = false;
this.fluidPrioritizedDisabledBtn.visible = true;
} else {
this.fluidPrioritizedEnabledBtn.visible = true;
this.fluidPrioritizedDisabledBtn.visible = false;
}
if (this.container.combine) {
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
} 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);
this.processingScrollBar.draw(this);
}
@Override
protected String getBackground() {
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
if (container.substitute) {
substitutionsEnabledBtn.visible = true;
substitutionsDisabledBtn.visible = false;
} else {
substitutionsEnabledBtn.visible = false;
substitutionsDisabledBtn.visible = true;
}
if (container.prioritize) {
fluidPrioritizedEnabledBtn.visible = true;
fluidPrioritizedDisabledBtn.visible = false;
} else {
fluidPrioritizedEnabledBtn.visible = false;
fluidPrioritizedDisabledBtn.visible = true;
}
final int offset = container.inverted ? 18 * -3 : 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop);
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput() {
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -1,53 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor {
protected EntityPlayer player;
public GuiBaseFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te, FCBaseFluidMonitorContain c) {
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
player = inventoryPlayer.player;
}
@Override
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
}
@@ -120,14 +120,15 @@ public class GuiDualInterface extends GuiUpgradeable {
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == null) {
return;
}
if (btn == this.priority) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_TILE));
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
}
}
@@ -149,7 +150,7 @@ public class GuiDualInterface extends GuiUpgradeable {
if (btn == this.insertionMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards));
}
if (btn == this.sidelessMode && this.sidelessMode != null) {
if (btn == this.sidelessMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
}
}
@@ -1,797 +0,0 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
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.*;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.container.AEBaseContainer;
import appeng.container.slot.*;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
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;
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 com.glodblock.github.util.Util;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
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;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiFCBaseFluidMonitor extends AEBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
private static String memoryText = "";
private final FluidRepo repo;
private final int offsetX = 9;
private final int lowerTextureOffset = 0;
private final boolean viewCell;
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
public IConfigManager configSrc;
public FCBaseFluidMonitorContain monitorableContainer;
public GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private FCGuiTextField searchField;
private int perRow = 9;
private int reservedSpace = 0;
private boolean customSortOrder = true;
private int rows = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private GuiImgButton ViewBox;
private GuiImgButton SortByBox;
private GuiImgButton SortDirBox;
private GuiImgButton searchBoxSettings;
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseFluidMonitor(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) {
super(c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.repo = new FluidRepo(scrollbar, this);
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCBaseFluidMonitorContain) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
IAEItemStack stack = AEItemStack.create(ItemFluidDrop.newDisplayStack(is.getFluidStack()));
stack.setStackSize(is.getStackSize());
this.repo.postUpdate(stack);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar()
.setRange(
0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next =
Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (btn == this.searchBoxSettings) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
} else {
try {
NetworkHandler.instance.sendToServer(
new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reinitalize();
}
}
}
}
private void reinitalize() {
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL
? 9
: 9 + ((this.width - this.standardSize) / 18);
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = hasNEI ? 0 : 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18.0);
if (this.rows > this.maxRows) {
top += (this.rows - this.maxRows) * 18 / 2;
this.rows = this.maxRows;
}
if (hasNEI) {
this.rows--;
}
if (this.rows < 3) {
this.rows = 3;
}
this.getMeSlots().clear();
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots()
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) {
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
} else {
this.xSize = this.standardSize;
}
super.initGui();
// full size : 204
// extra slots : 72
// slot 18
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
int offset = this.guiTop + 8;
if (this.customSortOrder) {
this.buttonList.add(
this.SortByBox = new GuiImgButton(
this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
}
// this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE,
// this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
// offset += 20;
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
}
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
offset += 20;
this.searchField = new FCGuiTextField(
this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setVisible(true);
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if (this.viewCell) {
if (ModAndClassUtil.isCraftStatus
&& AEConfig.instance
.getConfigManager()
.getSetting(Settings.CRAFTING_STATUS)
.equals(CraftingStatus.BUTTON)) {
this.buttonList.add(
this.craftingStatusImgBtn = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.CRAFTING_STATUS,
AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
} else {
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + 170,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
}
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString(memoryText, false);
}
if (this.isSubGui()) {
this.repo.updateView();
this.setScrollBar();
}
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
this.repositionSlot((AppEngSlot) s);
}
}
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
final Slot g = (Slot) s;
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
}
}
}
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
}
public void setSearchString(String memoryText, boolean updateView) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
if (updateView) {
this.repo.updateView();
this.setScrollBar();
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
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);
}
@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);
}
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;
if (mouseButton == 3) {
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if (slot instanceof SlotFake) {
InventoryAction action =
ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
} else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (slot instanceof SlotPatternTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
} catch (final IOException e) {
AELog.debug(e);
}
} else if (slot instanceof SlotCraftingTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
InventoryAction action;
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
} else {
// Craft stack on right-click, craft single on left-click
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
IAEItemStack stack = null;
if (slot instanceof SlotME) {
stack = ((SlotME) slot).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
}
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
}
if (slot instanceof SlotDisconnected) {
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
InventoryAction action = null;
switch (mouseButton) {
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(
action,
slot.getSlotIndex(),
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
return;
}
if (slot instanceof SlotME) {
InventoryAction action = null;
IAEItemStack stack = null;
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (stack != null
&& action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
if (stack.getItem() instanceof ItemFluidDrop) {
stack = ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
}
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
} else if (player.capabilities.isCreativeMode) {
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if (slotItem != null) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
break;
default:
case 4: // drop item:
case 6:
}
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
} else if (action != null) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0);
NetworkHandler.instance.sendToServer(p);
}
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
memoryText = this.searchField.getText();
}
public void bindTextureBack(final String file) {
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
this.mc.getTextureManager().bindTexture(loc);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTextureBack(this.getBackground());
final int x_width = 195;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
if (this.viewCell) {
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
}
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(
offsetX,
offsetY + 16 + this.rows * 18 + this.lowerTextureOffset,
0,
106 - 18 - 18,
x_width,
99 + this.reservedSpace - this.lowerTextureOffset);
if (this.viewCell) {
boolean update = false;
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i]
!= this.monitorableContainer.getCellViewSlot(i).getStack()) {
update = true;
this.myCurrentViewCells[i] =
this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
if (update) {
this.repo.setViewCell(this.myCurrentViewCells);
}
}
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? 6
: Integer.MAX_VALUE;
}
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
}
}
@Override
public void updateScreen() {
this.repo.setPower(this.monitorableContainer.isPowered());
super.updateScreen();
}
@Override
public Enum<?> getSortBy() {
return this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public Enum<?> getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum<?> getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.SortByBox != null) {
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
if (this.SortDirBox != null) {
this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
if (this.ViewBox != null) {
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
}
this.repo.updateView();
}
public int getReservedSpace() {
return this.reservedSpace;
}
public void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public boolean isCustomSortOrder() {
return this.customSortOrder;
}
public void setCustomSortOrder(final boolean customSortOrder) {
this.customSortOrder = customSortOrder;
}
public int getStandardSize() {
return this.standardSize;
}
public void setStandardSize(final int standardSize) {
this.standardSize = standardSize;
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y) {
return searchField.isMouseIn(x, y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
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);
}
}
}
@@ -1,199 +1,99 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.FluidCraft;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFCPriority extends AEBaseGui {
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType OriginalGui;
public class GuiFCPriority extends FCGuiAmount {
public GuiFCPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) {
super(new ContainerPriority(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
final int a = AEConfig.instance.priorityByStacksAmounts(0);
final int b = AEConfig.instance.priorityByStacksAmounts(1);
final int c = AEConfig.instance.priorityByStacksAmounts(2);
final int d = AEConfig.instance.priorityByStacksAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
if (target instanceof TileFluidInterface) {
myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE;
} else if (target instanceof PartFluidInterface) {
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
} else if (target instanceof PartFluidStorageBus) {
myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.OriginalGui = GuiType.FLUID_STORAGE_BUS;
}
if (this.OriginalGui != null && myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.priority = new GuiNumberBox(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT,
Long.class);
this.priority.setEnableBackgroundDrawing(false);
this.priority.setMaxStringLength(16);
this.priority.setTextColor(0xFFFFFF);
this.priority.setVisible(true);
this.priority.setFocused(true);
((ContainerPriority) this.inventorySlots).setTextField(this.priority);
this.submit.enabled = false;
this.submit.visible = false;
this.buttonList.remove(this.submit);
((ContainerPriority) this.inventorySlots).setTextField(this.amountBox);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 0x404040);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.priority.drawTextBox();
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.amountBox.drawTextBox();
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty(final int i) {
protected void addQty(final int i) {
try {
String out = this.priority.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.priority.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
long result = Long.parseLong(out);
result += i;
this.priority.setText(out = Long.toString(result));
NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final NumberFormatException e) {
// nope..
this.priority.setText("0");
} catch (final IOException e) {
this.amountBox.setText(Long.toString(getAmount() + i));
} catch (final NumberFormatException ignore) {
}
try {
NetworkHandler.instance.sendToServer(
new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
} catch (IOException e) {
AELog.debug(e);
}
}
@Override
protected void setOriginGUI(Object target) {
if (target instanceof TileFluidInterface) {
this.myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE;
} else if (target instanceof PartFluidInterface) {
this.myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.originalGui = GuiType.DUAL_INTERFACE_PART;
} else if (target instanceof PartFluidStorageBus) {
this.myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.originalGui = GuiType.FLUID_STORAGE_BUS;
}
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if ((key == 211
|| key == 205
|| key == 203
|| key == 14
|| character == '-'
|| Character.isDigit(character))
&& this.priority.textboxKeyTyped(character, key)) {
try {
String out = this.priority.getText();
super.keyTyped(character, key);
try {
NetworkHandler.instance.sendToServer(
new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
} catch (IOException e) {
AELog.debug(e);
}
}
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.priority.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final IOException e) {
AELog.debug(e);
}
@Override
protected int getAmount() {
try {
String out = this.amountBox.getText();
double result = Calculator.conversion(out);
if (Double.isNaN(result)) {
return 0;
} else {
super.keyTyped(character, key);
return (int) ArithHelper.round(result, 0);
}
} catch (final NumberFormatException e) {
return 0;
}
}
@@ -1,47 +1,22 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFluidCraftAmount extends AEBaseGui {
private GuiNumberBox amountToCraft;
private GuiTabButton originalGuiBtn;
public class GuiFluidCraftAmount extends FCGuiAmount {
private GuiButton next;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType originalGui;
@Reflected
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftAmount(inventoryPlayer, te));
}
@@ -49,192 +24,57 @@ public class GuiFluidCraftAmount extends AEBaseGui {
@Override
public void initGui() {
super.initGui();
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(
this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if (target instanceof PartFluidPatternTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (target instanceof PartFluidTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToCraft = new GuiNumberBox(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT,
Integer.class);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible(true);
this.amountToCraft.setFocused(true);
this.amountToCraft.setText("1");
this.amountToCraft.setSelectionPos(0);
this.amountBox.setText("1");
this.amountBox.setSelectionPos(0);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
this.bindTexture("guis/craftAmt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.submit.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
try {
Long.parseLong(this.amountToCraft.getText());
this.next.enabled = this.amountToCraft.getText().length() > 0;
this.submit.enabled = getAmount() > 0;
} catch (final NumberFormatException e) {
this.next.enabled = false;
}
this.amountToCraft.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.next);
}
if ((key == 211
|| key == 205
|| key == 203
|| key == 14
|| character == '-'
|| Character.isDigit(character))
&& this.amountToCraft.textboxKeyTyped(character, key)) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.amountToCraft.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
final long result = Long.parseLong(out);
if (result < 0) {
this.amountToCraft.setText("1");
}
} catch (final NumberFormatException e) {
// :P
}
} else {
super.keyTyped(character, key);
}
this.submit.enabled = false;
}
this.amountBox.drawTextBox();
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
if (btn == this.next) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
if (btn == this.submit && this.submit.enabled) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketCraftRequest(getAmount(), isShiftKeyDown()));
}
} catch (final NumberFormatException e) {
// nope..
this.amountToCraft.setText("1");
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
this.amountBox.setText("1");
}
}
private void addQty(final int i) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.amountToCraft.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
long result = Integer.parseInt(out);
if (result == 1 && i > 1) {
result = 0;
}
result += i;
if (result < 1) {
result = 1;
}
out = Long.toString(result);
Integer.parseInt(out);
this.amountToCraft.setText(out);
} catch (final NumberFormatException e) {
// :P
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (target instanceof PartFluidTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
}
}
@Override
protected String getBackground() {
return "guis/craftAmt.png";
}
}
@@ -30,7 +30,6 @@ import org.lwjgl.opengl.GL11;
public class GuiFluidCraftConfirm extends AEBaseGui {
private final ContainerFluidCraftConfirm ccc;
private final int rows = 5;
private final IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
@@ -5,15 +5,15 @@ import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidIO extends GuiUpgradeable {
private final PartSharedFluidBus bus;
private final FCSharedFluidBus bus;
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) {
public GuiFluidIO(InventoryPlayer inventoryPlayer, FCSharedFluidBus te) {
super(new ContainerFluidIO(inventoryPlayer, te));
this.bus = te;
}
@@ -7,23 +7,21 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import com.glodblock.github.util.RenderUtil;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
@@ -34,20 +32,12 @@ public class GuiFluidInterface extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png");
private static final int TANK_X = 35, TANK_X_OFF = 18, TANK_Y = 53;
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 68;
private final ContainerFluidInterface cont;
private GuiTabButton switcher;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
public GuiFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
this.addMouseRegin();
}
public GuiFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
public GuiFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(new ContainerFluidInterface(ipl, tile));
this.cont = (ContainerFluidInterface) inventorySlots;
this.ySize = 231;
@@ -61,11 +51,7 @@ public class GuiFluidInterface extends AEBaseGui {
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(
isPart()
? ((PartFluidInterface) cont.getTile()).getInternalFluid()
: ((TileFluidInterface) cont.getTile()).getInternalFluid(),
i));
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
}
}
@@ -98,19 +84,14 @@ public class GuiFluidInterface extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv;
if (isPart()) {
fluidInv = ((PartFluidInterface) cont.getTile()).getInternalFluid();
} else {
fluidInv = ((TileFluidInterface) cont.getTile()).getInternalFluid();
}
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 6; i++) {
if (!isPart()) {
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
}
renderFluidIntoGui(
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
@@ -132,29 +113,6 @@ public class GuiFluidInterface extends AEBaseGui {
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
public void renderFluidIntoGui(
int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -166,18 +124,9 @@ public class GuiFluidInterface extends AEBaseGui {
public void update(int id, IAEFluidStack stack) {
if (id >= 100) {
id -= 100;
if (isPart()) {
((PartFluidInterface) cont.getTile()).setConfig(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
}
cont.getTile().setConfig(id - 100, stack);
} else {
if (isPart()) {
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
}
cont.getTile().setFluidInv(id, stack);
}
}
@@ -0,0 +1,55 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.localization.GuiText;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.client.me.FluidRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.util.Util;
import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
public GuiFluidMonitor(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidMonitor c) {
super(inventoryPlayer, te, c);
this.repo = new FluidRepo(getScrollBar(), this);
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
IAEItemStack stack = AEItemStack.create(ItemFluidDrop.newDisplayStack(is.getFluidStack()));
stack.setStackSize(is.getStackSize());
this.repo.postUpdate(stack);
}
this.repo.updateView();
this.setScrollBar();
}
@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(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
protected IAEItemStack transformItem(IAEItemStack stack) {
if (stack.getItem() instanceof ItemFluidDrop) {
return ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
}
return stack;
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
if (Util.getFluidFromItem(stack) != null) {
setSearchString(Util.getFluidFromItem(stack).getLocalizedName(), true);
}
}
}
@@ -9,7 +9,7 @@ import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.slot.ISlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
@@ -82,8 +82,8 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
}
public void drawSlot0(Slot slot) {
if (slot instanceof SlotFluid) {
IAEItemStack stack = ((SlotFluid) slot).getAeStack();
if (slot instanceof ISlotFluid) {
IAEItemStack stack = ((ISlotFluid) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return;
IAEItemStack fake = stack.copy();
@@ -1,75 +1,135 @@
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.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternTerm;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminal container = new ContainerFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
this.container = container;
this.monitorableContainer = container;
this.configSrc = container.getConfigManager();
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
craftingStatusBtn = super.craftingStatusBtn;
this.tabCraftButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.crafting_table),
GuiText.CraftingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.furnace),
GuiText.ProcessingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
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);
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);
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);
}
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
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 && !this.container.isCraftingMode()) {
AEItemStack stack = AEItemStack.create(slot.getStack());
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);
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL),
8,
this.ySize - 96 + 2 - getReservedSpace(),
4210752);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (mouseButton == 3) {
if (this.container.isCraftingMode()
&& (slot instanceof OptionalSlotFake
|| slot instanceof SlotFakeCraftingMatrix
|| slot instanceof SlotPatternTerm)) {
return;
}
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
protected String getBackground() {
if (this.container.isCraftingMode()) {
return "gui/pattern.png";
}
return "gui/pattern2.png";
}
}
@@ -1,75 +1,179 @@
package com.glodblock.github.client.gui;
import appeng.api.config.*;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
import appeng.client.gui.widgets.GuiImgButton;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternTerminalEx(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminalEx container = new ContainerFluidPatternTerminalEx(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
this.container = container;
this.monitorableContainer = container;
this.configSrc = container.getConfigManager();
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te, new ContainerFluidPatternTerminalEx(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
craftingStatusBtn = super.craftingStatusBtn;
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
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 - 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);
invertBtn.setHalfSize(true);
this.buttonList.add(this.invertBtn);
this.clearBtn = new GuiImgButton(
this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
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);
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.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 - 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);
}
processingScrollBar.setTop(this.ySize - 164);
}
@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) {
AEItemStack stack = AEItemStack.create(slot.getStack());
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);
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
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);
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
protected String getBackground() {
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
final int offset = container.inverted ? 18 * -3 : 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
beSubstitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop);
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput() {
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -80,7 +80,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.FLUID_STORAGE_BUS_PRIORITY));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_PART));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
@@ -5,17 +5,21 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidTerminal;
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.Util;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
@@ -23,18 +27,33 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
public class GuiFluidTerminal extends GuiBaseFluidTerminal {
public class GuiFluidTerminal extends GuiFluidMonitor {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public ContainerFluidTerminal container;
protected EntityPlayer player;
public ContainerFluidMonitor container;
public GuiFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
this.container = new ContainerFluidTerminal(inventoryPlayer, te);
super(inventoryPlayer, te, new ContainerFluidMonitor(inventoryPlayer, te));
this.container = new ContainerFluidMonitor(inventoryPlayer, te);
this.player = inventoryPlayer.player;
}
@Override
public void initGui() {
super.initGui();
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else {
super.actionPerformed(btn);
}
}
@Override
@@ -88,6 +107,9 @@ public class GuiFluidTerminal extends GuiBaseFluidTerminal {
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
}
if (mouseButton == 3 && slot instanceof SlotME) {
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@@ -11,12 +11,10 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import com.glodblock.github.util.RenderUtil;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@@ -40,7 +38,7 @@ public class GuiIngredientBuffer extends AEBaseGui {
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
}
@@ -65,10 +63,11 @@ public class GuiIngredientBuffer extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 4; i++) {
renderFluidIntoGui(
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
@@ -77,34 +76,10 @@ public class GuiIngredientBuffer extends AEBaseGui {
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(
int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -0,0 +1,47 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.ItemRepo;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.base.FCGuiMonitor;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.util.ModAndClassUtil;
import java.util.List;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiItemMonitor extends FCGuiMonitor<IAEItemStack> {
public GuiItemMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerItemMonitor c) {
super(inventoryPlayer, te, c);
this.repo = new ItemRepo(getScrollBar(), this);
}
public void postUpdate(final List<IAEItemStack> list) {
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
@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(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
@Override
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
setSearchString(displayName, true);
}
}
@@ -11,12 +11,10 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import com.glodblock.github.util.RenderUtil;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@@ -40,7 +38,7 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
}
@@ -66,10 +64,11 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 7; i++) {
renderFluidIntoGui(
RenderUtil.renderFluidIntoGui(
this,
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
@@ -78,34 +77,10 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(
int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
}
}
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -14,13 +14,15 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.Optional;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -29,7 +31,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
@@ -41,10 +42,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
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;
private FCGuiTextField input;
private int lastWorkingTick;
private final int interval = 20;
private int refreshTick;
private final CoFHFontRenderer render;
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
@@ -52,12 +52,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.cont = (ContainerLevelMaintainer) inventorySlots;
this.xSize = 195;
this.ySize = 214;
this.tile = tile;
this.render = new CoFHFontRenderer(
Minecraft.getMinecraft().gameSettings,
TEX_BG,
Minecraft.getMinecraft().getTextureManager(),
true);
this.refreshTick = 0;
}
public void postUpdate(List<IAEItemStack> list) {
@@ -81,7 +81,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void initGui() {
super.initGui();
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
this.lastWorkingTick = this.refreshTick;
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
component[i] = new Component(
new Widget(
@@ -104,6 +104,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
this.refreshTick++;
super.drawScreen(mouseX, mouseY, btn);
for (Component com : this.component) {
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
@@ -116,10 +117,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(TEX_BG);
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
int tick = MinecraftServer.getServer().getTickCounter();
int tick = this.refreshTick;
int interval = 20;
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
lastWorkingTick = this.refreshTick;
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
this.component[i].draw();
@@ -139,7 +141,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotFake) {
IAEItemStack stack = ((ContainerLevelMaintainer.FakeSlot) slot).getAeStack();
IAEItemStack stack = ((SlotFluidConvertingFake) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return true;
IAEItemStack fake = stack.copy();
@@ -206,8 +208,7 @@ 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) {
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() != null) {
this.component[slot.getSlotIndex()]
.getQty()
.textField
@@ -252,7 +253,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
for (ContainerLevelMaintainer.FakeSlot slot : this.cont.getRequestSlots()) {
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
if (getSlotArea(slot).contains(mouseX, mouseY)) {
slot.putStack(draggedStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
@@ -313,7 +314,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
private boolean send(Widget widget) {
if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (!widget.textField.getText().isEmpty()
&& widget.textField.getText().matches("^[0-9]+")) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
@@ -1,123 +1,29 @@
package com.glodblock.github.client.gui;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
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.minecraftforge.fluids.FluidStack;
public class GuiPatternValueAmount extends AEBaseGui {
public class GuiPatternValueAmount extends FCGuiAmount {
private GuiTextField amountToSet;
private GuiTabButton originalGuiBtn;
private GuiButton set;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
private GuiType originalGui;
private final int valueIndex;
private final int originalAmount;
@Reflected
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerPatternValueAmount(inventoryPlayer, te));
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
Slot slot = gui.theSlot;
originalAmount = this.getOriginalAmount(slot.getStack());
valueIndex = slot.slotNumber;
} else {
valueIndex = -1;
originalAmount = 0;
}
}
@Override
public void initGui() {
super.initGui();
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(
this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
if (target instanceof PartFluidPatternTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToSet = new GuiTextField(
this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToSet.setEnableBackgroundDrawing(false);
this.amountToSet.setMaxStringLength(16);
this.amountToSet.setTextColor(0xFFFFFF);
this.amountToSet.setVisible(true);
this.amountToSet.setFocused(true);
this.amountToSet.setText(String.valueOf(originalAmount));
this.amountToSet.setSelectionPos(0);
this.submit.displayString = GuiText.Set.getLocal();
}
@Override
@@ -127,116 +33,50 @@ public class GuiPatternValueAmount extends AEBaseGui {
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.set.displayString = I18n.format("ae2fc.gui.button.set");
this.set.enabled = valueIndex >= 0;
this.bindTexture("guis/craftAmt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
super.drawBG(offsetX, offsetY, mouseX, mouseY);
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
this.set.enabled = resultI > 0;
int result = getAmount();
this.submit.enabled = result > 0;
} catch (final NumberFormatException e) {
this.set.enabled = false;
}
this.amountToSet.drawTextBox();
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.set);
}
this.amountToSet.textboxKeyTyped(character, key);
super.keyTyped(character, key);
this.submit.enabled = false;
}
this.amountBox.drawTextBox();
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try {
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
if (btn == this.set && btn.enabled) {
double resultD = Calculator.conversion(this.amountToSet.getText());
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 1;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
FluidCraft.proxy.netHandler.sendToServer(
new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
if (btn == this.submit && btn.enabled) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternValueSet(
originalGui.ordinal(),
getAmount(),
((ContainerPatternValueAmount) this.inventorySlots).getValueIndex()));
}
} catch (final NumberFormatException e) {
// nope..
this.amountToSet.setText("1");
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
this.amountBox.setText("1");
}
}
private void addQty(final int i) {
try {
String out = this.amountToSet.getText();
double resultD = Calculator.conversion(out);
int resultI;
if (resultD <= 0 || Double.isNaN(resultD)) {
resultI = 0;
} else {
resultI = (int) ArithHelper.round(resultD, 0);
}
if (resultI == 1 && i > 1) {
resultI = 0;
}
resultI += i;
if (resultI < 1) {
resultI = 1;
}
out = Integer.toString(resultI);
this.amountToSet.setText(out);
} catch (final NumberFormatException e) {
// :P
@Override
protected void setOriginGUI(Object target) {
if (target instanceof PartFluidPatternTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if (target instanceof PartFluidPatternTerminalEx) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
}
private int getOriginalAmount(ItemStack stack) {
if (Util.isFluidPacket(stack)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
return fluidStack.amount;
} else {
return stack.stackSize;
}
@Override
protected String getBackground() {
return "guis/craftAmt.png";
}
public void setAmount(int amount) {
this.amountBox.setText(String.valueOf(amount));
this.amountBox.setSelectionPos(0);
}
}
@@ -1,6 +1,6 @@
package com.glodblock.github.client.gui;
public interface TankDumpable {
public interface ITankDump {
boolean canDumpTank(int index);
@@ -0,0 +1,141 @@
package com.glodblock.github.client.gui.base;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketSwitchGuis;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
public abstract class FCGuiAmount extends AEBaseGui {
protected GuiTextField amountBox;
protected GuiTabButton originalGuiBtn;
protected GuiButton submit;
protected GuiButton plus1;
protected GuiButton plus10;
protected GuiButton plus100;
protected GuiButton plus1000;
protected GuiButton minus1;
protected GuiButton minus10;
protected GuiButton minus100;
protected GuiButton minus1000;
protected GuiType originalGui;
protected ItemStack myIcon;
public FCGuiAmount(Container container) {
super(container);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
super.initGui();
final int a = AEConfig.instance.priorityByStacksAmounts(0);
final int b = AEConfig.instance.priorityByStacksAmounts(1);
final int c = AEConfig.instance.priorityByStacksAmounts(2);
final int d = AEConfig.instance.priorityByStacksAmounts(3);
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(
this.submit = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
setOriginGUI(((AEBaseContainer) this.inventorySlots).getTarget());
if (this.originalGui != null && this.myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, this.myIcon, this.myIcon.getDisplayName(), itemRender));
}
this.amountBox = new GuiTextField(
this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountBox.setEnableBackgroundDrawing(false);
this.amountBox.setMaxStringLength(16);
this.amountBox.setTextColor(0xFFFFFF);
this.amountBox.setVisible(true);
this.amountBox.setFocused(true);
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.submit);
}
this.amountBox.textboxKeyTyped(character, key);
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
protected void addQty(final int i) {
try {
long resultI = getAmount();
if (resultI == 1 && i > 1) {
resultI = 0;
}
resultI += i;
if (resultI < 1) {
resultI = 1;
}
String out = Long.toString(resultI);
this.amountBox.setText(out);
} catch (final NumberFormatException ignore) {
}
}
protected abstract void setOriginGUI(Object target);
protected abstract String getBackground();
protected int getAmount() {
try {
String out = this.amountBox.getText();
double result = Calculator.conversion(out);
if (result <= 0 || Double.isNaN(result)) {
return 0;
} else {
return (int) ArithHelper.round(result, 0);
}
} catch (final NumberFormatException e) {
return 0;
}
}
}
@@ -0,0 +1,157 @@
package com.glodblock.github.client.gui.base;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotFake;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFCImgButton;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import org.lwjgl.input.Keyboard;
public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
private static final String SUBSTITUTION_DISABLE = "0";
private static final String SUBSTITUTION_ENABLE = "1";
private static final String PRIORITY_DISABLE = "0";
private static final String PRIORITY_ENABLE = "1";
private static final String MODE_CRAFTING = "1";
private static final String MODE_PROCESSING = "0";
public FCContainerEncodeTerminal container;
protected GuiTabButton tabCraftButton;
protected GuiTabButton tabProcessButton;
protected GuiImgButton substitutionsEnabledBtn;
protected GuiImgButton substitutionsDisabledBtn;
protected GuiFCImgButton fluidPrioritizedEnabledBtn;
protected GuiFCImgButton fluidPrioritizedDisabledBtn;
protected GuiImgButton encodeBtn;
protected GuiImgButton invertBtn;
protected GuiImgButton clearBtn;
protected GuiImgButton doubleBtn;
protected GuiImgButton beSubstitutionsEnabledBtn;
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public FCGuiEncodeTerminal(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerEncodeTerminal c) {
super(inventoryPlayer, te, c);
this.container = (FCContainerEncodeTerminal) this.inventorySlots;
c.setGui(this);
setReservedSpace(81);
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == craftingStatusBtn) {
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
} else if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.CraftMode", this.tabProcessButton == btn ? MODE_CRAFTING : MODE_PROCESSING));
} else if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSTITUTION_DISABLE : SUBSTITUTION_ENABLE));
} else if (this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE));
} else if (this.invertBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminal.Invert", container.inverted ? "0" : "1"));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
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.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"));
}
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
updateButton(this.tabCraftButton, this.container.isCraftingMode());
updateButton(this.tabProcessButton, !this.container.isCraftingMode());
updateButton(this.doubleBtn, !this.container.isCraftingMode());
updateButton(this.substitutionsEnabledBtn, this.container.substitute);
updateButton(this.substitutionsDisabledBtn, !this.container.substitute);
updateButton(this.combineEnableBtn, !this.container.isCraftingMode() && this.container.combine);
updateButton(this.combineDisableBtn, !this.container.isCraftingMode() && !this.container.combine);
updateButton(this.beSubstitutionsEnabledBtn, this.container.beSubstitute);
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
protected void updateButton(GuiButton button, boolean vis) {
if (button != null) {
button.visible = vis;
}
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@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 && !this.container.isCraftingMode()) {
AEItemStack stack = AEItemStack.create(slot.getStack());
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);
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
}
@@ -1,9 +1,10 @@
package com.glodblock.github.client.gui;
package com.glodblock.github.client.gui.base;
import appeng.api.config.*;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.gui.AEBaseMEGui;
@@ -32,7 +33,8 @@ 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.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
@@ -49,65 +51,51 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
private static String memoryText = "";
private final ItemRepo repo;
private final int offsetX = 9;
private final int lowerTextureOffset = 0;
protected static String memoryText = "";
protected final int offsetX = 9;
protected final int lowerTextureOffset = 0;
public IConfigManager configSrc;
private final boolean viewCell;
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCBaseMonitorContain monitorableContainer;
protected final boolean viewCell;
protected final ItemStack[] myCurrentViewCells = new ItemStack[5];
public FCContainerMonitor<T> monitorableContainer;
public GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private FCGuiTextField searchField;
private int perRow = 9;
private int reservedSpace = 0;
private boolean customSortOrder = true;
private int rows = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private GuiImgButton ViewBox;
private GuiImgButton SortByBox;
private GuiImgButton SortDirBox;
private GuiImgButton searchBoxSettings;
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseMonitor(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c) {
protected ItemRepo repo;
protected GuiImgButton craftingStatusImgBtn;
protected FCGuiTextField searchField;
protected int perRow = 9;
protected int reservedSpace = 0;
protected boolean customSortOrder = true;
protected int rows = 0;
protected int maxRows = Integer.MAX_VALUE;
protected int standardSize;
protected GuiImgButton ViewBox;
protected GuiImgButton SortByBox;
protected GuiImgButton SortDirBox;
protected GuiImgButton searchBoxSettings;
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
super(c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar(scrollbar);
this.repo = new ItemRepo(scrollbar, this);
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots).setGui(this);
(this.monitorableContainer = (FCContainerMonitor<T>) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate(final List<IAEItemStack> list) {
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
public abstract void postUpdate(final List<T> list);
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
protected void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar()
.setRange(
@@ -116,20 +104,17 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next =
Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (btn == this.searchBoxSettings) {
@@ -144,17 +129,15 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
AELog.debug(e);
}
}
iBtn.set(next);
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reinitalize();
this.reInitalize();
}
}
}
}
private void reinitalize() {
protected void reInitalize() {
this.buttonList.clear();
this.initGui();
}
@@ -171,7 +154,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = hasNEI ? 0 : 0;
final int NEI = 0;
int top = hasNEI ? 22 : 0;
final int magicNumber = 114 + 1;
@@ -179,7 +162,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.rows = (int) Math.floor(extraSpace / 18.0);
if (this.rows > this.maxRows) {
top += (this.rows - this.maxRows) * 18 / 2;
this.rows = this.maxRows;
}
@@ -211,7 +193,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
// slot 18
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
@@ -224,45 +205,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
offset += 20;
}
this.buttonList.add(
this.ViewBox = new GuiImgButton(
this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting(Settings.VIEW_MODE)));
offset += 20;
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
}
this.buttonList.add(
this.terminalStyleBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.TERMINAL_STYLE,
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
offset += 20;
this.searchField = new FCGuiTextField(
this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
this.searchField.setEnableBackgroundDrawing(false);
@@ -296,7 +238,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
@@ -340,24 +281,15 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
}
@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(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
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)) {
setSearchString("", true);
}
super.mouseClicked(xCoord, yCoord, btn);
}
@@ -387,7 +319,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
})
.orElse(false);
return;
} catch (NoSuchFieldException | IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException ignore) {
}
}
}
@@ -395,22 +327,20 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
@SuppressWarnings("unchecked")
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 (this instanceof GuiBaseFluidPatternTerminal
&& ((GuiBaseFluidPatternTerminal) this).container.isCraftingMode()) {
return;
}
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
if (slot.getHasStack()) {
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, i, 0, stack));
}
}
return;
}
}
@@ -419,7 +349,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (slot instanceof SlotFake) {
InventoryAction action =
ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
@@ -427,14 +356,11 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
action = InventoryAction.PICKUP_SINGLE;
}
}
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
@@ -442,7 +368,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
} catch (final IOException e) {
@@ -452,7 +377,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
InventoryAction action;
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
@@ -460,10 +384,8 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
// Craft stack on right-click, craft single on left-click
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
@@ -473,13 +395,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (slot instanceof SlotME) {
stack = ((SlotME) slot).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
}
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance.sendToServer(p);
@@ -491,9 +410,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
InventoryAction action = null;
switch (mouseButton) {
case 0: // pickup / set-down.
{
@@ -507,19 +424,15 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
break;
default:
case 4: // drop item:
case 6:
}
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(
action,
@@ -527,34 +440,30 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
return;
}
if (slot instanceof SlotME) {
InventoryAction action = null;
IAEItemStack stack = null;
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (stack != null
&& action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
stack = transformItem(stack); // for fluid terminal
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
} else if (player.capabilities.isCreativeMode) {
@@ -564,12 +473,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
}
break;
default:
case 4: // drop item:
case 6:
}
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
@@ -587,6 +494,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
protected IAEItemStack transformItem(IAEItemStack stack) {
return stack;
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
@@ -601,19 +512,15 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTextureBack(this.getBackground());
final int x_width = 195;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
if (this.viewCell) {
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
}
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(
offsetX,
offsetY + 16 + this.rows * 18 + this.lowerTextureOffset,
@@ -621,10 +528,8 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
106 - 18 - 18,
x_width,
99 + this.reservedSpace - this.lowerTextureOffset);
if (this.viewCell) {
boolean update = false;
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i]
!= this.monitorableContainer.getCellViewSlot(i).getStack()) {
@@ -633,12 +538,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
if (update) {
this.repo.setViewCell(this.myCurrentViewCells);
}
}
if (this.searchField != null) {
this.searchField.drawTextBox();
}
@@ -653,7 +556,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
return this.repo.hasPower();
}
int getMaxRows() {
protected int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? 6
: Integer.MAX_VALUE;
@@ -754,27 +657,25 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
if (tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
int ry = this.guiTop;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
@@ -782,9 +683,4 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
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);
}
}
@@ -29,7 +29,6 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collections;
@@ -281,7 +280,7 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(Util.from(this.getOpenContext().getSide())),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
@@ -4,20 +4,21 @@ import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.api.util.IConfigManager;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.util.Ae2Reflect;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidIO extends ContainerFluidConfigurable {
private final PartSharedFluidBus bus;
public class ContainerFluidIO extends FCContainerFluidConfigurable {
private final FCSharedFluidBus bus;
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te) {
public ContainerFluidIO(InventoryPlayer ip, FCSharedFluidBus te) {
super(ip, te);
this.bus = te;
}
public PartSharedFluidBus getBus() {
public FCSharedFluidBus getBus() {
return this.bus;
}
@@ -6,8 +6,7 @@ import appeng.container.slot.IOptionalSlotHost;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
@@ -19,9 +18,9 @@ import net.minecraft.inventory.IInventory;
public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost {
private final Object tile;
private final IDualHost tile;
public ContainerFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
public ContainerFluidInterface(InventoryPlayer ipl, IDualHost tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
@@ -34,20 +33,7 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
bindPlayerInventory(ipl, 0, 149);
}
public ContainerFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getConfig();
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(
inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
public Object getTile() {
public IDualHost getTile() {
return tile;
}
@@ -60,28 +46,15 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
if (tile instanceof TileFluidInterface) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i++) {
tmp.put(
i + 100,
AEFluidStack.create(ItemFluidPacket.getFluidStack(
((TileFluidInterface) tile).getConfig().getStackInSlot(i))));
}
} else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i++) {
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i++) {
tmp.put(
i + 100,
AEFluidStack.create(ItemFluidPacket.getFluidStack(
((PartFluidInterface) tile).getConfig().getStackInSlot(i))));
}
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < tile.getConfig().getSizeInventory(); i++) {
tmp.put(
i + 100,
AEFluidStack.create(
ItemFluidPacket.getFluidStack(tile.getConfig().getStackInSlot(i))));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
@@ -5,6 +5,7 @@ import appeng.api.implementations.IUpgradeableHost;
import appeng.container.guisync.GuiSync;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
@@ -15,7 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
public class ContainerFluidLevelEmitter extends ContainerFluidConfigurable {
public class ContainerFluidLevelEmitter extends FCContainerFluidConfigurable {
private final PartFluidLevelEmitter lvlEmitter;
@SideOnly(Side.CLIENT)
@@ -1,7 +1,7 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.config.Actionable;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
@@ -12,95 +12,52 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Util;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
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;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.MutablePair;
public class FCBaseFluidMonitorContain extends AEBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEFluidStack> monitor;
private final IItemList<IAEFluidStack> items = AEApi.instance().storage().createFluidList();
private final IConfigManager clientCM;
private final ITerminalHost host;
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
public FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) {
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected FCBaseFluidMonitorContain(
protected ContainerFluidMonitor(
final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(
ip,
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
monitorable instanceof IPart ? (IPart) monitorable : null);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getFluidInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
// this.setCellInventory( this.monitor );
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
@@ -142,10 +99,6 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
}
public IGridNode getNetworkNode() {
return this.networkNode;
}
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
@@ -164,106 +117,40 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (this.monitor != this.host.getFluidInventory()) {
this.setValidContainer(false);
}
protected void processItemList() {
if (!this.fluids.isEmpty()) {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
for (final IAEFluidStack is : this.fluids) {
final IAEFluidStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendFluid(is);
} else {
piu.appendFluid(send);
}
}
if (!this.items.isEmpty()) {
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
if (!piu.isEmpty()) {
this.fluids.resetStatus();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
for (final IAEFluidStack is : this.items) {
final IAEFluidStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendFluid(is);
} else {
piu.appendFluid(send);
}
}
if (!piu.isEmpty()) {
this.items.resetStatus();
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
}
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject || this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.detectAndSendChanges();
}
}
protected void updatePowerStatus() {
try {
if (this.networkNode != null) {
this.setPowered(this.networkNode.isActive());
} else if (this.getPowerSource() instanceof IEnergyGrid) {
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
} else {
this.setPowered(
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
} catch (final Throwable t) {
// :P
}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
if (field.equals("canAccessViewCells")) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.onUpdate(field, oldValue, newValue);
protected boolean isInvalid() {
return this.monitor != this.host.getFluidInventory();
}
@Override
public void addCraftingToCrafters(final ICrafting c) {
super.addCraftingToCrafters(c);
this.queueInventory(c);
}
private void queueInventory(final ICrafting c) {
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
@@ -273,7 +160,6 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
piu.appendFluid(send);
} catch (final BufferOverflowException boe) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
piu = new SPacketMEInventoryUpdate(true);
piu.appendFluid(send);
}
@@ -282,62 +168,11 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
}
@Override
public void onContainerClosed(final EntityPlayer player) {
super.onContainerClosed(player);
if (this.monitor != null) {
this.monitor.removeListener(this);
}
}
@Override
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered() {
return this.hasPower;
}
private void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
private IConfigManagerHost getGui() {
return this.gui;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
@Override
public boolean isValid(Object verificationToken) {
return true;
}
@Override
public void postChange(
IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
for (final IAEFluidStack is : change) {
this.items.add(is);
this.fluids.add(is);
}
}
@@ -376,7 +211,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
ItemStack out = fluidContainer.copy();
out.stackSize = 1;
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
// add fluid to tanks
// add fluid to tanks
if (nfluid.getStackSize() <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
@@ -403,7 +238,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// add fluid to ae network
// add fluid to ae network
AEFluidStack fluidStack = Util.getAEFluidFromItem(fluidContainer);
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
@@ -474,21 +309,4 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
this.detectAndSendChanges();
}
@Override
public void onListUpdate() {
for (final Object c : this.crafters) {
if (c instanceof ICrafting) {
final ICrafting cr = (ICrafting) c;
this.queueInventory(cr);
}
}
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
}
@@ -3,34 +3,28 @@ package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer {
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
private final TileFluidPatternEncoder tile;
@@ -171,58 +165,4 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
dest.setStack(i, src[i]);
}
}
public static class SlotFluidConvertingFake extends SlotFake implements SlotFluid {
private final AeStackInventory<IAEItemStack> inv;
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
this.inv = inv.getAeInventory();
}
@Override
public void putStack(ItemStack stack) {
inv.setStack(getSlotIndex(), AEItemStack.create(stack));
}
@Override
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
inv.setStack(getSlotIndex(), stack);
}
public void putConvertedStack(ItemStack stack) {
if (stack == null) {
setAeStack(null, false);
return;
} else if (stack.getItem() instanceof IFluidContainerItem) {
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
if (fluid != null) {
fluid.amount *= stack.stackSize;
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
if (aeStack != null) {
setAeStack(aeStack, false);
return;
}
}
} else if (FluidContainerRegistry.isContainer(stack)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if (fluid != null) {
fluid.amount *= stack.stackSize;
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
if (aeStack != null) {
setAeStack(aeStack, false);
return;
}
}
}
putStack(stack);
}
@Nullable
@Override
public IAEItemStack getAeStack() {
return inv.getStack(getSlotIndex());
}
}
}
@@ -1,222 +1,156 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import appeng.container.slot.SlotPatternTerm;
import appeng.util.Platform;
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraft.item.crafting.CraftingManager;
public class ContainerFluidPatternTerminal extends FCBasePartContainer implements PatternConsumer {
public class ContainerFluidPatternTerminal extends FCContainerEncodeTerminal {
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
public ContainerFluidPatternTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
final IInventory output = this.patternTerminal.getInventoryByName("output");
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
this.craftingSlots = new SlotFakeCraftingMatrix[9];
this.outputSlots = new OptionalSlotFake[3];
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] =
new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
}
}
this.addSlotToContainer(
this.craftSlot = new SlotPatternTerm(
ip.player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
this.crafting,
patternInv,
this.cOut,
110,
-76 + 18,
this,
2,
this));
this.craftSlot.setIIcon(-1);
for (int y = 0; y < 3; y++) {
this.addSlotToContainer(
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false);
}
this.updateOrderOfOutputSlots();
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output)
|| defs.materials().blankPattern().isSameAs(output);
}
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
private void updateOrderOfOutputSlots() {
if (!this.isCraftingMode()) {
this.craftSlot.xDisplayPosition = -9000;
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
}
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (!isPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize--;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
}
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting == null) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out == null) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (getPatternTerminal() != null) {
getPatternTerminal().onChangeCrafting(inputs, outputs);
}
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (this.isCraftingMode()) {
super.doAction(player, action, slotId, id);
return;
}
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null
&& !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
this.detectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = -9000;
}
}
}
protected boolean validPatternSlot(Slot slot) {
return slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs;
}
@Override
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
super.putStackInSlot(par1, par2ItemStack);
this.getAndUpdateOutput();
}
@Override
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
super.putStacksInSlots(par1ArrayOfItemStack);
this.getAndUpdateOutput();
}
private ItemStack getAndUpdateOutput() {
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
for (int x = 0; x < ic.getSizeInventory(); x++) {
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
}
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
this.cOut.setInventorySlotContents(0, is);
return is;
}
@Override
protected ItemStack[] getOutputs() {
if (this.isCraftingMode()) {
final ItemStack out = this.getAndUpdateOutput();
if (out != null && out.stackSize > 0) {
return new ItemStack[] {out};
}
}
return super.getOutputs();
}
@Override
public boolean isSlotEnabled(final int idx) {
if (idx == 1) {
return Platform.isServer() ? !this.patternTerminal.isCraftingRecipe() : !this.isCraftingMode();
} else if (idx == 2) {
return Platform.isServer() ? this.patternTerminal.isCraftingRecipe() : this.isCraftingMode();
} else {
return false;
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
if (this.isCraftingMode() != this.patternTerminal.isCraftingRecipe()) {
this.setCraftingMode(this.patternTerminal.isCraftingRecipe());
this.updateOrderOfOutputSlots();
}
}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("craftingMode")) {
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
public void clear() {
super.clear();
this.getAndUpdateOutput();
}
private void setCraftingMode(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
@Override
public void doubleStacks(boolean isShift) {
if (!isCraftingMode()) {
super.doubleStacks(isShift);
}
}
}
@@ -1,221 +1,158 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.PatternConsumer;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import appeng.util.Platform;
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
public class ContainerFluidPatternTerminalEx extends FCContainerEncodeTerminal {
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
public ContainerFluidPatternTerminalEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output)
|| defs.materials().blankPattern().isSameAs(output);
}
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
}
@Override
public void encode() {
if (!checkHasFluidPattern()) {
super.encode();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (!isPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize--;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
encodeFluidPattern();
}
}
private boolean checkHasFluidPattern() {
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
final ItemStack crafting = craftingSlot.getStack();
if (crafting == null) {
continue;
}
search = true;
if (crafting.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
if (!search) { // search=false -> inputs were empty
return false;
}
// `search` should be true at this point
for (Slot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out == null) {
continue;
}
search = false;
if (hasFluid) {
break;
} else if (out.getItem() instanceof ItemFluidPacket) {
hasFluid = true;
break;
}
}
return hasFluid && !search; // search=true -> outputs were empty
}
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setCombine(this.combine ? 1 : 0);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
}
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
this.craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
this.outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
crafting,
this,
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
15,
-83,
x,
y,
x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
output,
this,
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
112,
-83,
-x,
y,
x));
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
this.craftingMode = false;
}
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (getPatternTerminal() != null) {
getPatternTerminal().onChangeCrafting(inputs, outputs);
public boolean isSlotEnabled(final int idx) {
if (idx < 4) // outputs
{
return inverted || idx == 0;
} else {
return !inverted || idx == 4;
}
}
protected boolean validPatternSlot(Slot slot) {
return slot instanceof ProcessingSlotFake;
}
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
super.detectAndSendChanges();
}
private void offsetSlots() {
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
((ProcessingSlotFake) this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS])
.setHidden(page != activePage || x > 0 && inverted);
((ProcessingSlotFake) this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS])
.setHidden(page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("inverted") || field.equals("activePage")) {
offsetSlots();
}
}
@Override
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
inverted = patternTerminal.isInverted();
}
super.onSlotChange(s);
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof OptionalSlotFake)
&& stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
if (stack == null && slot.getStack() != null && slot.getStack().getItem() instanceof ItemFluidPacket) {
return;
}
}
this.craftingMode = false;
super.doAction(player, action, slotId, id);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null
&& !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
this.detectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
public void encode() {
this.craftingMode = false;
super.encode();
}
@Override
public boolean isCraftingMode() {
return false;
}
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(
IInventory inv,
IOptionalSlotHost containerBus,
int idx,
int x,
int y,
int offX,
int offY,
int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
}
@@ -10,6 +10,7 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
@@ -18,7 +19,7 @@ import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
public class ContainerFluidStorageBus extends ContainerFluidConfigurable {
public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
public final PartFluidStorageBus bus;
@@ -1,10 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.ITerminalHost;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidTerminal extends FCBaseFluidMonitorContain {
public ContainerFluidTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
super(ip, monitorable);
}
}
@@ -4,7 +4,7 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.client.gui.ITankDump;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
@@ -14,7 +14,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable {
public class ContainerIngredientBuffer extends AEBaseContainer implements ITankDump {
private final TileIngredientBuffer tile;
@@ -22,10 +22,14 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
addSlots(inv);
bindPlayerInventory(ipl, 0, 140);
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 9; i++) {
addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108));
}
bindPlayerInventory(ipl, 0, 140);
}
public TileIngredientBuffer getTile() {
@@ -34,13 +38,13 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(index) != null;
return tile.getInternalFluid().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
tile.getFluidInventory().setFluidInSlot(index, null);
if (index >= 0 && index < tile.getInternalFluid().getSlots()) {
tile.getInternalFluid().setFluidInSlot(index, null);
}
}
@@ -48,8 +52,8 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
@@ -0,0 +1,151 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.slot.SlotRestrictedInput;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import java.nio.BufferOverflowException;
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.minecraftforge.common.util.ForgeDirection;
public class ContainerItemMonitor extends FCContainerMonitor<IAEItemStack> {
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
public ContainerItemMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected ContainerItemMonitor(
final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(ip, monitorable, bindInventory);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
}
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
@Override
protected void processItemList() {
if (!this.items.isEmpty()) {
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
for (final IAEItemStack is : this.items) {
final IAEItemStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendItem(is);
} else {
piu.appendItem(send);
}
}
if (!piu.isEmpty()) {
this.items.resetStatus();
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
}
}
}
@Override
protected void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
for (final IAEItemStack send : monitorCache) {
try {
piu.appendItem(send);
} catch (final BufferOverflowException boe) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
piu = new SPacketMEInventoryUpdate();
piu.appendItem(send);
}
}
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
@Override
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if (this.crafters.isEmpty() && this.monitor != null) {
this.monitor.removeListener(this);
}
}
@Override
public void postChange(
final IBaseMonitor<IAEItemStack> monitor,
final Iterable<IAEItemStack> change,
final BaseActionSource source) {
for (final IAEItemStack is : change) {
this.items.add(is);
}
}
}
@@ -1,62 +1,21 @@
package com.glodblock.github.client.gui.container;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable {
private final TileLargeIngredientBuffer tile;
public class ContainerLargeIngredientBuffer extends ContainerIngredientBuffer {
public ContainerLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
super(ipl, tile);
this.tile = tile;
IInventory inv = tile.getInternalInventory();
}
protected void addSlots(IInventory inv) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new SlotNormal(inv, i * 9 + j, 8 + 18 * j, 72 + 18 * i));
}
}
bindPlayerInventory(ipl, 0, 140);
}
public TileLargeIngredientBuffer getTile() {
return tile;
}
@Override
public boolean canDumpTank(int index) {
return tile.getFluidInventory().getFluidInSlot(index) != null;
}
@Override
public void dumpTank(int index) {
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
tile.getFluidInventory().setFluidInSlot(index, null);
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
}
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -4,6 +4,7 @@ import appeng.container.AEBaseContainer;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.AeItemStackHandler;
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
@@ -11,14 +12,14 @@ import net.minecraft.item.ItemStack;
public class ContainerLevelMaintainer extends AEBaseContainer {
private final TileLevelMaintainer tile;
private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT];
private final SlotFluidConvertingFake[] requestSlots = new SlotFluidConvertingFake[TileLevelMaintainer.REQ_COUNT];
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(ipl, tile);
this.tile = tile;
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
FakeSlot slot = new FakeSlot(request, y, 27, 20 + y * 19);
SlotFluidConvertingFake slot = new SlotFluidConvertingFake(request, y, 27, 20 + y * 19);
addSlotToContainer(slot);
requestSlots[y] = slot;
}
@@ -29,13 +30,13 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
return tile;
}
public FakeSlot[] getRequestSlots() {
public SlotFluidConvertingFake[] getRequestSlots() {
return this.requestSlots;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
for (FakeSlot slot : this.getRequestSlots()) {
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
if (!slot.getHasStack()) {
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
break;
@@ -44,11 +45,4 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
this.detectAndSendChanges();
return null;
}
public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake {
public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) {
super(inv, idx, x, y);
}
}
}
@@ -3,6 +3,7 @@ package com.glodblock.github.client.gui.container;
import appeng.api.config.SecurityPermissions;
import appeng.api.storage.ITerminalHost;
import appeng.container.AEBaseContainer;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotInaccessible;
import appeng.tile.inventory.AppEngInternalInventory;
import net.minecraft.entity.player.InventoryPlayer;
@@ -11,7 +12,9 @@ import net.minecraft.inventory.Slot;
public class ContainerPatternValueAmount extends AEBaseContainer {
private final Slot patternValue;
private int valueIndex;
@GuiSync(11)
public int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
@@ -1,620 +0,0 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.networking.security.MachineSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
import appeng.core.sync.packets.PacketPatternSlot;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.util.Util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public class FCBasePartContainer extends FCBaseMonitorContain
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private final PartFluidPatternTerminal patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
private final IInventory crafting;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
protected final SlotPatternTerm craftSlot;
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync(97)
public boolean craftingMode = true;
@GuiSync(96)
public boolean substitute = false;
@GuiSync(95)
public boolean combine = false;
@GuiSync(94)
public boolean beSubstitute = 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");
this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] =
new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
}
}
this.addSlotToContainer(
this.craftSlot = new SlotPatternTerm(
ip.player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
this.crafting,
patternInv,
this.cOut,
110,
-76 + 18,
this,
2,
this));
this.craftSlot.setIIcon(-1);
for (int y = 0; y < 3; y++) {
this.addSlotToContainer(
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false);
}
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
patternInv,
0,
147,
-72 - 9,
this.getInventoryPlayer()));
this.addSlotToContainer(
this.patternSlotOUT = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
patternInv,
1,
147,
-72 + 34,
this.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit(1);
this.bindPlayerInventory(ip, 0, 0);
this.updateOrderOfOutputSlots();
}
static boolean canDoubleStacks(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots =
enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream()
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
.count();
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
static void doubleStacksInternal(SlotFake[] slots) {
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st == null) continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
} else if (st.stackSize * 2 > 127) {
overFlowStacks.add(st.copy());
} else {
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext()) break;
if (s.getStack() != null) continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
static boolean containsItem(SlotFake[] slots) {
List<SlotFake> 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) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream()
.filter(s -> Util.isFluidPacket(s.getStack()))
.count();
return fluid > 0;
}
private void updateOrderOfOutputSlots() {
if (!this.isCraftingMode()) {
this.craftSlot.xDisplayPosition = -9000;
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
}
} else {
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = -9000;
}
}
}
@Override
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
super.putStackInSlot(par1, par2ItemStack);
this.getAndUpdateOutput();
}
@Override
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
super.putStacksInSlots(par1ArrayOfItemStack);
this.getAndUpdateOutput();
}
private ItemStack getAndUpdateOutput() {
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
for (int x = 0; x < ic.getSizeInventory(); x++) {
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
}
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
this.cOut.setInventorySlotContents(0, is);
return is;
}
@Override
public void saveChanges() {}
@Override
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {}
public void encodeAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack(null);
}
}
public void encode() {
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if (in == null || out == null) {
return;
}
// first check the output slots, should either be null, or a pattern
if (output != null && !this.isPattern(output)) {
return;
} // if nothing is there we should snag a new pattern.
else if (output == null) {
output = this.patternSlotIN.getStack();
if (!this.isPattern(output)) {
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if (output.stackSize == 0) {
this.patternSlotIN.putStack(null);
}
// add a new encoded pattern.
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack(output);
}
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack(output);
}
}
// encode the slot.
final NBTTagCompound encodedValue = new NBTTagCompound();
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for (final ItemStack i : in) {
tagIn.appendTag(this.createItemTag(i));
}
for (final ItemStack i : out) {
tagOut.appendTag(this.createItemTag(i));
}
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("crafting", this.isCraftingMode());
encodedValue.setBoolean("substitute", this.isSubstitute());
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
output.setTagCompound(encodedValue);
}
private ItemStack[] getInputs() {
final ItemStack[] input = new ItemStack[9];
boolean hasValue = false;
for (int x = 0; x < this.craftingSlots.length; x++) {
input[x] = this.craftingSlots[x].getStack();
if (input[x] != null) {
hasValue = true;
}
}
if (hasValue) {
return input;
}
return null;
}
private ItemStack[] getOutputs() {
if (this.isCraftingMode()) {
final ItemStack out = this.getAndUpdateOutput();
if (out != null && out.stackSize > 0) {
return new ItemStack[] {out};
}
} else {
final List<ItemStack> list = new ArrayList<>(3);
boolean hasValue = false;
for (final OptionalSlotFake outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out != null && out.stackSize > 0) {
list.add(out);
hasValue = true;
}
}
if (hasValue) {
return list.toArray(new ItemStack[list.size()]);
}
}
return null;
}
private boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return isPattern;
}
private NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
}
return c;
}
@Override
public boolean isSlotEnabled(final int idx) {
if (idx == 1) {
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
} else if (idx == 2) {
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
} else {
return false;
}
}
public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) {
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorPlayerHand(this.getPlayerInv().player);
final InventoryAdaptor playerInv =
InventoryAdaptor.getAdaptor(this.getPlayerInv().player, ForgeDirection.UNKNOWN);
if (packetPatternSlot.shift) {
inv = playerInv;
}
if (inv.simulateAdd(out.getItemStack()) != null) {
return;
}
final IAEItemStack extracted = Platform.poweredExtraction(
this.getPowerSource(), this.getCellInventory(), out, this.getActionSource());
final EntityPlayer p = this.getPlayerInv().player;
if (extracted != null) {
inv.addItems(extracted.getItemStack());
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
return;
}
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(
x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack());
}
final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj);
if (r == null) {
return;
}
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal().getItemInventory();
final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult(ic);
for (int x = 0; x < ic.getSizeInventory(); x++) {
if (ic.getStackInSlot(x) != null) {
final ItemStack pulled = Platform.extractItemsByRecipe(
this.getPowerSource(),
this.getActionSource(),
storage,
p.worldObj,
r,
is,
ic,
ic.getStackInSlot(x),
x,
all,
Actionable.MODULATE,
ItemViewCell.createFilter(this.getViewCells()));
real.setInventorySlotContents(x, pulled);
}
}
final IRecipe rr = Platform.findMatchingRecipe(real, p.worldObj);
if (rr == r && Platform.isSameItemPrecise(rr.getCraftingResult(real), is)) {
final SlotCrafting sc = new SlotCrafting(p, real, this.cOut, 0, 0, 0);
sc.onPickupFromSlot(p, is);
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x));
if (failed != null) {
p.dropPlayerItemWithRandomChoice(failed, false);
}
}
inv.addItems(is);
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
} else {
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = real.getStackInSlot(x);
if (failed != null) {
this.getCellInventory()
.injectItems(
AEItemStack.create(failed),
Actionable.MODULATE,
new MachineSource(this.getPatternTerminal()));
}
}
}
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) {
this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe());
this.updateOrderOfOutputSlots();
}
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
}
}
@Override
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("craftingMode")) {
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
@Override
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && 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 void clear() {
for (final Slot s : this.craftingSlots) {
s.putStack(null);
}
for (final Slot s : this.outputSlots) {
s.putStack(null);
}
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
private void setCraftingMode(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
public PartFluidPatternTerminal getPatternTerminal() {
return this.patternTerminal;
}
private boolean canBeSubstitute() {
return this.beSubstitute;
}
private boolean isSubstitute() {
return this.substitute;
}
public void setSubstitute(final boolean substitute) {
this.substitute = substitute;
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName(name);
}
@Override
public boolean useRealItems() {
return false;
}
public void toggleSubstitute() {
this.substitute = !this.substitute;
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
public boolean isCraftingMode() {
return this.craftingMode;
}
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();
}
}
}
@@ -1,6 +0,0 @@
package com.glodblock.github.client.gui.container;
public enum FluidPrioritization {
ENABLED,
DISABLED;
}
@@ -1,26 +1,31 @@
package com.glodblock.github.client.gui.container;
package com.glodblock.github.client.gui.container.base;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.*;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
import com.glodblock.github.inventory.IPatternConsumer;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
@@ -30,65 +35,49 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
public class FCBasePartContainerEx extends FCBaseMonitorContain
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
protected final FCFluidEncodeTerminal patternTerminal;
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
protected final IInventory crafting;
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
protected SlotFake[] craftingSlots;
protected OptionalSlotFake[] outputSlots;
protected SlotPatternTerm craftSlot;
protected final ProcessingSlotFake[] craftingSlots =
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
@GuiSync(97)
public boolean craftingMode = true;
private final PartFluidPatternTerminalEx patternTerminal;
protected final ProcessingSlotFake[] outputSlots =
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
@GuiSync(96)
public boolean substitute = false;
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable, false);
this.patternTerminal = (PartFluidPatternTerminalEx) monitorable;
@GuiSync(95)
public boolean combine = false;
@GuiSync(94)
public boolean beSubstitute = false;
@GuiSync(93)
public boolean inverted;
@GuiSync(92)
public int activePage = 0;
@GuiSync(91)
public boolean prioritize = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (FCFluidEncodeTerminal) monitorable;
this.inverted = patternTerminal.isInverted();
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++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
crafting,
this,
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
15,
-83,
x,
y,
x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
output,
this,
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
112,
-83,
-x,
y,
x));
}
}
}
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
this.crafting = this.patternTerminal.getInventoryByName("crafting");
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
@@ -105,45 +94,96 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
147,
-72 + 34,
this.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit(1);
this.bindPlayerInventory(ip, 0, 0);
}
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
if (this.isCraftingMode()) {
super.doAction(player, action, slotId, id);
return;
}
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
super.doAction(player, action, slotId, id);
return;
}
if (action == InventoryAction.MOVE_REGION) {
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
return;
}
if (action == InventoryAction.PICKUP_SINGLE) {
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
return;
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if (validPatternSlot(slot)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
fluid = Util.getFluidFromItem(stack);
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
case SPLIT_OR_PLACE_SINGLE:
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
if (fluid != null && fluid.equals(origin)) {
fluid.amount += origin.amount;
if (fluid.amount <= 0) fluid = null;
}
slot.putStack(ItemFluidPacket.newStack(fluid));
break;
}
if (fluid == null) {
super.doAction(player, action, slotId, id);
return;
}
return;
}
super.doAction(player, action, slotId, id);
}
@GuiSync(96 + (17 - 9) + 11)
public boolean combine = false;
protected abstract boolean validPatternSlot(Slot slot);
@GuiSync(96 + (17 - 9) + 12)
public boolean substitute = false;
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null
&& !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
this.detectAndSendChanges();
return null;
} else {
return super.transferStackInSlot(p, idx);
}
}
@GuiSync(96 + (17 - 9) + 16)
public boolean inverted;
public FCFluidEncodeTerminal getPatternTerminal() {
return this.patternTerminal;
}
@GuiSync(96 + (17 - 9) + 17)
public int activePage = 0;
@GuiSync(96 + (17 - 9) + 13)
public boolean prioritize = false;
@GuiSync(96 + (17 - 9) + 14)
public boolean beSubstitute = false;
static boolean canDoubleStacks(SlotFake[] slots) {
protected static boolean canDoubleStacks(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots =
long emptySlots =
enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream()
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
.count();
return fullSlots <= emptyStots;
return fullSlots <= emptySlots;
}
static void doubleStacksInternal(SlotFake[] slots) {
protected static void doubleStacksInternal(SlotFake[] slots) {
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
@@ -173,7 +213,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
assert !ow.hasNext();
}
static boolean containsItem(SlotFake[] slots) {
protected static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream()
@@ -182,7 +222,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
return item > 0;
}
static boolean containsFluid(SlotFake[] slots) {
protected static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream()
@@ -191,18 +231,67 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
return fluid > 0;
}
protected static boolean nonNullSlot(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long object = enabledSlots.stream().filter(s -> s.getStack() != null).count();
return object > 0;
}
protected boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
}
boolean hasFluid = containsFluid(this.craftingSlots);
boolean search = nonNullSlot(this.craftingSlots);
if (!search) { // search=false -> inputs were empty
return false;
}
hasFluid |= containsFluid(this.outputSlots);
search = nonNullSlot(this.outputSlots);
return hasFluid && search; // search=false -> outputs were empty
}
protected void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(this.craftingSlots));
pattern.setOutputs(collectInventory(this.outputSlots));
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
}
protected static IAEItemStack[] collectInventory(Slot[] slots) {
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
stacks[i] = aeStack;
}
return stacks;
}
@Override
public void saveChanges() {}
public void saveChanges() {
// NO-OP
}
public void clear() {
for (final Slot s : this.craftingSlots) {
s.putStack(null);
}
for (final Slot s : this.outputSlots) {
s.putStack(null);
}
this.detectAndSendChanges();
}
@@ -212,7 +301,9 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {}
final ItemStack newStack) {
// NO-OP
}
public void encodeAndMoveToInventory() {
encode();
@@ -225,9 +316,43 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
}
}
public void encode() {
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
}
public void encode() {
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
}
ItemStack stack = this.patternSlotOUT.getStack();
if (stack == null) {
stack = this.patternSlotIN.getStack();
if (notPattern(stack)) {
return;
}
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize--;
}
encodeFluidPattern();
} else if (!notPattern(stack)) {
encodeFluidPattern();
}
}
public void encodeItemPattern() {
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
@@ -235,14 +360,13 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
if (in == null || out == null) {
return;
}
// first check the output slots, should either be null, or a pattern
if (output != null && !this.isPattern(output)) {
if (output != null && this.notPattern(output)) {
return;
} // if nothing is there we should snag a new pattern.
else if (output == null) {
output = this.patternSlotIN.getStack();
if (!this.isPattern(output)) {
if (this.notPattern(output)) {
return; // no blanks.
}
@@ -290,137 +414,78 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("substitute", this.isSubstitute());
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("prioritize", this.isPrioritize());
encodedValue.setBoolean("crafting", this.craftingMode);
encodedValue.setBoolean("substitute", this.substitute);
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
encodedValue.setBoolean("prioritize", this.prioritize);
output.setTagCompound(encodedValue);
}
private ItemStack[] getInputs() {
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
boolean hasValue = false;
for (int x = 0; x < this.craftingSlots.length; x++) {
input[x] = this.craftingSlots[x].getStack();
if (input[x] != null) {
hasValue = true;
}
protected ItemStack[] getInputs() {
final ArrayList<ItemStack> input = new ArrayList<>();
for (SlotFake craftingSlot : this.craftingSlots) {
input.add(craftingSlot.getStack());
}
if (hasValue) {
return input;
if (input.stream().anyMatch(Objects::nonNull)) {
return input.toArray(new ItemStack[0]);
}
return null;
}
private ItemStack[] getOutputs() {
final List<ItemStack> list = new ArrayList<>(CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES);
boolean hasValue = false;
for (final OptionalSlotFake outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if (out != null && out.stackSize > 0) {
list.add(out);
hasValue = true;
}
protected ItemStack[] getOutputs() {
final ArrayList<ItemStack> output = new ArrayList<>();
for (final SlotFake outputSlot : this.outputSlots) {
output.add(outputSlot.getStack());
}
if (hasValue) {
return list.toArray(new ItemStack[0]);
if (output.stream().anyMatch(Objects::nonNull)) {
return output.toArray(new ItemStack[0]);
}
return null;
}
private boolean isPattern(final ItemStack output) {
protected boolean notPattern(final ItemStack output) {
if (output == null) {
return false;
return true;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return isPattern;
return !isPattern;
}
private NBTBase createItemTag(final ItemStack i) {
protected NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if (i != null) {
i.writeToNBT(c);
c.setInteger("Count", i.stackSize);
}
return c;
}
@Override
public boolean isSlotEnabled(final int idx) {
if (idx < 4) // outputs
{
return inverted || idx == 0;
} else {
return !inverted || idx == 4;
}
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isServer()) {
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine(); // Check out
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
}
private void offsetSlots() {
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(
page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(
page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate(field, oldValue, newValue);
if (field.equals("inverted") || field.equals("activePage")) {
offsetSlots();
}
}
@Override
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
inverted = patternTerminal.isInverted();
for (final Object crafter : this.crafters) {
final ICrafting icrafting = (ICrafting) crafter;
for (final Object g : this.inventorySlots) {
if (g instanceof OptionalSlotFake) {
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
final Slot sri = (Slot) g;
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
}
@@ -436,7 +501,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName(name);
return this.patternTerminal.getInventoryByName(name);
}
@Override
@@ -444,48 +509,6 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
return false;
}
public PartFluidPatternTerminalEx getPatternTerminal() {
return this.patternTerminal;
}
private boolean isSubstitute() {
return this.substitute;
}
private boolean isPrioritize() {
return this.prioritize;
}
private boolean canBeSubstitute() {
return this.beSubstitute;
}
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(
IInventory inv,
IOptionalSlotHost containerBus,
int idx,
int x,
int y,
int offX,
int offY,
int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
public void doubleStacks(boolean isShift) {
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
doubleStacksInternal(this.craftingSlots);
@@ -500,11 +523,14 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain
}
}
public void setActivePage(final int activePage) {
this.activePage = activePage;
@Override
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
if (this.patternTerminal != null) {
this.patternTerminal.onChangeCrafting(inputs, outputs);
}
}
public int getActivePage() {
return this.activePage;
public boolean isCraftingMode() {
return this.craftingMode;
}
}
@@ -1,4 +1,4 @@
package com.glodblock.github.client.gui.container;
package com.glodblock.github.client.gui.container.base;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
@@ -23,9 +23,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable {
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
public FCContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
super(ip, te);
}
@@ -1,23 +1,13 @@
package com.glodblock.github.client.gui.container;
package com.glodblock.github.client.gui.container.base;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.parts.IPart;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.container.AEBaseContainer;
@@ -27,14 +17,10 @@ import appeng.core.AELog;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.me.helpers.ChannelPowerSrc;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import java.io.IOException;
import java.nio.BufferOverflowException;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -42,16 +28,13 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class FCBaseMonitorContain extends AEBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<T> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
private final IConfigManager clientCM;
private final ITerminalHost host;
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
protected final IConfigManager clientCM;
protected final ITerminalHost host;
@GuiSync(99)
public boolean canAccessViewCells = false;
@@ -59,77 +42,26 @@ public class FCBaseMonitorContain extends AEBaseContainer
@GuiSync(98)
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
protected IConfigManagerHost gui;
protected IConfigManager serverCM;
protected IGridNode networkNode;
protected IMEMonitor<T> monitor;
public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) {
public FCContainerMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected FCBaseMonitorContain(
protected FCContainerMonitor(
final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(
ip,
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
monitorable instanceof IPart ? (IPart) monitorable : null);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory(this.monitor);
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(
this.networkNode, (IEnergySource) g.getCache(IEnergyGrid.class)));
}
}
}
} else {
this.setValidContainer(false);
}
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
public IGridNode getNetworkNode() {
@@ -139,10 +71,9 @@ public class FCBaseMonitorContain extends AEBaseContainer
@Override
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (this.monitor != this.host.getItemInventory()) {
if (isInvalid()) {
this.setValidContainer(false);
}
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
@@ -159,35 +90,8 @@ public class FCBaseMonitorContain extends AEBaseContainer
}
}
}
if (!this.items.isEmpty()) {
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
for (final IAEItemStack is : this.items) {
final IAEItemStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendItem(is);
} else {
piu.appendItem(send);
}
}
if (!piu.isEmpty()) {
this.items.resetStatus();
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
}
}
processItemList();
this.updatePowerStatus();
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject || this.hasAccess(SecurityPermissions.BUILD, false);
@@ -198,11 +102,16 @@ public class FCBaseMonitorContain extends AEBaseContainer
}
}
}
super.detectAndSendChanges();
}
}
protected abstract void processItemList();
protected boolean isInvalid() {
return this.monitor != this.host.getItemInventory();
}
protected void updatePowerStatus() {
try {
if (this.networkNode != null) {
@@ -213,8 +122,7 @@ public class FCBaseMonitorContain extends AEBaseContainer
this.setPowered(
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
} catch (final Throwable t) {
// :P
} catch (final Throwable ignore) {
}
}
@@ -227,7 +135,6 @@ public class FCBaseMonitorContain extends AEBaseContainer
}
}
}
super.onUpdate(field, oldValue, newValue);
}
@@ -237,33 +144,7 @@ public class FCBaseMonitorContain extends AEBaseContainer
this.queueInventory(c);
}
private void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
for (final IAEItemStack send : monitorCache) {
try {
piu.appendItem(send);
} catch (final BufferOverflowException boe) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
piu = new SPacketMEInventoryUpdate();
piu.appendItem(send);
}
}
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
@Override
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if (this.crafters.isEmpty() && this.monitor != null) {
this.monitor.removeListener(this);
}
}
protected abstract void queueInventory(final ICrafting c);
@Override
public void onContainerClosed(final EntityPlayer player) {
@@ -274,18 +155,44 @@ public class FCBaseMonitorContain extends AEBaseContainer
}
@Override
public boolean isValid(final Object verificationToken) {
return true;
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered() {
return this.hasPower;
}
protected void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
protected IConfigManagerHost getGui() {
return this.gui;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
@Override
public void postChange(
final IBaseMonitor<IAEItemStack> monitor,
final Iterable<IAEItemStack> change,
final BaseActionSource source) {
for (final IAEItemStack is : change) {
this.items.add(is);
}
public boolean isValid(Object verificationToken) {
return true;
}
@Override
@@ -304,42 +211,4 @@ public class FCBaseMonitorContain extends AEBaseContainer
this.getGui().updateSetting(manager, settingName, newValue);
}
}
@Override
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered() {
return this.hasPower;
}
private void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
private IConfigManagerHost getGui() {
return this.gui;
}
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
}
@@ -35,7 +35,6 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
@@ -53,7 +52,6 @@ public class FluidRepo extends ItemRepo {
private String searchString = "";
private IPartitionList<IAEItemStack> myPartitionList;
private String innerSearch = "";
private String NEIWord = null;
private boolean hasPower;
@@ -107,35 +105,31 @@ public class FluidRepo extends ItemRepo {
this.view.ensureCapacity(this.list.size());
this.dsp.ensureCapacity(this.list.size());
final Enum viewMode = this.sortSrc.getSortDisplay();
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
final Enum<?> viewMode = this.sortSrc.getSortDisplay();
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
this.updateNEI(this.searchString);
}
this.innerSearch = this.searchString;
final boolean terminalSearchToolTips =
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
String innerSearch = this.searchString;
boolean searchMod = false;
if (this.innerSearch.startsWith("@")) {
if (innerSearch.startsWith("@")) {
searchMod = true;
this.innerSearch = this.innerSearch.substring(1);
innerSearch = innerSearch.substring(1);
}
Pattern m = null;
Pattern m;
try {
m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
m = Pattern.compile(innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
} catch (final Throwable ignore) {
try {
m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
m = Pattern.compile(Pattern.quote(innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
} catch (final Throwable __) {
return;
}
}
boolean notDone = false;
for (IAEItemStack is : this.list) {
if (this.myPartitionList != null) {
if (!this.myPartitionList.isListed(is)) {
@@ -166,27 +160,22 @@ public class FluidRepo extends ItemRepo {
this.view.add(is);
}
}
/*
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
* view.add( is ); notDone = false; } }
*/
}
final Enum SortBy = this.sortSrc.getSortBy();
final Enum SortDir = this.sortSrc.getSortDir();
final Enum<?> SortBy = this.sortSrc.getSortBy();
final Enum<?> SortDir = this.sortSrc.getSortDir();
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
FluidSorters.init();
if (SortBy == SortOrder.MOD) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD);
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_MOD);
} else if (SortBy == SortOrder.AMOUNT) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
} else if (SortBy == SortOrder.INVTWEAKS) {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
} else {
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME);
this.view.sort(FluidSorters.CONFIG_BASED_SORT_BY_NAME);
}
for (final IAEItemStack is : this.view) {
@@ -54,6 +54,7 @@ public class BlockFluidBuffer extends FCBaseBlock {
return fs != null || (player.isSneaking() && itemStack == null);
}
@Override
public BlockFluidBuffer register() {
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_BUFFER);
GameRegistry.registerTileEntity(TileFluidBuffer.class, NameConst.BLOCK_FLUID_BUFFER);
@@ -67,17 +68,8 @@ public class BlockFluidBuffer extends FCBaseBlock {
return new RenderBlockFluidBuffer();
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
@@ -23,6 +23,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
setTileEntity(TileFluidDiscretizer.class);
}
@Override
public BlockFluidDiscretizer register() {
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
GameRegistry.registerTileEntity(TileFluidDiscretizer.class, NameConst.BLOCK_FLUID_DISCRETIZER);
@@ -30,17 +31,8 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
@@ -18,8 +18,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
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;
import net.minecraftforge.common.util.ForgeDirection;
@@ -57,7 +55,11 @@ public class BlockFluidInterface extends FCBaseBlock {
if (tg != null) {
if (Platform.isServer()) {
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
player,
world,
new BlockPos(x, y, z),
ForgeDirection.getOrientation(facing),
GuiType.DUAL_INTERFACE);
}
return true;
}
@@ -76,18 +78,11 @@ public class BlockFluidInterface extends FCBaseBlock {
}
}
@Override
public BlockFluidInterface register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_INTERFACE);
GameRegistry.registerTileEntity(TileFluidInterface.class, NameConst.BLOCK_FLUID_INTERFACE);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -16,8 +16,8 @@ import java.util.List;
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;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFluidPacketDecoder extends FCBaseBlock {
@@ -41,7 +41,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
ForgeDirection.getOrientation(facing),
GuiType.FLUID_PACKET_DECODER);
}
return true;
@@ -49,6 +49,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
return false;
}
@Override
public BlockFluidPacketDecoder register() {
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
GameRegistry.registerTileEntity(TileFluidPacketDecoder.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
@@ -56,17 +57,8 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
@@ -10,9 +10,8 @@ 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;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFluidPatternEncoder extends FCBaseBlock {
@@ -36,7 +35,7 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
ForgeDirection.getOrientation(facing),
GuiType.FLUID_PATTERN_ENCODER);
}
return true;
@@ -44,18 +43,11 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
return false;
}
@Override
public BlockFluidPatternEncoder register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
GameRegistry.registerTileEntity(TileFluidPatternEncoder.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -10,9 +10,8 @@ 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;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockIngredientBuffer extends FCBaseBlock {
@@ -34,25 +33,22 @@ public class BlockIngredientBuffer extends FCBaseBlock {
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER);
player,
world,
new BlockPos(x, y, z),
ForgeDirection.getOrientation(facing),
GuiType.INGREDIENT_BUFFER);
}
return true;
}
return false;
}
@Override
public BlockIngredientBuffer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_INGREDIENT_BUFFER);
GameRegistry.registerTileEntity(TileIngredientBuffer.class, NameConst.BLOCK_INGREDIENT_BUFFER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -10,9 +10,8 @@ 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;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockLargeIngredientBuffer extends FCBaseBlock {
@@ -37,7 +36,7 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
ForgeDirection.getOrientation(facing),
GuiType.LARGE_INGREDIENT_BUFFER);
}
return true;
@@ -45,18 +44,11 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
return false;
}
@Override
public BlockLargeIngredientBuffer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
GameRegistry.registerTileEntity(TileLargeIngredientBuffer.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -22,8 +22,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockLevelMaintainer extends FCBaseBlock {
@@ -34,6 +34,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
setTileEntity(TileLevelMaintainer.class);
}
@Override
public BlockLevelMaintainer register() {
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER);
GameRegistry.registerTileEntity(TileLevelMaintainer.class, NameConst.BLOCK_LEVEL_MAINTAINER);
@@ -61,7 +62,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
ForgeDirection.getOrientation(facing),
GuiType.LEVEL_MAINTAINER);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
@@ -72,17 +73,8 @@ public class BlockLevelMaintainer extends FCBaseBlock {
return false;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
@@ -11,9 +11,8 @@ 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;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockOCPatternEditor extends FCBaseBlock {
@@ -34,13 +33,18 @@ public class BlockOCPatternEditor extends FCBaseBlock {
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
player,
world,
new BlockPos(x, y, z),
ForgeDirection.getOrientation(facing),
GuiType.OC_PATTERN_EDITOR);
}
return true;
}
return false;
}
@Override
public BlockOCPatternEditor register() {
if (ModAndClassUtil.OC) {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
@@ -50,12 +54,4 @@ public class BlockOCPatternEditor extends FCBaseBlock {
}
return null;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -3,6 +3,7 @@ package com.glodblock.github.common.block;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.IRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
@@ -13,7 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class FCBaseBlock extends AEBaseTileBlock {
public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<FCBaseBlock> {
public FCBaseBlock(Material mat, String name) {
super(mat);
@@ -39,7 +40,6 @@ public class FCBaseBlock extends AEBaseTileBlock {
super.setFeature(f);
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(
final ItemStack itemStack,
@@ -47,7 +47,8 @@ public class FCBaseBlock extends AEBaseTileBlock {
final List<String> toolTip,
final boolean advancedToolTips) {}
protected final List listFormattedStringToWidth(String str) {
@SuppressWarnings("unchecked")
protected final List<String> listFormattedStringToWidth(String str) {
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
}
@@ -55,4 +56,12 @@ public class FCBaseBlock extends AEBaseTileBlock {
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {
this.addInformation(itemStack, player, toolTip, advancedToolTips);
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -0,0 +1,20 @@
package com.glodblock.github.common.item;
import com.glodblock.github.loader.IRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public abstract class FCBaseItem extends Item implements IRegister<FCBaseItem> {
public ItemStack stack(int size, int meta) {
return new ItemStack(this, size, meta);
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -18,7 +18,6 @@ public class FCBaseItemBlock extends AEBaseItemBlock {
}
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addCheckedInformation(
final ItemStack itemStack,
final EntityPlayer player,
@@ -25,6 +25,7 @@ import com.glodblock.github.common.storage.IFluidCellInventory;
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
import com.glodblock.github.common.storage.IStorageFluidCell;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.google.common.base.Optional;
@@ -46,7 +47,8 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell {
public class ItemBasicFluidStorageCell extends AEBaseItem
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
private final CellType component;
private final int totalBytes;
private final int perType;
@@ -151,7 +153,11 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
format.toWideReadableForm(fluid.getStackSize())));
}
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
}
if (handler.isPreformatted()) {
@@ -167,6 +173,8 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
if (aeFluidStack != null)
lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
}
} else {
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -255,6 +263,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
return stack;
}
@SuppressWarnings("unchecked")
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
@@ -297,11 +306,9 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
player.dropPlayerItemWithRandomChoice(extraA, false);
}
}
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
return true;
}
}
@@ -322,7 +329,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
final float hitY,
final float hitZ) {
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
return this.disassembleDrive(stack, world, player);
}
@@ -336,7 +342,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
.asSet()) {
return stack;
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@@ -345,6 +350,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
}
@Override
public ItemBasicFluidStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
@@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
public class ItemBasicFluidStoragePart extends Item {
public class ItemBasicFluidStoragePart extends FCBaseItem {
public static final int types = 7;
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
@@ -56,6 +56,7 @@ public class ItemBasicFluidStoragePart extends Item {
return icon.get(meta);
}
@Override
public ItemBasicFluidStoragePart register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PART, FluidCraft.MODID);
@@ -27,7 +27,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class ItemFluidDrop extends Item {
public class ItemFluidDrop extends FCBaseItem {
@SideOnly(Side.CLIENT)
public IIcon shape;
@@ -96,22 +96,14 @@ public class ItemFluidDrop extends Item {
}
public static boolean isFluidStack(ItemStack stack) {
if (getFluidStack(stack) != null) {
return true;
} else {
return false;
}
return getFluidStack(stack) != null;
}
public static boolean isFluidStack(@Nullable IAEItemStack stack) {
if (stack == null) {
return false;
}
if (getFluidStack(stack.getItemStack()) != null) {
return true;
} else {
return false;
}
return getFluidStack(stack.getItemStack()) != null;
}
public static FluidStack getFluidStack(ItemStack stack) {
@@ -169,6 +161,7 @@ public class ItemFluidDrop extends Item {
return stack;
}
@Override
public ItemFluidDrop register() {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_DROP, FluidCraft.MODID);
return this;
@@ -3,13 +3,14 @@ package com.glodblock.github.common.item;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.items.misc.ItemEncodedPattern;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemFluidEncodedPattern extends ItemEncodedPattern {
public class ItemFluidEncodedPattern extends ItemEncodedPattern implements IRegister<ItemFluidEncodedPattern> {
public ItemFluidEncodedPattern() {
super();
@@ -23,6 +24,7 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
return pattern.readFromStack() ? pattern : null;
}
@Override
public ItemFluidEncodedPattern register() {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_ENCODED_PATTERN, FluidCraft.MODID);
return this;
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemFluidExportBus extends Item implements IPartItem {
public class ItemFluidExportBus extends FCBaseItem implements IPartItem {
public ItemFluidExportBus() {
this.setMaxStackSize(64);
@@ -46,6 +45,7 @@ public class ItemFluidExportBus extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemFluidExportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
@@ -61,12 +61,4 @@ public class ItemFluidExportBus extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemFluidImportBus extends Item implements IPartItem {
public class ItemFluidImportBus extends FCBaseItem implements IPartItem {
public ItemFluidImportBus() {
this.setMaxStackSize(64);
@@ -46,6 +45,7 @@ public class ItemFluidImportBus extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemFluidImportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
@@ -61,12 +61,4 @@ public class ItemFluidImportBus extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -12,13 +12,12 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class ItemFluidLevelEmitter extends Item implements IPartItem {
public class ItemFluidLevelEmitter extends FCBaseItem implements IPartItem {
public ItemFluidLevelEmitter() {
this.setMaxStackSize(64);
@@ -47,6 +46,7 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemFluidLevelEmitter register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_LEVEL_EMITTER, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -63,12 +63,4 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -14,7 +14,6 @@ import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -24,7 +23,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public class ItemFluidPacket extends Item {
public class ItemFluidPacket extends FCBaseItem {
public ItemFluidPacket() {
setUnlocalizedName(NameConst.ITEM_FLUID_PACKET);
@@ -141,12 +140,9 @@ public class ItemFluidPacket extends Item {
return tFluid == null ? 16777215 : tFluid.getColor();
}
@Override
public ItemFluidPacket register() {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PACKET, FluidCraft.MODID);
return this;
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemPartFluidInterface extends Item implements IPartItem {
public class ItemPartFluidInterface extends FCBaseItem implements IPartItem {
public ItemPartFluidInterface() {
this.setMaxStackSize(64);
@@ -45,6 +44,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemPartFluidInterface register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_INTERFACE, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -59,12 +59,4 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
public class ItemPartFluidPatternTerminal extends FCBaseItem implements IPartItem {
public ItemPartFluidPatternTerminal() {
this.setMaxStackSize(64);
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemPartFluidPatternTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
public class ItemPartFluidPatternTerminalEx extends FCBaseItem implements IPartItem {
public ItemPartFluidPatternTerminalEx() {
this.setMaxStackSize(64);
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemPartFluidPatternTerminalEx register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class ItemPartFluidStorageBus extends Item implements IPartItem {
public class ItemPartFluidStorageBus extends FCBaseItem implements IPartItem {
public ItemPartFluidStorageBus() {
this.setMaxStackSize(64);
@@ -45,6 +44,7 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
@Override
public ItemPartFluidStorageBus register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_STORAGE_BUS, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -59,12 +59,4 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -15,12 +15,11 @@ import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class ItemPartFluidTerminal extends Item implements IPartItem {
public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
public ItemPartFluidTerminal() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_TERMINAL);
@@ -55,6 +54,7 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
}
@Override
public ItemPartFluidTerminal register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_TERMINAL, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
@@ -69,12 +69,4 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -25,8 +25,8 @@ import appeng.util.item.AEItemStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -36,7 +36,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingRequester {
public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingRequester {
private final BaseActionSource source;
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
@@ -229,8 +229,7 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR
protected InventoryAdaptor getHandler(TileEntity target) {
return target != null
? FluidConvertingInventoryAdaptor.wrap(
target, Util.from(this.getSide().getOpposite()))
? FluidConvertingInventoryAdaptor.wrap(target, this.getSide().getOpposite())
: null;
}
@@ -15,6 +15,7 @@ import appeng.me.GridAccessException;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
@@ -25,7 +26,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidImportBus extends PartSharedFluidBus {
public class PartFluidImportBus extends FCSharedFluidBus {
private final BaseActionSource source;
@@ -24,8 +24,8 @@ import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
@@ -46,9 +46,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
public class PartFluidInterface extends PartInterface implements IDualHost {
private final BaseActionSource ownActionSource = new MachineSource(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
@@ -136,23 +135,19 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
fluidDuality.gridChanged();
}
@Override
public DualityFluidInterface getDualityFluid() {
return fluidDuality;
}
@Override
public AEFluidInventory getInternalFluid() {
return fluidDuality.getTanks();
}
@Override
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
} else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
Util.mirrorFluidToPacket(this.config, fluidDuality.getConfig());
return config;
}
@@ -161,24 +156,8 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
super.writeToStream(data);
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = 0;
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if (getInternalFluid().getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
getInternalFluid().writeToBuf(data);
}
@Override
@@ -191,27 +170,9 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = data.readByte();
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
getInternalFluid().setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (getInternalFluid().getFluidInSlot(i) != null) {
getInternalFluid().setFluidInSlot(i, null);
changed = true;
}
}
fluidDuality.loadConfigFromPacket(this.config);
changed |= getInternalFluid().readFromBuf(data);
return changed;
}
@@ -219,10 +180,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
fluidDuality.loadConfigFromPacket(this.config);
getInternalFluid().readFromNBT(data, "FluidInv");
}
@@ -307,7 +265,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
Objects.requireNonNull(this.getSide()),
GuiType.DUAL_INTERFACE_PART);
}
return true;
@@ -320,6 +278,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
fluidDuality.onFluidInventoryChanged(inv, slot);
}
@Override
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(
@@ -328,6 +287,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
}
@Override
public void setFluidInv(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
getInternalFluid().setFluidInSlot(id, fluid);
@@ -570,7 +570,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(getSide())),
Objects.requireNonNull(getSide()),
GuiType.FLUID_LEVEL_EMITTER);
return true;
}
@@ -1,122 +1,37 @@
package com.glodblock.github.common.parts;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.networking.IGridHost;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.sync.GuiBridge;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.BiggerAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.BiggerAppEngInventory;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
public class PartFluidPatternTerminal extends FCBasePart {
public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 9);
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 3);
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
private boolean craftingMode = true;
private boolean substitute = false;
private boolean combine = false;
private boolean beSubstitute = false;
public PartFluidPatternTerminal(ItemStack is) {
super(is, true);
super(is);
this.crafting = new BiggerAppEngInventory(this, 9);
this.output = new BiggerAppEngInventory(this, 3);
this.prioritize = false;
this.inverted = false;
this.activePage = 0;
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
for (final ItemStack is : this.pattern) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
InventoryHandler.openGui(
player,
te.getWorldObj(),
tePos,
Objects.requireNonNull(Util.from(getSide())),
GuiType.FLUID_PATTERN_TERMINAL);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
return true;
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.setCraftingRecipe(data.getBoolean("craftingMode"));
this.setSubstitution(data.getBoolean("substitute"));
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");
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setBoolean("craftingMode", this.craftingMode);
data.setBoolean("substitute", this.substitute);
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");
}
@Override
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_PATTERN_TERMINAL;
}
return GuiBridge.GUI_ME;
public GuiType getGui() {
return GuiType.FLUID_PATTERN_TERMINAL;
}
@Override
@@ -141,7 +56,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(details.canBeSubstitute());
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
@@ -189,69 +104,39 @@ public class PartFluidPatternTerminal extends FCBasePart {
}
}
public boolean isCraftingRecipe() {
return this.craftingMode;
}
public void setCraftingRecipe(final boolean craftingMode) {
this.craftingMode = craftingMode;
super.setCraftingRecipe(craftingMode);
this.fixCraftingRecipes();
}
public boolean isSubstitution() {
return this.substitute;
}
public boolean shouldCombine() {
return this.combine;
}
public void setSubstitution(boolean canSubstitute) {
this.substitute = canSubstitute;
}
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());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
}
@Override
public void setPrioritization(boolean canPrioritize) {
this.prioritize = false;
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("crafting")) {
return this.crafting;
}
public boolean isPrioritize() {
return false;
}
if (name.equals("output")) {
return this.output;
}
@Override
public boolean isInverted() {
return false;
}
if (name.equals("pattern")) {
return this.pattern;
}
@Override
public void setInverted(boolean inverted) {
this.inverted = false;
}
return super.getInventoryByName(name);
@Override
public int getActivePage() {
return 0;
}
@Override
public void setActivePage(int activePage) {
this.activePage = 0;
}
@Override
@@ -1,132 +1,35 @@
package com.glodblock.github.common.parts;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.networking.IGridHost;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.sync.GuiBridge;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.BiggerAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.BiggerAppEngInventory;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import java.util.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
public class PartFluidPatternTerminalEx extends FCBasePart {
public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 32);
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 32);
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
private boolean substitute = false;
private boolean combine = false;
private boolean prioritize = false;
private boolean inverted = false;
private boolean beSubstitute = false;
private int activePage = 0;
public PartFluidPatternTerminalEx(ItemStack is) {
super(is, true);
super(is);
this.crafting = new BiggerAppEngInventory(this, 32);
this.output = new BiggerAppEngInventory(this, 32);
this.craftingMode = false;
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
for (final ItemStack is : this.pattern) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
InventoryHandler.openGui(
player,
te.getWorldObj(),
tePos,
Objects.requireNonNull(Util.from(getSide())),
GuiType.FLUID_PATTERN_TERMINAL_EX);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
return true;
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
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"));
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
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);
data.setInteger("activePage", this.activePage);
}
@Override
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_PATTERN_TERMINAL;
}
return GuiBridge.GUI_ME;
public GuiType getGui() {
return GuiType.FLUID_PATTERN_TERMINAL_EX;
}
@Override
@@ -149,15 +52,13 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
final IAEItemStack[] outItems = details.getOutputs();
int inputsCount = 0;
int outputCount = 0;
for (int i = 0; i < inItems.length; i++) {
if (inItems[i] != null) {
for (IAEItemStack inItem : inItems) {
if (inItem != null) {
inputsCount++;
}
}
for (int i = 0; i < outItems.length; i++) {
if (outItems[i] != null) {
for (IAEItemStack outItem : outItems) {
if (outItem != null) {
outputCount++;
}
}
@@ -166,7 +67,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(details.canBeSubstitute());
}
this.setInverted(inputsCount <= 8 && outputCount > 8);
this.setActivePage(0);
@@ -219,68 +120,14 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
this.getHost().markForSave();
}
public boolean shouldCombine() {
return this.combine;
}
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
public boolean isSubstitution() {
return this.substitute;
}
public boolean isPrioritize() {
return this.prioritize;
}
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) {
this.prioritize = canPrioritize;
}
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());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
}
@Override
public void setCraftingRecipe(final boolean craftingMode) {
this.craftingMode = false;
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
if (name.equals("pattern")) {
return this.pattern;
}
return super.getInventoryByName(name);
public boolean isCraftingRecipe() {
return false;
}
@Override
@@ -302,20 +149,4 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
public boolean isLightSource() {
return false;
}
public boolean isInverted() {
return inverted;
}
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
public int getActivePage() {
return this.activePage;
}
public void setActivePage(int activePage) {
this.activePage = activePage;
}
}
@@ -33,7 +33,6 @@ import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.prioitylist.PrecisePriorityList;
@@ -44,7 +43,6 @@ import com.glodblock.github.inventory.*;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import extracells.tileentity.TileEntityFluidInterface;
@@ -233,7 +231,7 @@ public class PartFluidStorageBus extends PartUpgradeable
final BaseActionSource source) {
if (this.getProxy().isActive()) {
AccessRestriction currentAccess =
(AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
(AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
if (readOncePass) {
readOncePass = false;
try {
@@ -306,7 +304,7 @@ public class PartFluidStorageBus extends PartUpgradeable
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
Objects.requireNonNull(this.getSide()),
GuiType.FLUID_STORAGE_BUS);
}
return true;
@@ -1,22 +1,11 @@
package com.glodblock.github.common.parts;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGridHost;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.common.parts.base.FCPart;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
public class PartFluidTerminal extends FCBasePart {
public class PartFluidTerminal extends FCPart {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Dark;
@@ -51,42 +40,7 @@ public class PartFluidTerminal extends FCBasePart {
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
InventoryHandler.openGui(
player,
te.getWorldObj(),
tePos,
Objects.requireNonNull(Util.from(getSide())),
GuiType.FLUID_TERMINAL);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
return true;
}
@Override
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if (GuiBridge.GUI_WIRELESS_TERM.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_WIRELESS_TERM;
}
return GuiBridge.GUI_ME;
public GuiType getGui() {
return GuiType.FLUID_TERMINAL;
}
}
@@ -0,0 +1,155 @@
package com.glodblock.github.common.parts.base;
import appeng.api.storage.data.IAEItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public abstract class FCFluidEncodeTerminal extends FCPart {
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
protected final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
protected boolean craftingMode = true;
protected boolean substitute = false;
protected boolean combine = false;
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected int activePage = 0;
public FCFluidEncodeTerminal(ItemStack is) {
super(is, true);
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
super.getDrops(drops, wrenched);
for (final ItemStack is : this.pattern) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.setCraftingRecipe(data.getBoolean("craftingMode"));
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setBoolean("craftingMode", this.craftingMode);
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
data.setBoolean("priorization", this.prioritize);
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
}
public boolean shouldCombine() {
return this.combine;
}
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
public boolean isSubstitution() {
return this.substitute;
}
public boolean isPrioritize() {
return this.prioritize;
}
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) {
this.prioritize = canPrioritize;
}
public boolean isInverted() {
return inverted;
}
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
public int getActivePage() {
return this.activePage;
}
public void setActivePage(int activePage) {
this.activePage = activePage;
}
public void setCraftingRecipe(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
public boolean isCraftingRecipe() {
return this.craftingMode;
}
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());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
}
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
if (name.equals("pattern")) {
return this.pattern;
}
return super.getInventoryByName(name);
}
}
@@ -1,12 +1,10 @@
package com.glodblock.github.common.parts;
package com.glodblock.github.common.parts.base;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.config.*;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.GridFlags;
import appeng.api.networking.IGridHost;
import appeng.api.networking.events.MENetworkBootingStatusChange;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
@@ -18,7 +16,6 @@ import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.IConfigManager;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
import appeng.tile.inventory.AppEngInternalInventory;
@@ -28,11 +25,16 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
@@ -40,12 +42,13 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class FCBasePart extends AEBasePart
public abstract class FCPart extends AEBasePart
implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory {
protected static final int POWERED_FLAG = 4;
@@ -59,11 +62,11 @@ public abstract class FCBasePart extends AEBasePart
private final IConfigManager cm = new ConfigManager(this);
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
public FCBasePart(final ItemStack is) {
public FCPart(final ItemStack is) {
this(is, false);
}
protected FCBasePart(final ItemStack is, final boolean requireChannel) {
protected FCPart(final ItemStack is, final boolean requireChannel) {
super(is);
if (requireChannel) {
@@ -137,9 +140,7 @@ public abstract class FCBasePart extends AEBasePart
this.viewCell.writeToNBT(data, "viewCell");
}
public GuiBridge getGui(final EntityPlayer player) {
return GuiBridge.GUI_ME;
}
public abstract GuiType getGui();
@Override
public void writeToStream(final ByteBuf data) throws IOException {
@@ -148,15 +149,15 @@ public abstract class FCBasePart extends AEBasePart
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
this.clientFlags = this.getClientFlags() | FCBasePart.POWERED_FLAG;
this.clientFlags = this.getClientFlags() | FCPart.POWERED_FLAG;
}
if (this.getProxy().getPath().isNetworkBooting()) {
this.clientFlags = this.getClientFlags() | FCBasePart.BOOTING_FLAG;
this.clientFlags = this.getClientFlags() | FCPart.BOOTING_FLAG;
}
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.clientFlags = this.getClientFlags() | FCBasePart.CHANNEL_FLAG;
this.clientFlags = this.getClientFlags() | FCPart.CHANNEL_FLAG;
}
} catch (final GridAccessException e) {
// um.. nothing.
@@ -215,18 +216,20 @@ public abstract class FCBasePart extends AEBasePart
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
if (!onPartActivate0(player, pos)) {
if (!player.isSneaking()) {
if (Platform.isClient()) {
return true;
}
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui(player));
return true;
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(getSide()), getGui());
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
return false;
return true;
}
@Override
@@ -251,7 +254,6 @@ public abstract class FCBasePart extends AEBasePart
te.yCoord + this.getSide().offsetY,
te.zCoord + this.getSide().offsetZ);
}
return (int) (emit * (this.opacity / 255.0f));
}
@@ -261,7 +263,7 @@ public abstract class FCBasePart extends AEBasePart
if (Platform.isServer()) {
return this.getProxy().getEnergy().isNetworkPowered();
} else {
return ((this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG);
return ((this.getClientFlags() & FCPart.POWERED_FLAG) == FCPart.POWERED_FLAG);
}
} catch (final GridAccessException e) {
return false;
@@ -309,8 +311,8 @@ public abstract class FCBasePart extends AEBasePart
@Override
public final boolean isActive() {
if (!this.isLightSource()) {
return ((this.getClientFlags() & (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG))
== (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG));
return ((this.getClientFlags() & (FCPart.CHANNEL_FLAG | FCPart.POWERED_FLAG))
== (FCPart.CHANNEL_FLAG | FCPart.POWERED_FLAG));
} else {
return this.isPowered();
}
@@ -407,9 +409,9 @@ public abstract class FCBasePart extends AEBasePart
rh.setBounds(4, 4, 13, 12, 12, 14);
rh.renderBlock(x, y, z, renderer);
final boolean hasChan = (this.getClientFlags() & (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG))
== (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG);
final boolean hasPower = (this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG;
final boolean hasChan = (this.getClientFlags() & (FCPart.POWERED_FLAG | FCPart.CHANNEL_FLAG))
== (FCPart.POWERED_FLAG | FCPart.CHANNEL_FLAG);
final boolean hasPower = (this.getClientFlags() & FCPart.POWERED_FLAG) == FCPart.POWERED_FLAG;
if (hasChan) {
final int l = 14;
@@ -1,4 +1,4 @@
package com.glodblock.github.common.parts;
package com.glodblock.github.common.parts.base;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Upgrades;
@@ -15,7 +15,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -26,12 +25,12 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable {
public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridTickable {
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9);
private boolean lastRedstone;
public PartSharedFluidBus(ItemStack is) {
public FCSharedFluidBus(ItemStack is) {
super(is);
}
@@ -75,7 +74,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
Objects.requireNonNull(this.getSide()),
GuiType.FLUID_BUS_IO);
}
@@ -31,15 +31,14 @@ public class FluidCellInventory implements IFluidCellInventory {
private static String[] fluidSlotCount;
private final ItemStack cellItem;
private final ISaveProvider container;
private static final int MAX_TYPE = 1;
private final int MAX_TYPE = 1;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellItems;
private IItemList<IAEFluidStack> cellFluids;
private final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
if (fluidSlots == null) {
fluidSlots = new String[MAX_TYPE];
fluidSlotCount = new String[MAX_TYPE];
@@ -75,7 +74,7 @@ public class FluidCellInventory implements IFluidCellInventory {
this.tagCompound = Platform.openNbtData(o);
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
this.cellItems = null;
this.cellFluids = null;
}
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
@@ -90,13 +89,10 @@ public class FluidCellInventory implements IFluidCellInventory {
if (itemStack == null) {
return false;
}
final Item type = itemStack.getItem();
if (type instanceof IStorageFluidCell) {
return ((IStorageFluidCell) type).isStorageCell(itemStack);
}
return false;
}
@@ -122,7 +118,10 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public boolean canHoldNewFluid() {
return this.getRemainingFluidCount() > 0 && getRemainingFluidTypes() > 0;
final long bytesFree = this.getFreeBytes();
return (bytesFree > this.getBytesPerType()
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
&& this.getRemainingFluidTypes() > 0;
}
@Override
@@ -137,10 +136,8 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getUsedBytes() {
long bytesForItemCount = this.getStoredFluidCount() / singleByteAmount;
long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) + bytesForItemCount;
if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++;
return tmp;
final long bytesForFluidCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / singleByteAmount;
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForFluidCount;
}
@Override
@@ -158,22 +155,26 @@ public class FluidCellInventory implements IFluidCellInventory {
return this.storedFluids;
}
@Override
public long getRemainingFluidTypes() {
final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
final long baseOnTotal = this.getTotalFluidTypes() - this.getStoredFluidTypes();
return Math.min(basedOnStorage, baseOnTotal);
}
@Override
public long getRemainingFluidCount() {
final long remaining = this.getTotalBytes() * singleByteAmount - this.getStoredFluidCount();
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
return remaining > 0 ? remaining : 0;
}
@Override
public int getUnusedFluidCount() {
return (int) (this.getStoredFluidCount() % singleByteAmount);
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
if (div == 0) {
return 0;
}
return singleByteAmount - div;
}
@Override
@@ -187,35 +188,29 @@ public class FluidCellInventory implements IFluidCellInventory {
return 3;
}
private void loadCellItems() {
if (this.cellItems == null) {
this.cellItems = AEApi.instance().storage().createFluidList();
private void loadCellFluids() {
if (this.cellFluids == null) {
this.cellFluids = AEApi.instance().storage().createFluidList();
}
this.cellItems.resetStatus(); // clears totals and stuff.
this.cellFluids.resetStatus(); // clears totals and stuff.
final int types = (int) this.getStoredFluidTypes();
for (int x = 0; x < types; x++) {
final FluidStack t = FluidStack.loadFluidStackFromNBT(this.tagCompound.getCompoundTag(fluidSlots[x]));
final AEFluidStack aet = AEFluidStack.create(t);
if (aet != null) {
aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x]));
if (aet.getStackSize() > 0) {
this.cellItems.add(aet);
this.cellFluids.add(aet);
}
}
}
}
private IItemList<IAEFluidStack> getCellItems() {
if (this.cellItems == null) {
this.loadCellItems();
private IItemList<IAEFluidStack> getCellFluids() {
if (this.cellFluids == null) {
this.loadCellFluids();
}
return this.cellItems;
return this.cellFluids;
}
private void updateFluidCount(final long delta) {
@@ -224,15 +219,12 @@ public class FluidCellInventory implements IFluidCellInventory {
}
private void saveChanges() {
long itemCount = 0;
long fluidCount = 0;
int x = 0;
for (final IAEFluidStack v : this.cellItems) {
itemCount += v.getStackSize();
for (final IAEFluidStack v : this.cellFluids) {
fluidCount += v.getStackSize();
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
if (c instanceof NBTTagCompound) {
v.writeToNBT((NBTTagCompound) c);
} else {
@@ -240,45 +232,29 @@ public class FluidCellInventory implements IFluidCellInventory {
v.writeToNBT(g);
this.tagCompound.setTag(fluidSlots[x], g);
}
/*
* NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
*/
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
x++;
}
// NBTBase tagType = tagCompound.getTag( ITEM_TYPE_TAG );
// NBTBase tagCount = tagCompound.getTag( ITEM_COUNT_TAG );
final short oldStoredItems = this.storedFluids;
final short oldStoredFluids = this.storedFluids;
this.storedFluids = (short) this.cellFluids.size();
/*
* if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size();
* else
*/
this.storedFluids = (short) this.cellItems.size();
if (this.cellItems.isEmpty()) {
if (this.cellFluids.isEmpty()) {
this.tagCompound.removeTag(FLUID_TYPE_TAG);
} else {
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
}
/*
* if ( tagCount instanceof NBTTagInt ) ((NBTTagInt) tagCount).data = storedItemCount = itemCount; else
*/
this.storedFluidCount = itemCount;
this.storedFluidCount = fluidCount;
if (itemCount == 0) {
if (fluidCount == 0) {
this.tagCompound.removeTag(FLUID_COUNT_TAG);
} else {
this.tagCompound.setLong(FLUID_COUNT_TAG, itemCount);
this.tagCompound.setLong(FLUID_COUNT_TAG, fluidCount);
}
// clean any old crusty stuff...
for (; x < oldStoredItems && x < MAX_TYPE; x++) {
for (; x < oldStoredFluids && x < MAX_TYPE; x++) {
this.tagCompound.removeTag(fluidSlots[x]);
this.tagCompound.removeTag(fluidSlotCount[x]);
}
@@ -293,32 +269,27 @@ public class FluidCellInventory implements IFluidCellInventory {
if (input == null) {
return null;
}
if (input.getStackSize() == 0) {
return null;
}
if (this.cellType.isBlackListed(this.cellItem, input)) {
return input;
}
final IAEFluidStack l = this.getCellItems().findPrecise(input);
final IAEFluidStack l = this.getCellFluids().findPrecise(input);
if (l != null) {
final long remainingItemSlots =
this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount;
final long remainingFluidSlots = this.getRemainingFluidCount();
if (remainingItemSlots < 0) {
if (remainingFluidSlots < 0) {
return input;
}
if (input.getStackSize() > remainingItemSlots) {
if (input.getStackSize() > remainingFluidSlots) {
final IAEFluidStack r = input.copy();
r.setStackSize(r.getStackSize() - remainingItemSlots);
r.setStackSize(r.getStackSize() - remainingFluidSlots);
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() + remainingItemSlots);
this.updateFluidCount(remainingItemSlots);
l.setStackSize(l.getStackSize() + remainingFluidSlots);
this.updateFluidCount(remainingFluidSlots);
this.saveChanges();
}
return r;
@@ -328,40 +299,33 @@ public class FluidCellInventory implements IFluidCellInventory {
this.updateFluidCount(input.getStackSize());
this.saveChanges();
}
return null;
}
}
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
{
final long remainingItemCount =
final long remainingFluidCount =
this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount);
if (remainingItemCount > 0) {
if (input.getStackSize() > remainingItemCount) {
if (remainingFluidCount > 0) {
if (input.getStackSize() > remainingFluidCount) {
final IAEFluidStack toReturn = input.copy();
toReturn.decStackSize(remainingItemCount);
toReturn.decStackSize(remainingFluidCount);
if (mode == Actionable.MODULATE) {
IAEFluidStack toWrite = input.copy();
toWrite.setStackSize(remainingItemCount);
this.cellItems.add(toWrite);
toWrite.setStackSize(remainingFluidCount);
this.cellFluids.add(toWrite);
this.updateFluidCount(toWrite.getStackSize());
this.saveChanges();
}
return toReturn;
}
if (mode == Actionable.MODULATE) {
this.updateFluidCount(input.getStackSize());
this.cellItems.add(input);
this.cellFluids.add(input);
this.saveChanges();
}
return null;
}
}
@@ -379,7 +343,7 @@ public class FluidCellInventory implements IFluidCellInventory {
IAEFluidStack results = null;
final IAEFluidStack l = this.getCellItems().findPrecise(request);
final IAEFluidStack l = this.getCellFluids().findPrecise(request);
if (l != null) {
results = l.copy();
@@ -408,7 +372,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out) {
for (final IAEFluidStack i : this.getCellItems()) {
for (final IAEFluidStack i : this.getCellFluids()) {
out.add(i);
}
return out;
@@ -417,7 +381,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public List<IAEFluidStack> getContents() {
List<IAEFluidStack> ret = new ArrayList<>();
for (IAEFluidStack fluid : this.getCellItems()) {
for (IAEFluidStack fluid : this.getCellFluids()) {
ret.add(fluid);
}
return ret;
@@ -29,7 +29,7 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
AEApi.instance().storage().createFluidList();
for (int x = 0; x < config.getSizeInventory(); x++) {
final ItemStack is = config.getStackInSlot(x);
if (is != null && Util.getFluidFromItem(is) != null) {
if (Util.getFluidFromItem(is) != null) {
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
break;
}
@@ -43,15 +43,14 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
@Override
public IFluidCellInventory getCellInv() {
Object o = this.getInternal();
if (o instanceof MEPassThrough) {
o = Ae2Reflect.getInternal((MEPassThrough) o);
o = Ae2Reflect.getInternal((MEPassThrough<?>) o);
}
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
}
@Override
@SuppressWarnings("unchecked")
public Iterable<IAEFluidStack> getPartitionInv() {
return (Iterable<IAEFluidStack>) Ae2Reflect.getPartitionList(this).getItems();
}
@@ -29,7 +29,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
int getBytesPerType();
/**
* @return true if a new item type can be added.
* @return true if a new fluid type can be added.
*/
boolean canHoldNewFluid();
@@ -49,17 +49,22 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
long getUsedBytes();
/**
* @return how many items are stored.
* @return how many fluids are stored.
*/
long getStoredFluidCount();
/**
* @return how many more items can be stored.
* @return how many more fluids can be stored.
*/
long getRemainingFluidCount();
/**
* @return how many items can be added without consuming another byte.
* @return how many fluid types remain.
*/
long getRemainingFluidTypes();
/**
* @return how many fluids can be added without consuming another byte.
*/
int getUnusedFluidCount();
@@ -68,8 +73,14 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
*/
int getStatusForCell();
/**
* @return how many items types are currently stored.
*/
long getStoredFluidTypes();
/**
* @return max number of types.
*/
long getTotalFluidTypes();
List<IAEFluidStack> getContents();
@@ -1,5 +1,6 @@
package com.glodblock.github.common.tile;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.GridFlags;
import appeng.api.networking.crafting.ICraftingGrid;
@@ -134,7 +135,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
private List<IAEItemStack> itemCache = null;
private IItemList<IAEItemStack> itemCache = null;
FluidDiscretizingInventory() {
invHandler.setPriority(Integer.MAX_VALUE);
@@ -185,7 +186,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
if (itemCache == null) {
itemCache = new ArrayList<>();
itemCache = AEApi.instance().storage().createItemList();
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
if (fluidGrid != null) {
for (IAEFluidStack fluid : fluidGrid.getStorageList()) {
@@ -15,13 +15,13 @@ import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.IDualHost;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.DualityFluidInterface;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
@@ -32,31 +32,28 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory {
public class TileFluidInterface extends TileInterface implements IDualHost {
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
private final IConfigManager dualityConfigManager =
getInterfaceDuality().getConfigManager();
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
SidelessMode mode = (SidelessMode) dualityConfigManager.getSetting(Settings.SIDELESS_MODE);
if (mode == SidelessMode.SIDELESS) {
return this.getTanks().drain(from, maxDrain, doDrain);
}
return this.getTanks().drain(from.ordinal(), maxDrain, doDrain);
}
};
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
public TileFluidInterface() {
super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
}
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
@MENetworkEventSubscribe
public void stateChange(final MENetworkChannelsChanged c) {
fluidDuality.onChannelStateChange(c);
@@ -75,23 +72,19 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
fluidDuality.gridChanged();
}
@Override
public DualityFluidInterface getDualityFluid() {
return fluidDuality;
}
@Override
public AEFluidInventory getInternalFluid() {
return fluidDuality.getTanks();
}
@Override
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
} else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
Util.mirrorFluidToPacket(this.config, fluidDuality.getConfig());
return config;
}
@@ -121,24 +114,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
protected void writeToStream(ByteBuf data) throws IOException {
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = 0;
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if (getInternalFluid().getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
getInternalFluid().writeToBuf(data);
}
@TileEvent(TileEventType.NETWORK_READ)
@@ -150,37 +127,16 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
}
int fluidMask = data.readByte();
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
getInternalFluid().setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (getInternalFluid().getFluidInSlot(i) != null) {
getInternalFluid().setFluidInSlot(i, null);
changed = true;
}
}
fluidDuality.loadConfigFromPacket(this.config);
changed |= getInternalFluid().readFromBuf(data);
return changed;
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
fluidDuality.loadConfigFromPacket(this.config);
getInternalFluid().readFromNBT(data, "FluidInv");
}
@@ -241,6 +197,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
fluidDuality.onFluidInventoryChanged(inv, slot);
}
@Override
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(
@@ -249,6 +206,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
}
@Override
public void setFluidInv(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
getInternalFluid().setFluidInSlot(id, fluid);
@@ -1,12 +1,10 @@
package com.glodblock.github.common.tile;
import appeng.api.storage.data.IAEFluidStack;
import appeng.tile.AEBaseInvTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
@@ -25,8 +23,13 @@ import net.minecraftforge.fluids.IFluidHandler;
public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 9);
private final AEFluidInventory invFluids = new AEFluidInventory(this, 4, 64000);
protected AppEngInternalInventory invItems;
protected AEFluidInventory invFluids;
public TileIngredientBuffer() {
this.invFluids = new AEFluidInventory(this, 4, 64000);
this.invItems = new AppEngInternalInventory(this, 9);
}
@Nonnull
@Override
@@ -34,10 +37,6 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
return invItems;
}
public IAEFluidTank getFluidInventory() {
return invFluids;
}
@Override
public boolean canBeRotated() {
return false;
@@ -69,19 +68,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
for (int i = 0; i < invItems.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i));
}
int fluidMask = 0;
for (int i = 0; i < invFluids.getSlots(); i++) {
if (invFluids.getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < invFluids.getSlots(); i++) {
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
this.invFluids.writeToBuf(data);
}
@TileEvent(TileEventType.NETWORK_READ)
@@ -94,22 +81,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
changed = true;
}
}
int fluidMask = data.readByte();
for (int i = 0; i < invFluids.getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
invFluids.setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (invFluids.getFluidInSlot(i) != null) {
invFluids.setFluidInSlot(i, null);
changed = true;
}
}
changed |= this.invFluids.readFromBuf(data);
return changed;
}
@@ -1,51 +1,14 @@
package com.glodblock.github.common.tile;
import appeng.api.storage.data.IAEFluidStack;
import appeng.tile.AEBaseInvTile;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import javax.annotation.Nonnull;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
public class TileLargeIngredientBuffer extends TileIngredientBuffer {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 27);
private final AEFluidInventory invFluids = new AEFluidInventory(this, 7, 64000);
@Nonnull
@Override
public IInventory getInternalInventory() {
return invItems;
}
public IAEFluidTank getFluidInventory() {
return invFluids;
}
@Override
public boolean canBeRotated() {
return false;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
markForUpdate();
public TileLargeIngredientBuffer() {
this.invFluids = new AEFluidInventory(this, 7, 64000);
this.invItems = new AppEngInternalInventory(this, 27);
}
@Override
@@ -55,106 +18,8 @@ public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluid
};
}
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
markForUpdate();
}
@Override
public AEFluidInventory getInternalFluid() {
return this.invFluids;
}
@TileEvent(TileEventType.NETWORK_WRITE)
protected void writeToStream(ByteBuf data) throws IOException {
for (int i = 0; i < invItems.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i));
}
int fluidMask = 0;
for (int i = 0; i < invFluids.getSlots(); i++) {
if (invFluids.getFluidInSlot(i) != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (int i = 0; i < invFluids.getSlots(); i++) {
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
if (fluid != null) {
fluid.writeToPacket(data);
}
}
}
@TileEvent(TileEventType.NETWORK_READ)
protected boolean readFromStream(ByteBuf data) throws IOException {
boolean changed = false;
for (int i = 0; i < invItems.getSizeInventory(); i++) {
ItemStack stack = ByteBufUtils.readItemStack(data);
if (!ItemStack.areItemStacksEqual(stack, invItems.getStackInSlot(i))) {
invItems.setInventorySlotContents(i, stack);
changed = true;
}
}
int fluidMask = data.readByte();
for (int i = 0; i < invFluids.getSlots(); i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
invFluids.setFluidInSlot(i, fluid);
changed = true;
}
}
} else if (invFluids.getFluidInSlot(i) != null) {
invFluids.setFluidInSlot(i, null);
changed = true;
}
}
return changed;
}
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
invItems.readFromNBT(data, "ItemInv");
invFluids.readFromNBT(data, "FluidInv");
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
invItems.writeToNBT(data, "ItemInv");
invFluids.writeToNBT(data, "FluidInv");
return data;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return invFluids.fill(from, resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return invFluids.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return invFluids.drain(from, maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
return invFluids.canFill(from, fluid);
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return invFluids.canDrain(from, fluid);
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return invFluids.getTankInfo(from);
}
}
@@ -66,7 +66,7 @@ public class TileLevelMaintainer extends AENetworkTile
@Override
public ImmutableSet<ICraftingLink> getRequestedJobs() {
return ImmutableSet.copyOf(new NonNullArrayIterator<ICraftingLink>(this.requests.getLinks()));
return ImmutableSet.copyOf(new NonNullArrayIterator<>(this.requests.getLinks()));
}
private IAEItemStack setState(ICraftingLink link, IAEItemStack items) {
@@ -176,8 +176,7 @@ public class TileLevelMaintainer extends AENetworkTile
}
}
}
} catch (final GridAccessException e) {
// :P
} catch (final GridAccessException ignore) {
}
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
}
@@ -245,8 +244,7 @@ public class TileLevelMaintainer extends AENetworkTile
if (!this.requests.isDone(i)) this.requests.setState(i, State.Crafting);
}
}
} catch (Exception e) {
// :P You don't have job to do XD
} catch (Exception ignore) {
}
}
@@ -331,6 +329,7 @@ public class TileLevelMaintainer extends AENetworkTile
private final ICraftingLink[] links;
private final State[] state = new State[REQ_COUNT];
@SuppressWarnings("unchecked")
public InventoryRequest(TileLevelMaintainer tile) {
this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
this.requestBatches = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
@@ -27,7 +27,6 @@ import com.glodblock.github.inventory.FluidConvertingInventoryCrafting;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.SetBackedMachineSet;
import com.glodblock.github.util.Util;
import com.google.common.collect.Sets;
import java.util.HashSet;
import java.util.Set;
@@ -68,7 +67,7 @@ public class CoreModHooks {
@Nullable
public static InventoryAdaptor wrapInventory(@Nullable TileEntity tile, ForgeDirection face) {
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, Util.from(face)) : null;
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, face) : null;
}
public static long getCraftingByteCost(IAEItemStack stack) {
@@ -2,7 +2,7 @@ package com.glodblock.github.crossmod.waila.part;
import appeng.api.parts.IPart;
import appeng.integration.modules.waila.part.BasePartWailaDataProvider;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
import com.glodblock.github.crossmod.waila.Tooltip;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -20,9 +20,9 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider {
final List<String> currentToolTip,
final IWailaDataAccessor accessor,
final IWailaConfigHandler config) {
if (part instanceof PartSharedFluidBus) {
if (part instanceof FCSharedFluidBus) {
part.readFromNBT(accessor.getNBTData());
currentToolTip.add(Tooltip.partFluidBusFormat(((PartSharedFluidBus) part).calculateAmountToSend() / 5));
currentToolTip.add(Tooltip.partFluidBusFormat(((FCSharedFluidBus) part).calculateAmountToSend() / 5));
}
return currentToolTip;
}
@@ -37,7 +37,7 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider {
final int x,
final int y,
final int z) {
if (part instanceof PartSharedFluidBus) {
if (part instanceof FCSharedFluidBus) {
part.writeToNBT(tag);
}
return tag;
@@ -5,6 +5,8 @@ import appeng.core.AELog;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.util.Util;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@@ -251,6 +253,42 @@ public class AEFluidInventory implements IAEFluidTank {
data.setTag(name, c);
}
public void writeToBuf(final ByteBuf data) throws IOException {
int fluidMask = 0;
for (int i = 0; i < this.fluids.length; i++) {
if (this.fluids[i] != null) {
fluidMask |= 1 << i;
}
}
data.writeByte(fluidMask);
for (IAEFluidStack fluid : this.fluids) {
if (fluid != null) {
fluid.writeToPacket(data);
}
}
}
public boolean readFromBuf(final ByteBuf data) throws IOException {
boolean changed = false;
int fluidMask = data.readByte();
for (int i = 0; i < this.fluids.length; i++) {
if ((fluidMask & (1 << i)) != 0) {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
if (fluid != null) { // this shouldn't happen, but better safe than sorry
IAEFluidStack origFluid = this.fluids[i];
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
this.fluids[i] = fluid;
changed = true;
}
}
} else if (this.fluids[i] != null) {
this.fluids[i] = null;
changed = true;
}
}
return changed;
}
private void writeToNBT(final NBTTagCompound target) {
for (int x = 0; x < this.fluids.length; x++) {
try {
@@ -1,56 +0,0 @@
package com.glodblock.github.inventory;
import appeng.core.AELog;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/**
* Since there is no ae2 available now for compiling, we copied it over, and it will need to be removed in the future.
*/
@Deprecated
public class BiggerAppEngInventory extends AppEngInternalInventory {
private final ItemStack[] inv;
public BiggerAppEngInventory(IAEAppEngInventory inventory, int size) {
super(inventory, size);
inv = ObfuscationReflectionHelper.getPrivateValue(AppEngInternalInventory.class, this, "inv");
}
protected void writeToNBT(final NBTTagCompound target) {
for (int x = 0; x < this.getSizeInventory(); x++) {
try {
final NBTTagCompound c = new NBTTagCompound();
if (this.inv[x] != null) {
this.inv[x].writeToNBT(c);
c.setInteger("Count", this.inv[x].stackSize);
}
target.setTag("#" + x, c);
} catch (final Exception ignored) {
}
}
}
public void readFromNBT(final NBTTagCompound target) {
for (int x = 0; x < this.getSizeInventory(); x++) {
try {
final NBTTagCompound c = target.getCompoundTag("#" + x);
if (c != null) {
ItemStack stack = ItemStack.loadItemStackFromNBT(c);
if (stack != null) {
stack.stackSize = c.getInteger("Count");
}
this.inv[x] = stack;
}
} catch (final Exception e) {
AELog.debug(e);
}
}
}
}
@@ -5,13 +5,11 @@ import appeng.api.config.InsertionMode;
import appeng.me.GridAccessException;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.tile.misc.TileInterface;
import appeng.tile.networking.TileCableBus;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
import cofh.api.transport.IItemDuct;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidExportBus;
import com.glodblock.github.common.parts.PartFluidInterface;
@@ -27,7 +25,6 @@ import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
@@ -38,13 +35,13 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
public FluidConvertingInventoryAdaptor(
@Nullable InventoryAdaptor invItems,
@Nullable IFluidHandler invFluids,
EnumFacing facing,
ForgeDirection facing,
BlockPos pos,
boolean isOnmi,
Object eioConduct) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = Util.from(facing);
this.side = facing;
this.posInterface = pos;
this.eioDuct = eioConduct;
this.onmi = isOnmi;
@@ -57,21 +54,20 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
private final Object eioDuct;
private final boolean onmi;
public static InventoryAdaptor wrap(TileEntity capProvider, EnumFacing face) {
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
// sometimes i wish 1.7.10 has cap system.
ForgeDirection f = Util.from(face);
TileEntity inter = capProvider
.getWorldObj()
.getTileEntity(
capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ);
capProvider.xCoord + face.offsetX,
capProvider.yCoord + face.offsetY,
capProvider.zCoord + face.offsetZ);
if (!Config.noFluidPacket
&& !(inter instanceof TileFluidInterface
|| (inter instanceof TileCableBus
&& (((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface
|| ((TileCableBus) inter).getPart(f.getOpposite())
instanceof PartFluidExportBus))))
return InventoryAdaptor.getAdaptor(capProvider, f);
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f);
|| Util.getPart(inter, face.getOpposite()) instanceof PartFluidInterface
|| Util.getPart(inter, face.getOpposite()) instanceof PartFluidExportBus))
return InventoryAdaptor.getAdaptor(capProvider, face);
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, face);
IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null;
boolean onmi = false;
if (inter instanceof TileInterface) {
@@ -85,16 +81,10 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
if (toBeAdded.getItem() instanceof ItemFluidPacket || toBeAdded.getItem() instanceof ItemFluidDrop) {
FluidStack fluid = Util.getFluidFromVirtual(toBeAdded);
if (fluid != null) {
if (invFluids != null) {
FluidStack fluid;
if (toBeAdded.getItem() instanceof ItemFluidPacket) {
fluid = ItemFluidPacket.getFluidStack(toBeAdded);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeAdded);
}
if (fluid != null && invFluids.canFill(side, fluid.getFluid())) {
if (invFluids.canFill(side, fluid.getFluid())) {
int filled = invFluids.fill(side, fluid, true);
if (filled > 0) {
fluid.amount -= filled;
@@ -122,46 +112,27 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
if (toBeSimulated.getItem() instanceof ItemFluidPacket || toBeSimulated.getItem() instanceof ItemFluidDrop) {
FluidStack fluid = Util.getFluidFromVirtual(toBeSimulated);
if (fluid != null) {
if (onmi) {
boolean sus = false;
FluidStack fluid;
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
}
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
if (te instanceof IFluidHandler) {
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
if (filled > 0) {
sus = true;
break;
}
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
if (te instanceof IFluidHandler) {
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
if (filled > 0) {
sus = true;
break;
}
}
} else {
sus = true;
}
return sus ? null : toBeSimulated;
}
if (invFluids != null) {
FluidStack fluid;
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
} else {
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
}
if (fluid != null) {
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
}
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
}
}
return toBeSimulated;
@@ -203,10 +174,9 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (invFluids instanceof TileCableBus
&& ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) {
if (Util.getPart(invFluids, this.side) instanceof PartP2PLiquids) {
// read other ends of p2p for blocking mode
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) ((TileCableBus) invFluids).getPart(this.side);
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(invFluids, this.side);
try {
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
boolean checkedInput = false;
@@ -223,8 +193,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
if (target == null) continue;
tankInfos.add(target.getTankInfo(p2p.getSide().getOpposite()));
}
} catch (GridAccessException e) {
// ignore
} catch (GridAccessException ignore) {
}
} else {
tankInfos.add(invFluids.getTankInfo(this.side));
@@ -0,0 +1,17 @@
package com.glodblock.github.inventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.util.DualityFluidInterface;
import net.minecraftforge.fluids.IFluidHandler;
public interface IDualHost extends IFluidHandler, IAEFluidInventory {
DualityFluidInterface getDualityFluid();
AppEngInternalAEInventory getConfig();
void setConfig(int id, IAEFluidStack fluid);
void setFluidInv(int id, IAEFluidStack fluid);
}
@@ -2,7 +2,7 @@ package com.glodblock.github.inventory;
import appeng.api.storage.data.IAEItemStack;
public interface PatternConsumer {
public interface IPatternConsumer {
void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs);
}
@@ -9,8 +9,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class InventoryHandler implements IGuiHandler {
@@ -18,7 +18,7 @@ public class InventoryHandler implements IGuiHandler {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType));
}
public static void openGui(EntityPlayer player, World world, BlockPos pos, EnumFacing face, GuiType guiType) {
public static void openGui(EntityPlayer player, World world, BlockPos pos, ForgeDirection face, GuiType guiType) {
player.openGui(
FluidCraft.INSTANCE,
(guiType.ordinal() << 3) | face.ordinal(),
@@ -32,10 +32,10 @@ public class InventoryHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
int faceOrd = id & 0x7;
if (faceOrd > EnumFacing.values().length) {
if (faceOrd > ForgeDirection.values().length) {
return null;
}
EnumFacing face = EnumFacing.getFront(faceOrd);
ForgeDirection face = ForgeDirection.getOrientation(faceOrd);
GuiType type = GuiType.getByOrdinal(id >>> 3);
return type != null ? type.guiFactory.createServerGui(player, world, x, y, z, face) : null;
}
@@ -45,10 +45,10 @@ public class InventoryHandler implements IGuiHandler {
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
int faceOrd = id & 0x7;
if (faceOrd > EnumFacing.values().length) {
if (faceOrd > ForgeDirection.values().length) {
return null;
}
EnumFacing face = EnumFacing.getFront(faceOrd);
ForgeDirection face = ForgeDirection.getOrientation(faceOrd);
GuiType type = GuiType.getByOrdinal(id >>> 3);
return type != null ? type.guiFactory.createClientGui(player, world, x, y, z, face) : null;
}
@@ -5,7 +5,7 @@ import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.tile.networking.TileCableBus;
import com.glodblock.github.util.Util;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -16,9 +16,7 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
if (channel == StorageChannel.FLUIDS) {
if (te instanceof ITileStorageMonitorable) {
return true;
} else
return te instanceof TileCableBus
&& ((TileCableBus) te).getPart(d.getOpposite()) instanceof ITileStorageMonitorable;
} else return Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable;
}
return false;
}
@@ -29,9 +27,8 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
if (channel == StorageChannel.FLUIDS) {
if (te instanceof ITileStorageMonitorable) {
return ((ITileStorageMonitorable) te).getMonitorable(d, src).getFluidInventory();
} else if (te instanceof TileCableBus
&& ((TileCableBus) te).getPart(d.getOpposite()) instanceof ITileStorageMonitorable) {
ITileStorageMonitorable part = (ITileStorageMonitorable) ((TileCableBus) te).getPart(d.getOpposite());
} else if (Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable) {
ITileStorageMonitorable part = (ITileStorageMonitorable) Util.getPart(te, d.getOpposite());
return part.getMonitorable(d, src).getFluidInventory();
}
}
Loaded 100 of 140 files, more files were not shown because too many files have changed in this diff. Show more