mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge pull request #9 from vfyjxf/master
Allows the use of the middle mouse button to modify the number of items in the pattern.
This commit is contained in:
33 files changed
+512
-40
No files matched your search
@@ -11,8 +11,6 @@ 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.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
@@ -7,7 +7,10 @@ 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.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
@@ -28,9 +31,9 @@ import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.FCBaseMonitorContain;
|
||||
import com.glodblock.github.client.gui.container.FCBasePartContainer;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
@@ -362,6 +365,19 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -17,7 +17,6 @@ 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 net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -14,6 +14,7 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.Reflected;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
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.CPacketCraftRequest;
|
||||
@@ -78,6 +79,10 @@ public class GuiFluidCraftAmount extends AEBaseGui
|
||||
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 )
|
||||
{
|
||||
@@ -250,8 +255,4 @@ public class GuiFluidCraftAmount extends AEBaseGui
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketEncodePattern;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
-1
@@ -8,7 +8,6 @@ import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@@ -11,7 +11,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.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
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.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 {
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
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.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);
|
||||
|
||||
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;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
private int getOriginalAmount(ItemStack stack) {
|
||||
if (Util.isFluidPacket(stack)) {
|
||||
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
|
||||
return fluidStack.amount;
|
||||
} else {
|
||||
return stack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerPatternValueAmount extends AEBaseContainer {
|
||||
|
||||
|
||||
private final Slot patternValue;
|
||||
private int valueIndex;
|
||||
|
||||
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
this.patternValue = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
|
||||
this.addSlotToContainer( patternValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
this.verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
public Slot getPatternValue()
|
||||
{
|
||||
return patternValue;
|
||||
}
|
||||
|
||||
public int getValueIndex()
|
||||
{
|
||||
return valueIndex;
|
||||
}
|
||||
|
||||
public void setValueIndex( int valueIndex )
|
||||
{
|
||||
this.valueIndex = valueIndex;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,10 @@ import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.glodblock.github.common.block;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.render.RenderBlockFluidInterface;
|
||||
|
||||
@@ -16,7 +16,6 @@ import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
|
||||
@@ -11,8 +11,8 @@ 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.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.BiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -34,8 +34,8 @@ public class PartFluidPatternTerminal extends FCBasePart {
|
||||
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 AppEngInternalInventory( this, 9 );
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 3 );
|
||||
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;
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -33,8 +34,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
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 AppEngInternalInventory( this, 32 );
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 32 );
|
||||
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;
|
||||
|
||||
@@ -5,10 +5,8 @@ import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
@@ -18,9 +16,6 @@ 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 net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -11,8 +11,6 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
|
||||
@@ -10,7 +10,6 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.inventory.AeStackInventoryImpl;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -5,8 +5,6 @@ import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.util.Util;
|
||||
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;
|
||||
@@ -14,8 +12,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AEFluidInventory implements IAEFluidTank
|
||||
{
|
||||
private final IAEFluidStack[] fluids;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@@ -222,6 +222,18 @@ public enum GuiType {
|
||||
protected Object createClientGui(EntityPlayer player, TileFluidPacketDecoder inv) {
|
||||
return new GuiFluidPacketDecoder(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
PATTERN_VALUE_SET(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new ContainerPatternValueAmount(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new GuiPatternValueAmount(player.inventory, inv);
|
||||
}
|
||||
});
|
||||
|
||||
public static final List<GuiType> VALUES = ImmutableList.copyOf(values());
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.glodblock.github.inventory.gui;
|
||||
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -20,5 +20,6 @@ public class ChannelLoader implements Runnable {
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id ++, Side.SERVER);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,11 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -108,6 +111,24 @@ public class CPacketInventoryAction implements IMessage {
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE"))
|
||||
{
|
||||
final ContainerOpenContext context = baseContainer.getOpenContext();
|
||||
if( context != null )
|
||||
{
|
||||
final TileEntity te = context.getTile();
|
||||
InventoryHandler.openGui(sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.PATTERN_VALUE_SET );
|
||||
if( sender.openContainer instanceof ContainerPatternValueAmount)
|
||||
{
|
||||
final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer;
|
||||
if( baseContainer.getTargetStack() != null )
|
||||
{
|
||||
cpv.setValueIndex( message.slot );
|
||||
cpv.getPatternValue().putStack( baseContainer.getTargetStack().getItemStack() );
|
||||
}
|
||||
cpv.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
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 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;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CPacketPatternValueSet implements IMessage {
|
||||
|
||||
|
||||
private GuiType originGui;
|
||||
private int amount;
|
||||
private int valueIndex;
|
||||
|
||||
public CPacketPatternValueSet() {
|
||||
|
||||
}
|
||||
|
||||
public CPacketPatternValueSet( int originalGui, int amount, int valueIndex ){
|
||||
this.originGui = GuiType.getByOrdinal(originalGui);
|
||||
this.amount = amount;
|
||||
this.valueIndex = valueIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(originGui.ordinal());
|
||||
buf.writeInt(amount);
|
||||
buf.writeInt(valueIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.originGui = GuiType.getByOrdinal(buf.readInt());
|
||||
this.amount = buf.readInt();
|
||||
this.valueIndex = buf.readInt();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketPatternValueSet, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketPatternValueSet message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerPatternValueAmount) {
|
||||
ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) player.openContainer;
|
||||
final Object target = cpv.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final ContainerOpenContext context = cpv.getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity te = context.getTile();
|
||||
InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.originGui);
|
||||
if (player.openContainer instanceof ContainerFluidPatternTerminal || player.openContainer instanceof ContainerFluidPatternTerminalEx) {
|
||||
Slot slot = player.openContainer.getSlot(message.valueIndex);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
if (Util.isFluidPacket(stack)) {
|
||||
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
|
||||
if (fluidStack != null) {
|
||||
fluidStack = ItemFluidPacket.getFluidStack(stack).copy();
|
||||
fluidStack.amount = message.amount;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluidStack));
|
||||
} else {
|
||||
stack.stackSize = message.amount;
|
||||
slot.putStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CPacketTransferRecipe implements IMessage {
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public final class Util {
|
||||
|
||||
|
||||
Reference in new issue
Block a user