mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
fluid pattern terminal ex
This commit is contained in:
1 parent
bb4a1e9e58
commit
3e76b36c49
19 files changed
+1247
-30
No files matched your search
@@ -0,0 +1,133 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class GuiBaseFluidPatternTerminalEx 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 FCBasePartContainerEx container;
|
||||
|
||||
private GuiImgButton substitutionsEnabledBtn;
|
||||
private GuiImgButton substitutionsDisabledBtn;
|
||||
private GuiImgButton encodeBtn;
|
||||
private GuiImgButton clearBtn;
|
||||
private GuiImgButton doubleBtn;
|
||||
|
||||
public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) );
|
||||
this.container = (FCBasePartContainerEx) this.inventorySlots;
|
||||
Ae2Reflect.setReservedSpace(this, 81);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if( this.encodeBtn == btn )
|
||||
{
|
||||
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) );
|
||||
}
|
||||
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 (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
|
||||
{
|
||||
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "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.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 );
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - Ae2Reflect.getReservedSpace(this), 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,17 +32,15 @@ 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.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.network.CPacketSetTargetItem;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -50,7 +48,6 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
@@ -62,10 +59,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private final ItemRepo repo;
|
||||
private final int offsetX = 9;
|
||||
private final int lowerTextureOffset = 0;
|
||||
private final IConfigManager configSrc;
|
||||
public IConfigManager configSrc;
|
||||
private final boolean viewCell;
|
||||
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
|
||||
private final FCBaseMonitorContain monitorableContainer;
|
||||
public FCBaseMonitorContain monitorableContainer;
|
||||
private GuiTabButton craftingStatusBtn;
|
||||
private GuiImgButton craftingStatusImgBtn;
|
||||
private MEGuiTextField searchField;
|
||||
@@ -88,7 +85,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBasePartContainer c )
|
||||
public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c )
|
||||
{
|
||||
|
||||
super( c );
|
||||
@@ -116,6 +113,10 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
{
|
||||
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
if (te instanceof PartFluidPatternTerminalEx)
|
||||
{
|
||||
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list )
|
||||
|
||||
@@ -12,6 +12,7 @@ import appeng.util.Platform;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
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.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
@@ -61,6 +62,10 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
{
|
||||
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
if( te instanceof PartFluidPatternTerminalEx)
|
||||
{
|
||||
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAutoStart()
|
||||
|
||||
+12
-2
@@ -3,6 +3,8 @@ package com.glodblock.github.client.gui;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.implementations.GuiCraftingStatus;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
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;
|
||||
@@ -14,14 +16,19 @@ import net.minecraft.item.ItemStack;
|
||||
public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private final ITerminalHost host;
|
||||
|
||||
public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
host = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
Ae2Reflect.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
|
||||
if (host instanceof PartFluidPatternTerminal)
|
||||
Ae2Reflect.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
Ae2Reflect.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
|
||||
super.initGui();
|
||||
originalGuiBtn = Ae2Reflect.getOriginalGuiButton(this);
|
||||
}
|
||||
@@ -29,7 +36,10 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == originalGuiBtn) {
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
|
||||
if (host instanceof PartFluidPatternTerminal)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
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 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.Ae2Reflect;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
|
||||
|
||||
private GuiTabButton craftingStatusBtn;
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2Reflect.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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
craftingStatusBtn = Ae2Reflect.getCraftingStatusButton(this);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == craftingStatusBtn) {
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
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.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
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.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.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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
|
||||
|
||||
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
|
||||
@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 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);
|
||||
}
|
||||
|
||||
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.setInputs(collectInventory(craftingSlots));
|
||||
pattern.setOutputs(collectInventory(outputSlots));
|
||||
patternSlotOUT.putStack(pattern.writeToStack());
|
||||
}
|
||||
|
||||
private static IAEItemStack[] collectInventory(Slot[] slots) {
|
||||
// see note at top of FluidPatternDetails
|
||||
List<IAEItemStack> acc = new ArrayList<>();
|
||||
for (Slot slot : slots) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
if (stack.getItem() instanceof ItemFluidPacket) {
|
||||
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
|
||||
if (dropStack != null) {
|
||||
acc.add(dropStack);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
IAEItemStack aeStack = AEItemStack.create(stack);
|
||||
acc.add(aeStack);
|
||||
}
|
||||
return acc.toArray(new IAEItemStack[0]);
|
||||
}
|
||||
|
||||
@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 (slotId < 0 || slotId >= this.inventorySlots.size()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
Slot slot = getSlot(slotId);
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && 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;
|
||||
}
|
||||
}
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,410 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
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.helpers.IContainerCraftingPacket;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
|
||||
private final PartFluidPatternTerminalEx patternTerminal;
|
||||
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
|
||||
private final IInventory crafting;
|
||||
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[16];
|
||||
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[4];
|
||||
protected final SlotRestrictedInput patternSlotIN;
|
||||
protected final SlotRestrictedInput patternSlotOUT;
|
||||
@GuiSync( 96 )
|
||||
public boolean substitute = false;
|
||||
|
||||
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable )
|
||||
{
|
||||
super( ip, monitorable, false );
|
||||
this.patternTerminal = (PartFluidPatternTerminalEx) 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 < 4; y++ )
|
||||
{
|
||||
for( int x = 0; x < 4; x++ )
|
||||
{
|
||||
this.addSlotToContainer( this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix( this.crafting, x + y * 4, 15 + x * 18, -83 + y * 18 ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( int y = 0; y < 4; y++ )
|
||||
{
|
||||
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 112, -83, 0, y, 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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for( final Slot s : this.craftingSlots )
|
||||
{
|
||||
s.putStack( null );
|
||||
}
|
||||
|
||||
for( final Slot s : this.outputSlots )
|
||||
{
|
||||
s.putStack( null );
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@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 );
|
||||
}
|
||||
}
|
||||
|
||||
// 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( "substitute", this.isSubstitute() );
|
||||
|
||||
output.setTagCompound( encodedValue );
|
||||
}
|
||||
|
||||
private ItemStack[] getInputs()
|
||||
{
|
||||
final ItemStack[] input = new ItemStack[16];
|
||||
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()
|
||||
{
|
||||
final List<ItemStack> list = new ArrayList<>( 4 );
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled( final int idx )
|
||||
{
|
||||
if( idx == 1 )
|
||||
{
|
||||
Platform.isServer();
|
||||
return true;
|
||||
}
|
||||
else if( idx == 2 )
|
||||
{
|
||||
Platform.isServer();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.substitute = this.patternTerminal.isSubstitution();
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
public PartFluidPatternTerminalEx getPatternTerminal()
|
||||
{
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
private boolean isSubstitute()
|
||||
{
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitute( final boolean substitute )
|
||||
{
|
||||
this.substitute = substitute;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public void doubleStacks(boolean isShift)
|
||||
{
|
||||
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
|
||||
{
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
if (isShift && !containsFluid(outputSlots) && !containsFluid(craftingSlots))
|
||||
{
|
||||
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots))
|
||||
{
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
static boolean 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.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;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
|
||||
public ItemPartFluidPatternTerminalEx() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PartFluidPatternTerminalEx createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidPatternTerminalEx(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
public ItemPartFluidPatternTerminalEx register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
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.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.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
|
||||
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 AppEngInternalInventory( this, 16 );
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 4 );
|
||||
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
|
||||
|
||||
private boolean substitute = false;
|
||||
|
||||
public PartFluidPatternTerminalEx(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@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.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( "substitute", this.substitute );
|
||||
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 void onChangeInventory0(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( inv == this.pattern && slot == 1 )
|
||||
{
|
||||
final ItemStack is = this.pattern.getStackInSlot( 1 );
|
||||
if( is != null && is.getItem() instanceof ICraftingPatternItem)
|
||||
{
|
||||
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
|
||||
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
|
||||
if( details != null )
|
||||
{
|
||||
this.setSubstitution( details.canSubstitute() );
|
||||
|
||||
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getOutputs()[x];
|
||||
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if (inv == this.pattern && slot == 1) {
|
||||
final ItemStack is = inv.getStackInSlot(1);
|
||||
if (is != null && is.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
|
||||
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
|
||||
if( details != null )
|
||||
{
|
||||
this.setSubstitution( details.canSubstitute() );
|
||||
|
||||
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.crafting.setInventorySlotContents(x, packet);
|
||||
}
|
||||
else this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getOutputs()[x];
|
||||
if (item != null && item.getItem() instanceof ItemFluidDrop) {
|
||||
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
|
||||
this.output.setInventorySlotContents(x, packet);
|
||||
}
|
||||
else this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
|
||||
}
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
return;
|
||||
}
|
||||
}
|
||||
onChangeInventory0(inv, slot, mc, removedStack, newStack);
|
||||
}
|
||||
|
||||
public boolean isSubstitution()
|
||||
{
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitution( boolean canSubstitute )
|
||||
{
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontColored() {
|
||||
return FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,8 @@ import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPacketDecoder;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.*;
|
||||
import com.glodblock.github.common.parts.FCBasePart;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
@@ -19,14 +17,14 @@ import java.util.List;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<PartFluidPatternTerminal>(PartFluidPatternTerminal.class) {
|
||||
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new ContainerCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new GuiFluidPatternTerminalCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
@@ -43,6 +41,18 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_PATTERN_TERMINAL_EX(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new ContainerFluidPatternTerminalEx(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiFluidPatternTerminalEx(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_PATTERN_ENCODER(new TileGuiFactory<TileFluidPatternEncoder>(TileFluidPatternEncoder.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileFluidPatternEncoder inv) {
|
||||
@@ -55,26 +65,26 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<PartFluidPatternTerminal>(PartFluidPatternTerminal.class) {
|
||||
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new ContainerFluidCraftConfirm(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new GuiFluidCraftConfirm(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_CRAFTING_AMOUNT(new PartGuiFactory<PartFluidPatternTerminal>(PartFluidPatternTerminal.class) {
|
||||
FLUID_CRAFTING_AMOUNT(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new ContainerCraftAmount(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartFluidPatternTerminal inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
return new GuiFluidCraftAmount(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -13,6 +13,7 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidDrop DROP = new ItemFluidDrop().register();
|
||||
public static ItemFluidEncodedPattern PATTERN = new ItemFluidEncodedPattern().register();
|
||||
public static ItemPartFluidPatternTerminal FLUID_TERMINAL = new ItemPartFluidPatternTerminal().register();
|
||||
public static ItemPartFluidPatternTerminalEx FLUID_TERMINAL_EX = new ItemPartFluidPatternTerminalEx().register();
|
||||
public static ItemPartFluidInterface FLUID_INTERFACE = new ItemPartFluidInterface().register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
import com.glodblock.github.network.CPacketTransferRecipe;
|
||||
@@ -37,7 +38,7 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle
|
||||
}
|
||||
|
||||
private boolean isCorrectGui(GuiContainer firstGui) {
|
||||
return firstGui instanceof GuiFluidPatternTerminal;
|
||||
return firstGui instanceof GuiFluidPatternTerminal || firstGui instanceof GuiFluidPatternTerminalEx;
|
||||
}
|
||||
|
||||
private boolean notUseOther(IRecipeHandler recipeHandler) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import codechicken.nei.api.API;
|
||||
import codechicken.nei.api.IConfigureNEI;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
|
||||
public class NEI_FC_Config implements IConfigureNEI {
|
||||
@@ -12,6 +13,7 @@ public class NEI_FC_Config implements IConfigureNEI {
|
||||
public void loadConfig() {
|
||||
for (String identifier : FluidRecipe.getSupportRecipes()) {
|
||||
API.registerGuiOverlayHandler(GuiFluidPatternTerminal.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier);
|
||||
API.registerGuiOverlayHandler(GuiFluidPatternTerminalEx.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -3,6 +3,7 @@ package com.glodblock.github.nei.recipes.extractor;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import com.glodblock.github.nei.object.IRecipeExtractor;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import gregtech.api.enums.ItemList;
|
||||
import gregtech.common.items.GT_FluidDisplayItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -24,8 +25,8 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
if (r) removeSpecial(rawInputs);
|
||||
List<PositionedStack> compressed = compress(rawInputs);
|
||||
if (r) compressed.remove(compressed.size() - 1);
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < compressed.size(); i ++) {
|
||||
if (compressed.get(i) == null) continue;
|
||||
@@ -48,7 +49,6 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor {
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<PositionedStack> compressed = compress(rawOutputs);
|
||||
if (r) compressed.remove(compressed.size() - 1);
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < compressed.size(); i ++) {
|
||||
if (compressed.get(i) == null) continue;
|
||||
@@ -68,16 +68,27 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private void removeSpecial(List<PositionedStack> list) {
|
||||
for (int i = list.size() - 1; i >= 0; i --) {
|
||||
PositionedStack positionedStack = list.get(i);
|
||||
if (positionedStack != null &&
|
||||
(positionedStack.items[0].isItemEqual(ItemList.Tool_DataStick.get(1)) || positionedStack.items[0].isItemEqual(ItemList.Tool_DataOrb.get(1)))) {
|
||||
list.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<PositionedStack> compress(List<PositionedStack> list) {
|
||||
List<PositionedStack> comp = new LinkedList<>();
|
||||
for (PositionedStack positionedStack : list) {
|
||||
if (positionedStack == null) continue;
|
||||
ItemStack currentStack = positionedStack.items[0];
|
||||
ItemStack currentStack = positionedStack.items[0].copy();
|
||||
if (currentStack.stackSize == 0) continue;
|
||||
boolean find = false;
|
||||
for (PositionedStack storedStack : comp) {
|
||||
if (storedStack == null) continue;
|
||||
ItemStack firstStack = storedStack.items[0];
|
||||
ItemStack firstStack = storedStack.items[0].copy();
|
||||
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
|
||||
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
|
||||
find = true;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -57,7 +58,7 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
String Name = message.Name;
|
||||
String Value = message.Value;
|
||||
final Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if( Name.startsWith( "PatternTerminal." ) && c instanceof ContainerFluidPatternTerminal)
|
||||
if( Name.startsWith( "PatternTerminal." ) && (c instanceof ContainerFluidPatternTerminal))
|
||||
{
|
||||
final ContainerFluidPatternTerminal cpt = (ContainerFluidPatternTerminal) c;
|
||||
switch (Name) {
|
||||
@@ -80,6 +81,26 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
cpt.doubleStacks(Value.equals("1"));
|
||||
break;
|
||||
}
|
||||
} else if( Name.startsWith( "PatternTerminal." ) && (c instanceof ContainerFluidPatternTerminalEx))
|
||||
{
|
||||
final ContainerFluidPatternTerminalEx cpt = (ContainerFluidPatternTerminalEx) c;
|
||||
switch (Name) {
|
||||
case "PatternTerminal.Encode":
|
||||
if (Value.equals("2"))
|
||||
cpt.encodeAndMoveToInventory();
|
||||
else
|
||||
cpt.encode();
|
||||
break;
|
||||
case "PatternTerminal.Clear":
|
||||
cpt.clear();
|
||||
break;
|
||||
case "PatternTerminal.Substitute":
|
||||
cpt.getPatternTerminal().setSubstitution(Value.equals("1"));
|
||||
break;
|
||||
case "PatternTerminal.Double":
|
||||
cpt.doubleStacks(Value.equals("1"));
|
||||
break;
|
||||
}
|
||||
} else if(Name.equals( "Terminal.Cpu" ) && c instanceof ContainerFluidCraftConfirm) {
|
||||
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
|
||||
qk.cycleCpu( Value.equals( "Next" ) );
|
||||
|
||||
@@ -4,9 +4,7 @@ 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.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
@@ -120,6 +121,48 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
}
|
||||
c.onCraftMatrixChanged(inputSlot);
|
||||
c.onCraftMatrixChanged(outputSlot);
|
||||
} else if (c instanceof ContainerFluidPatternTerminalEx) {
|
||||
ContainerFluidPatternTerminalEx cf = (ContainerFluidPatternTerminalEx) c;
|
||||
IInventory inputSlot = cf.getInventoryByName("crafting");
|
||||
IInventory outputSlot = cf.getInventoryByName("output");
|
||||
for (int i = 0; i < inputSlot.getSizeInventory(); i ++) {
|
||||
inputSlot.setInventorySlotContents(i, null);
|
||||
}
|
||||
for (int i = 0; i < outputSlot.getSizeInventory(); i ++) {
|
||||
outputSlot.setInventorySlotContents(i, null);
|
||||
}
|
||||
for (OrderStack<?> stack : message.inputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
}
|
||||
else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
}
|
||||
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < inputSlot.getSizeInventory())
|
||||
inputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
for (OrderStack<?> stack : message.outputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
}
|
||||
else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
}
|
||||
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < outputSlot.getSizeInventory())
|
||||
outputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
c.onCraftMatrixChanged(inputSlot);
|
||||
c.onCraftMatrixChanged(outputSlot);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_DROP = "fluid_drop";
|
||||
public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL = "part_fluid_pattern_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL_EX = "part_fluid_pattern_terminal_ex";
|
||||
public static final String ITEM_PART_FLUID_INTERFACE = "part_fluid_interface";
|
||||
public static final String ITEM_FLUID_PACKET = "fluid_packet";
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
@@ -26,6 +27,7 @@ public class NameConst {
|
||||
|
||||
public static final String GUI_KEY = FluidCraft.MODID + ".gui.";
|
||||
public static final String GUI_FLUID_PATTERN_TERMINAL = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL;
|
||||
public static final String GUI_FLUID_PATTERN_TERMINAL_EX = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL_EX;
|
||||
public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
||||
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
||||
|
||||
|
||||
Reference in new issue
Block a user