mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 19:05:29 +00:00
refactor 4
This commit is contained in:
1 parent
b9b8ac3b43
commit
d9449622b9
22 files changed
+350
-579
No files matched your search
@@ -125,9 +125,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,198 +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_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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,6 +327,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
}
|
||||
|
||||
@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) {
|
||||
@@ -335,8 +336,11 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -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)
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
|
||||
+2
-2
@@ -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.TileLargeIngredientBuffer;
|
||||
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 ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable {
|
||||
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements ITankDump {
|
||||
|
||||
private final TileLargeIngredientBuffer tile;
|
||||
|
||||
|
||||
+4
-1
@@ -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,7 +1,7 @@
|
||||
package com.glodblock.github.inventory.gui;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.TankDumpable;
|
||||
import com.glodblock.github.client.gui.ITankDump;
|
||||
import com.glodblock.github.network.CPacketDumpTank;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import java.util.Collections;
|
||||
@@ -36,7 +36,7 @@ public class ButtonMouseHandler implements MouseRegionManager.Handler {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ButtonMouseHandler dumpTank(TankDumpable host, int index) {
|
||||
public static ButtonMouseHandler dumpTank(ITankDump host, int index) {
|
||||
return new ButtonMouseHandler(NameConst.TT_DUMP_TANK, () -> {
|
||||
if (host.canDumpTank(index)) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketDumpTank(index));
|
||||
|
||||
@@ -102,7 +102,7 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_PRIORITY_PART(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
PRIORITY_PART(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new ContainerPriority(player.inventory, inv);
|
||||
@@ -114,19 +114,7 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_PRIORITY(new TileGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new ContainerPriority(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new GuiFCPriority(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_STORAGE_BUS_PRIORITY(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
PRIORITY_TILE(new TileGuiFactory<IPriorityHost>(IPriorityHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
|
||||
return new ContainerPriority(player.inventory, inv);
|
||||
@@ -301,9 +289,9 @@ public enum GuiType {
|
||||
return ordinal < 0 || ordinal >= VALUES.size() ? null : VALUES.get(ordinal);
|
||||
}
|
||||
|
||||
public final GuiFactory guiFactory;
|
||||
public final IGuiFactory guiFactory;
|
||||
|
||||
GuiType(GuiFactory guiFactory) {
|
||||
GuiType(IGuiFactory guiFactory) {
|
||||
this.guiFactory = guiFactory;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface GuiFactory {
|
||||
public interface IGuiFactory {
|
||||
|
||||
@Nullable
|
||||
Object createServerGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face);
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class TileGuiFactory<T> implements GuiFactory {
|
||||
public abstract class TileGuiFactory<T> implements IGuiFactory {
|
||||
|
||||
protected final Class<T> invClass;
|
||||
|
||||
|
||||
@@ -39,5 +39,7 @@ public class ChannelLoader implements Runnable {
|
||||
new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.TankDumpable;
|
||||
import com.glodblock.github.client.gui.ITankDump;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -36,8 +36,8 @@ public class CPacketDumpTank implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(CPacketDumpTank message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof TankDumpable) {
|
||||
((TankDumpable) player.openContainer).dumpTank(message.index);
|
||||
if (player.openContainer instanceof ITankDump) {
|
||||
((ITankDump) player.openContainer).dumpTank(message.index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
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;
|
||||
@@ -20,6 +22,7 @@ import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CPacketInventoryAction implements IMessage {
|
||||
|
||||
@@ -96,22 +99,19 @@ public class CPacketInventoryAction implements IMessage {
|
||||
Objects.requireNonNull(
|
||||
Util.from(baseContainer.getOpenContext().getSide())),
|
||||
GuiType.FLUID_CRAFTING_AMOUNT);
|
||||
|
||||
if (sender.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
|
||||
if (baseContainer.getTargetStack() != null) {
|
||||
cca.getCraftingItem()
|
||||
.putStack(baseContainer.getTargetStack().getItemStack());
|
||||
cca.setItemToCraft(baseContainer.getTargetStack());
|
||||
}
|
||||
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else if (message.action == InventoryAction.SET_PATTERN_VALUE) {
|
||||
final ContainerOpenContext context = baseContainer.getOpenContext();
|
||||
if (context != null) {
|
||||
if (context != null && message.stack != null) {
|
||||
final TileEntity te = context.getTile();
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
@@ -120,6 +120,12 @@ public class CPacketInventoryAction implements IMessage {
|
||||
Objects.requireNonNull(
|
||||
Util.from(baseContainer.getOpenContext().getSide())),
|
||||
GuiType.PATTERN_VALUE_SET);
|
||||
int amt = (int) message.stack.getStackSize();
|
||||
if (message.stack.getItem() instanceof ItemFluidPacket) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(message.stack);
|
||||
amt = fluid == null ? 1 : fluid.amount;
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketSetItemAmount(amt), sender);
|
||||
if (sender.openContainer instanceof ContainerPatternValueAmount) {
|
||||
final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer;
|
||||
if (baseContainer.getTargetStack() != null) {
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
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;
|
||||
@@ -27,7 +27,9 @@ public class CPacketPatternValueSet implements IMessage {
|
||||
private int amount;
|
||||
private int valueIndex;
|
||||
|
||||
public CPacketPatternValueSet() {}
|
||||
public CPacketPatternValueSet() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public CPacketPatternValueSet(int originalGui, int amount, int valueIndex) {
|
||||
this.originGui = GuiType.getByOrdinal(originalGui);
|
||||
@@ -54,7 +56,7 @@ public class CPacketPatternValueSet implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(CPacketPatternValueSet message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerPatternValueAmount && message.valueIndex != -1) {
|
||||
if (player.openContainer instanceof ContainerPatternValueAmount) {
|
||||
ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) player.openContainer;
|
||||
final Object target = cpv.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
@@ -67,10 +69,9 @@ public class CPacketPatternValueSet implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(Util.from(context.getSide())),
|
||||
message.originGui);
|
||||
if (player.openContainer instanceof ContainerFluidPatternTerminal
|
||||
|| player.openContainer instanceof ContainerFluidPatternTerminalEx) {
|
||||
if (player.openContainer instanceof FCContainerEncodeTerminal) {
|
||||
Slot slot = player.openContainer.getSlot(message.valueIndex);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot instanceof SlotFake) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
if (Util.isFluidPacket(stack)) {
|
||||
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiPatternValueAmount;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class SPacketSetItemAmount implements IMessage {
|
||||
|
||||
private int amount;
|
||||
|
||||
public SPacketSetItemAmount() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public SPacketSetItemAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
amount = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(amount);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketSetItemAmount, IMessage> {
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(SPacketSetItemAmount message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiPatternValueAmount) {
|
||||
((GuiPatternValueAmount) gs).setAmount(message.amount);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user