mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 07:47:55 +00:00
refactor 2
This commit is contained in:
1 parent
a70ace4742
commit
018d488bee
27 files changed
+829
-1780
No files matched your search
@@ -7,7 +7,7 @@ import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.FCBasePartContainer;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -26,7 +26,7 @@ public class GuiBaseFluidPatternTerminal extends GuiItemMonitor {
|
||||
private static final String CRAFTMODE_CRFTING = "1";
|
||||
private static final String CRAFTMODE_PROCESSING = "0";
|
||||
|
||||
public FCBasePartContainer container;
|
||||
public ContainerFluidPatternTerminal container;
|
||||
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
@@ -42,8 +42,8 @@ public class GuiBaseFluidPatternTerminal extends GuiItemMonitor {
|
||||
private GuiFCImgButton combineDisableBtn;
|
||||
|
||||
public GuiBaseFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new FCBasePartContainer(inventoryPlayer, te));
|
||||
this.container = (FCBasePartContainer) this.inventorySlots;
|
||||
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
|
||||
this.container = (ContainerFluidPatternTerminal) this.inventorySlots;
|
||||
setReservedSpace(81);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -23,7 +23,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiItemMonitor {
|
||||
private static final String PRIORITY_DISABLE = "0";
|
||||
private static final String PRIORITY_ENABLE = "1";
|
||||
|
||||
public FCBasePartContainerEx container;
|
||||
public ContainerFluidPatternTerminalEx container;
|
||||
|
||||
private GuiImgButton substitutionsEnabledBtn;
|
||||
private GuiImgButton substitutionsDisabledBtn;
|
||||
@@ -41,8 +41,8 @@ public class GuiBaseFluidPatternTerminalEx extends GuiItemMonitor {
|
||||
private final GuiScrollbar processingScrollBar = new GuiScrollbar();
|
||||
|
||||
public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new FCBasePartContainerEx(inventoryPlayer, te));
|
||||
this.container = (FCBasePartContainerEx) this.inventorySlots;
|
||||
super(inventoryPlayer, te, new ContainerFluidPatternTerminalEx(inventoryPlayer, te));
|
||||
this.container = (ContainerFluidPatternTerminalEx) this.inventorySlots;
|
||||
setReservedSpace(81);
|
||||
|
||||
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
|
||||
|
||||
@@ -27,7 +27,6 @@ public class GuiFCPriority extends AEBaseGui {
|
||||
|
||||
private GuiNumberBox priority;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
private GuiButton plus1;
|
||||
private GuiButton plus10;
|
||||
private GuiButton plus100;
|
||||
@@ -71,7 +70,7 @@ public class GuiFCPriority extends AEBaseGui {
|
||||
this.OriginalGui = GuiType.DUAL_INTERFACE;
|
||||
} else if (target instanceof PartFluidInterface) {
|
||||
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
|
||||
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
|
||||
this.OriginalGui = GuiType.DUAL_INTERFACE_PART;
|
||||
} else if (target instanceof PartFluidStorageBus) {
|
||||
myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
|
||||
this.OriginalGui = GuiType.FLUID_STORAGE_BUS;
|
||||
|
||||
@@ -5,15 +5,15 @@ import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidIO;
|
||||
import com.glodblock.github.common.parts.PartFluidImportBus;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GuiFluidIO extends GuiUpgradeable {
|
||||
private final PartSharedFluidBus bus;
|
||||
private final FCSharedFluidBus bus;
|
||||
|
||||
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) {
|
||||
public GuiFluidIO(InventoryPlayer inventoryPlayer, FCSharedFluidBus te) {
|
||||
super(new ContainerFluidIO(inventoryPlayer, te));
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,10 @@ import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
|
||||
import com.glodblock.github.client.me.FluidRepo;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GuiFluidMonitor extends FCGuiMonitor<IAEFluidStack> {
|
||||
|
||||
public GuiFluidMonitor(
|
||||
|
||||
@@ -4,20 +4,21 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
|
||||
import com.glodblock.github.common.parts.PartFluidExportBus;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerFluidIO extends ContainerFluidConfigurable {
|
||||
private final PartSharedFluidBus bus;
|
||||
public class ContainerFluidIO extends FCContainerFluidConfigurable {
|
||||
private final FCSharedFluidBus bus;
|
||||
|
||||
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te) {
|
||||
public ContainerFluidIO(InventoryPlayer ip, FCSharedFluidBus te) {
|
||||
super(ip, te);
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
public PartSharedFluidBus getBus() {
|
||||
public FCSharedFluidBus getBus() {
|
||||
return this.bus;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketMEInventoryUpdate;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -40,12 +43,8 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
private final IItemList<IAEFluidStack> items = AEApi.instance().storage().createFluidList();
|
||||
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
|
||||
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
this(ip, monitorable, true);
|
||||
@@ -119,11 +118,11 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
|
||||
@Override
|
||||
protected void processItemList() {
|
||||
if (!this.items.isEmpty()) {
|
||||
if (!this.fluids.isEmpty()) {
|
||||
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
|
||||
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
|
||||
|
||||
for (final IAEFluidStack is : this.items) {
|
||||
for (final IAEFluidStack is : this.fluids) {
|
||||
final IAEFluidStack send = monitorCache.findPrecise(is);
|
||||
if (send == null) {
|
||||
is.setStackSize(0);
|
||||
@@ -134,7 +133,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
}
|
||||
|
||||
if (!piu.isEmpty()) {
|
||||
this.items.resetStatus();
|
||||
this.fluids.resetStatus();
|
||||
|
||||
for (final Object c : this.crafters) {
|
||||
if (c instanceof EntityPlayer) {
|
||||
@@ -173,7 +172,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
public void postChange(
|
||||
IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
|
||||
for (final IAEFluidStack is : change) {
|
||||
this.items.add(is);
|
||||
this.fluids.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,5 +309,4 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -13,7 +13,7 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.inventory.PatternConsumer;
|
||||
import com.glodblock.github.inventory.IPatternConsumer;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
@@ -30,7 +30,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer {
|
||||
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
|
||||
|
||||
private final TileFluidPatternEncoder tile;
|
||||
|
||||
|
||||
+138
-204
@@ -1,222 +1,156 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.PatternConsumer;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
|
||||
public class ContainerFluidPatternTerminal extends FCBasePartContainer implements PatternConsumer {
|
||||
public class ContainerFluidPatternTerminal extends FCContainerEncodeTerminal {
|
||||
|
||||
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
public ContainerFluidPatternTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
final IInventory output = this.patternTerminal.getInventoryByName("output");
|
||||
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
|
||||
this.craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
this.outputSlots = new OptionalSlotFake[3];
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlotToContainer(
|
||||
this.craftingSlots[x + y * 3] =
|
||||
new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.craftSlot = new SlotPatternTerm(
|
||||
ip.player,
|
||||
this.getActionSource(),
|
||||
this.getPowerSource(),
|
||||
monitorable,
|
||||
this.crafting,
|
||||
patternInv,
|
||||
this.cOut,
|
||||
110,
|
||||
-76 + 18,
|
||||
this,
|
||||
2,
|
||||
this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.addSlotToContainer(
|
||||
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
|
||||
this.outputSlots[y].setRenderDisabled(false);
|
||||
}
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
private static boolean isPattern(final ItemStack output) {
|
||||
if (output == null) {
|
||||
return false;
|
||||
}
|
||||
if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
return true;
|
||||
}
|
||||
final IDefinitions defs = AEApi.instance().definitions();
|
||||
return defs.items().encodedPattern().isSameAs(output)
|
||||
|| defs.materials().blankPattern().isSameAs(output);
|
||||
}
|
||||
|
||||
public void encodeAllItemAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (output != null) {
|
||||
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.entityDropItem(output, 0);
|
||||
private void updateOrderOfOutputSlots() {
|
||||
if (!this.isCraftingMode()) {
|
||||
this.craftSlot.xDisplayPosition = -9000;
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
|
||||
}
|
||||
this.patternSlotOUT.putStack(null);
|
||||
this.patternSlotIN.putStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode() {
|
||||
if (!checkHasFluidPattern()) {
|
||||
super.encode();
|
||||
return;
|
||||
}
|
||||
ItemStack stack = this.patternSlotOUT.getStack();
|
||||
if (stack == null) {
|
||||
stack = this.patternSlotIN.getStack();
|
||||
if (!isPattern(stack)) {
|
||||
return;
|
||||
}
|
||||
if (stack.stackSize == 1) {
|
||||
this.patternSlotIN.putStack(null);
|
||||
} else {
|
||||
stack.stackSize--;
|
||||
}
|
||||
encodeFluidPattern();
|
||||
} else if (isPattern(stack)) {
|
||||
encodeFluidPattern();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkHasFluidPattern() {
|
||||
if (this.craftingMode) {
|
||||
return false;
|
||||
}
|
||||
boolean hasFluid = false, search = false;
|
||||
for (Slot craftingSlot : this.craftingSlots) {
|
||||
final ItemStack crafting = craftingSlot.getStack();
|
||||
if (crafting == null) {
|
||||
continue;
|
||||
}
|
||||
search = true;
|
||||
if (crafting.getItem() instanceof ItemFluidPacket) {
|
||||
hasFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!search) { // search=false -> inputs were empty
|
||||
return false;
|
||||
}
|
||||
// `search` should be true at this point
|
||||
for (Slot outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (out == null) {
|
||||
continue;
|
||||
}
|
||||
search = false;
|
||||
if (hasFluid) {
|
||||
break;
|
||||
} else if (out.getItem() instanceof ItemFluidPacket) {
|
||||
hasFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasFluid && !search; // search=true -> outputs were empty
|
||||
}
|
||||
|
||||
private void encodeFluidPattern() {
|
||||
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
|
||||
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
|
||||
pattern.setInputs(collectInventory(craftingSlots));
|
||||
pattern.setOutputs(collectInventory(outputSlots));
|
||||
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
|
||||
patternSlotOUT.putStack(pattern.writeToStack());
|
||||
}
|
||||
|
||||
private static IAEItemStack[] collectInventory(Slot[] slots) {
|
||||
// see note at top of FluidPatternDetails
|
||||
IAEItemStack[] stacks = new IAEItemStack[slots.length];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
ItemStack stack = slots[i].getStack();
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof ItemFluidPacket) {
|
||||
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
|
||||
if (dropStack != null) {
|
||||
stacks[i] = dropStack;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
IAEItemStack aeStack = AEItemStack.create(stack);
|
||||
stacks[i] = aeStack;
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
|
||||
if (getPatternTerminal() != null) {
|
||||
getPatternTerminal().onChangeCrafting(inputs, outputs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
if (this.isCraftingMode()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.MOVE_REGION) {
|
||||
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.PICKUP_SINGLE) {
|
||||
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
|
||||
return;
|
||||
}
|
||||
Slot slot = getSlot(slotId);
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs)
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
FluidStack fluid = null;
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
fluid = Util.getFluidFromItem(stack);
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
|
||||
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
|
||||
if (fluid != null && fluid.equals(origin)) {
|
||||
fluid.amount += origin.amount;
|
||||
if (fluid.amount <= 0) fluid = null;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
}
|
||||
if (fluid == null) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
ItemStack is = clickSlot.getStack();
|
||||
if (is != null
|
||||
&& !patternSlotOUT.getHasStack()
|
||||
&& is.stackSize == 1
|
||||
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
|
||||
ItemStack output = is.copy();
|
||||
patternSlotOUT.putStack(output);
|
||||
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
} else {
|
||||
return super.transferStackInSlot(p, idx);
|
||||
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = -9000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validPatternSlot(Slot slot) {
|
||||
return slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
|
||||
super.putStackInSlot(par1, par2ItemStack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
|
||||
super.putStacksInSlots(par1ArrayOfItemStack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
private ItemStack getAndUpdateOutput() {
|
||||
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
}
|
||||
|
||||
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
|
||||
this.cOut.setInventorySlotContents(0, is);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack[] getOutputs() {
|
||||
if (this.isCraftingMode()) {
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
if (out != null && out.stackSize > 0) {
|
||||
return new ItemStack[] {out};
|
||||
}
|
||||
}
|
||||
return super.getOutputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.patternTerminal.isCraftingRecipe() : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.patternTerminal.isCraftingRecipe() : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.patternTerminal.isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.patternTerminal.isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
if (field.equals("craftingMode")) {
|
||||
this.getAndUpdateOutput();
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
super.clear();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
private void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doubleStacks(boolean isShift) {
|
||||
if (!isCraftingMode()) {
|
||||
super.doubleStacks(isShift);
|
||||
}
|
||||
}
|
||||
}
|
||||
+129
-192
@@ -1,221 +1,158 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.PatternConsumer;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
|
||||
public class ContainerFluidPatternTerminalEx extends FCContainerEncodeTerminal {
|
||||
|
||||
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
private static final int CRAFTING_GRID_PAGES = 2;
|
||||
private static final int CRAFTING_GRID_WIDTH = 4;
|
||||
private static final int CRAFTING_GRID_HEIGHT = 4;
|
||||
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
|
||||
|
||||
public ContainerFluidPatternTerminalEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
|
||||
private static boolean isPattern(final ItemStack output) {
|
||||
if (output == null) {
|
||||
return false;
|
||||
}
|
||||
if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
return true;
|
||||
}
|
||||
final IDefinitions defs = AEApi.instance().definitions();
|
||||
return defs.items().encodedPattern().isSameAs(output)
|
||||
|| defs.materials().blankPattern().isSameAs(output);
|
||||
}
|
||||
|
||||
public void encodeAllItemAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (output != null) {
|
||||
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.entityDropItem(output, 0);
|
||||
}
|
||||
this.patternSlotOUT.putStack(null);
|
||||
this.patternSlotIN.putStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode() {
|
||||
if (!checkHasFluidPattern()) {
|
||||
super.encode();
|
||||
return;
|
||||
}
|
||||
ItemStack stack = this.patternSlotOUT.getStack();
|
||||
if (stack == null) {
|
||||
stack = this.patternSlotIN.getStack();
|
||||
if (!isPattern(stack)) {
|
||||
return;
|
||||
}
|
||||
if (stack.stackSize == 1) {
|
||||
this.patternSlotIN.putStack(null);
|
||||
} else {
|
||||
stack.stackSize--;
|
||||
}
|
||||
encodeFluidPattern();
|
||||
} else if (isPattern(stack)) {
|
||||
encodeFluidPattern();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkHasFluidPattern() {
|
||||
boolean hasFluid = false, search = false;
|
||||
for (Slot craftingSlot : this.craftingSlots) {
|
||||
final ItemStack crafting = craftingSlot.getStack();
|
||||
if (crafting == null) {
|
||||
continue;
|
||||
}
|
||||
search = true;
|
||||
if (crafting.getItem() instanceof ItemFluidPacket) {
|
||||
hasFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!search) { // search=false -> inputs were empty
|
||||
return false;
|
||||
}
|
||||
// `search` should be true at this point
|
||||
for (Slot outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
if (out == null) {
|
||||
continue;
|
||||
}
|
||||
search = false;
|
||||
if (hasFluid) {
|
||||
break;
|
||||
} else if (out.getItem() instanceof ItemFluidPacket) {
|
||||
hasFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasFluid && !search; // search=true -> outputs were empty
|
||||
}
|
||||
|
||||
private void encodeFluidPattern() {
|
||||
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
|
||||
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
|
||||
pattern.setCombine(this.combine ? 1 : 0);
|
||||
pattern.setInputs(collectInventory(craftingSlots));
|
||||
pattern.setOutputs(collectInventory(outputSlots));
|
||||
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
|
||||
patternSlotOUT.putStack(pattern.writeToStack());
|
||||
}
|
||||
|
||||
private static IAEItemStack[] collectInventory(Slot[] slots) {
|
||||
// see note at top of FluidPatternDetails
|
||||
IAEItemStack[] stacks = new IAEItemStack[slots.length];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
ItemStack stack = slots[i].getStack();
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof ItemFluidPacket) {
|
||||
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
|
||||
if (dropStack != null) {
|
||||
stacks[i] = dropStack;
|
||||
continue;
|
||||
}
|
||||
this.craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
|
||||
this.outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
|
||||
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
|
||||
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
this.addSlotToContainer(
|
||||
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] =
|
||||
new ProcessingSlotFake(
|
||||
crafting,
|
||||
this,
|
||||
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
|
||||
15,
|
||||
-83,
|
||||
x,
|
||||
y,
|
||||
x + 4));
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
this.addSlotToContainer(
|
||||
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] =
|
||||
new ProcessingSlotFake(
|
||||
output,
|
||||
this,
|
||||
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
|
||||
112,
|
||||
-83,
|
||||
-x,
|
||||
y,
|
||||
x));
|
||||
}
|
||||
}
|
||||
IAEItemStack aeStack = AEItemStack.create(stack);
|
||||
stacks[i] = aeStack;
|
||||
}
|
||||
return stacks;
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
|
||||
if (getPatternTerminal() != null) {
|
||||
getPatternTerminal().onChangeCrafting(inputs, outputs);
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx < 4) // outputs
|
||||
{
|
||||
return inverted || idx == 0;
|
||||
} else {
|
||||
return !inverted || idx == 4;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validPatternSlot(Slot slot) {
|
||||
return slot instanceof ProcessingSlotFake;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
|
||||
inverted = patternTerminal.isInverted();
|
||||
activePage = patternTerminal.getActivePage();
|
||||
offsetSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void offsetSlots() {
|
||||
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
((ProcessingSlotFake) this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS])
|
||||
.setHidden(page != activePage || x > 0 && inverted);
|
||||
((ProcessingSlotFake) this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS])
|
||||
.setHidden(page != activePage || x > 0 && !inverted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(String field, Object oldValue, Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
if (field.equals("inverted") || field.equals("activePage")) {
|
||||
offsetSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
super.onSlotChange(s);
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
inverted = patternTerminal.isInverted();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.MOVE_REGION) {
|
||||
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.PICKUP_SINGLE) {
|
||||
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
|
||||
return;
|
||||
}
|
||||
Slot slot = getSlot(slotId);
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if ((slot instanceof OptionalSlotFake)
|
||||
&& stack != null
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
FluidStack fluid = null;
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
fluid = Util.getFluidFromItem(stack);
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
|
||||
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
|
||||
if (fluid != null && fluid.equals(origin)) {
|
||||
fluid.amount += origin.amount;
|
||||
if (fluid.amount <= 0) fluid = null;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
}
|
||||
if (fluid == null) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
|
||||
if (stack == null && slot.getStack() != null && slot.getStack().getItem() instanceof ItemFluidPacket) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.craftingMode = false;
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
ItemStack is = clickSlot.getStack();
|
||||
if (is != null
|
||||
&& !patternSlotOUT.getHasStack()
|
||||
&& is.stackSize == 1
|
||||
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
|
||||
ItemStack output = is.copy();
|
||||
patternSlotOUT.putStack(output);
|
||||
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
} else {
|
||||
return super.transferStackInSlot(p, idx);
|
||||
public void encode() {
|
||||
this.craftingMode = false;
|
||||
super.encode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCraftingMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class ProcessingSlotFake extends OptionalSlotFake {
|
||||
|
||||
private static final int POSITION_SHIFT = 9000;
|
||||
private boolean hidden = false;
|
||||
|
||||
public ProcessingSlotFake(
|
||||
IInventory inv,
|
||||
IOptionalSlotHost containerBus,
|
||||
int idx,
|
||||
int x,
|
||||
int y,
|
||||
int offX,
|
||||
int offY,
|
||||
int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
this.setRenderDisabled(false);
|
||||
}
|
||||
|
||||
public void setHidden(boolean hide) {
|
||||
if (this.hidden != hide) {
|
||||
this.hidden = hide;
|
||||
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -10,6 +10,7 @@ import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerFluidConfigurable;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
|
||||
@@ -18,7 +19,7 @@ import java.util.Iterator;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class ContainerFluidStorageBus extends ContainerFluidConfigurable {
|
||||
public class ContainerFluidStorageBus extends FCContainerFluidConfigurable {
|
||||
|
||||
public final PartFluidStorageBus bus;
|
||||
|
||||
|
||||
@@ -1,620 +0,0 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FCBasePartContainer extends ContainerItemMonitor
|
||||
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
|
||||
private final PartFluidPatternTerminal patternTerminal;
|
||||
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
private final IInventory crafting;
|
||||
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
|
||||
protected final SlotPatternTerm craftSlot;
|
||||
protected final SlotRestrictedInput patternSlotIN;
|
||||
protected final SlotRestrictedInput patternSlotOUT;
|
||||
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
|
||||
@GuiSync(96)
|
||||
public boolean substitute = false;
|
||||
|
||||
@GuiSync(95)
|
||||
public boolean combine = false;
|
||||
|
||||
@GuiSync(94)
|
||||
public boolean beSubstitute = false;
|
||||
|
||||
public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
this.patternTerminal = (PartFluidPatternTerminal) monitorable;
|
||||
|
||||
final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern");
|
||||
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
|
||||
|
||||
this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlotToContainer(
|
||||
this.craftingSlots[x + y * 3] =
|
||||
new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.craftSlot = new SlotPatternTerm(
|
||||
ip.player,
|
||||
this.getActionSource(),
|
||||
this.getPowerSource(),
|
||||
monitorable,
|
||||
this.crafting,
|
||||
patternInv,
|
||||
this.cOut,
|
||||
110,
|
||||
-76 + 18,
|
||||
this,
|
||||
2,
|
||||
this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.addSlotToContainer(
|
||||
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
|
||||
this.outputSlots[y].setRenderDisabled(false);
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotIN = new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
|
||||
patternInv,
|
||||
0,
|
||||
147,
|
||||
-72 - 9,
|
||||
this.getInventoryPlayer()));
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotOUT = new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
|
||||
patternInv,
|
||||
1,
|
||||
147,
|
||||
-72 + 34,
|
||||
this.getInventoryPlayer()));
|
||||
|
||||
this.patternSlotOUT.setStackLimit(1);
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
static boolean canDoubleStacks(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long emptyStots =
|
||||
enabledSlots.stream().filter(s -> s.getStack() == null).count();
|
||||
long fullSlots = enabledSlots.stream()
|
||||
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
|
||||
.count();
|
||||
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
|
||||
}
|
||||
|
||||
static void doubleStacksInternal(SlotFake[] slots) {
|
||||
List<ItemStack> overFlowStacks = new ArrayList<>();
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
for (final Slot s : enabledSlots) {
|
||||
ItemStack st = s.getStack();
|
||||
if (st == null) continue;
|
||||
if (Util.isFluidPacket(st)) {
|
||||
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
|
||||
if (fluidStack != null) {
|
||||
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
|
||||
if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2;
|
||||
}
|
||||
s.putStack(ItemFluidPacket.newStack(fluidStack));
|
||||
} else if (st.stackSize * 2 > 127) {
|
||||
overFlowStacks.add(st.copy());
|
||||
} else {
|
||||
st.stackSize *= 2;
|
||||
s.putStack(st);
|
||||
}
|
||||
}
|
||||
Iterator<ItemStack> ow = overFlowStacks.iterator();
|
||||
for (final Slot s : enabledSlots) {
|
||||
if (!ow.hasNext()) break;
|
||||
if (s.getStack() != null) continue;
|
||||
s.putStack(ow.next());
|
||||
}
|
||||
assert !ow.hasNext();
|
||||
}
|
||||
|
||||
static boolean containsItem(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long item = enabledSlots.stream()
|
||||
.filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack()))
|
||||
.count();
|
||||
return item > 0;
|
||||
}
|
||||
|
||||
static boolean containsFluid(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long fluid = enabledSlots.stream()
|
||||
.filter(s -> Util.isFluidPacket(s.getStack()))
|
||||
.count();
|
||||
return fluid > 0;
|
||||
}
|
||||
|
||||
private void updateOrderOfOutputSlots() {
|
||||
if (!this.isCraftingMode()) {
|
||||
this.craftSlot.xDisplayPosition = -9000;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
|
||||
}
|
||||
} else {
|
||||
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = -9000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
|
||||
super.putStackInSlot(par1, par2ItemStack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
|
||||
super.putStacksInSlots(par1ArrayOfItemStack);
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
private ItemStack getAndUpdateOutput() {
|
||||
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
}
|
||||
|
||||
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
|
||||
this.cOut.setInventorySlotContents(0, is);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(
|
||||
final IInventory inv,
|
||||
final int slot,
|
||||
final InvOperation mc,
|
||||
final ItemStack removedStack,
|
||||
final ItemStack newStack) {}
|
||||
|
||||
public void encodeAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (output != null) {
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.entityDropItem(output, 0);
|
||||
}
|
||||
this.patternSlotOUT.putStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
|
||||
// if there is no input, this would be silly.
|
||||
if (in == null || out == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (output != null && !this.isPattern(output)) {
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output == null) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (!this.isPattern(output)) {
|
||||
return; // no blanks.
|
||||
}
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.stackSize--;
|
||||
if (output.stackSize == 0) {
|
||||
this.patternSlotIN.putStack(null);
|
||||
}
|
||||
|
||||
// add a new encoded pattern.
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance()
|
||||
.definitions()
|
||||
.items()
|
||||
.encodedPattern()
|
||||
.maybeStack(1)
|
||||
.asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance()
|
||||
.definitions()
|
||||
.items()
|
||||
.encodedPattern()
|
||||
.maybeStack(1)
|
||||
.asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
final NBTTagCompound encodedValue = new NBTTagCompound();
|
||||
|
||||
final NBTTagList tagIn = new NBTTagList();
|
||||
final NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
for (final ItemStack i : out) {
|
||||
tagOut.appendTag(this.createItemTag(i));
|
||||
}
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("crafting", this.isCraftingMode());
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
private ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[9];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (input[x] != null) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] getOutputs() {
|
||||
if (this.isCraftingMode()) {
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
|
||||
if (out != null && out.stackSize > 0) {
|
||||
return new ItemStack[] {out};
|
||||
}
|
||||
} else {
|
||||
final List<ItemStack> list = new ArrayList<>(3);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if (out != null && out.stackSize > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[list.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPattern(final ItemStack output) {
|
||||
if (output == null) {
|
||||
return false;
|
||||
}
|
||||
if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
return true;
|
||||
}
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern;
|
||||
}
|
||||
|
||||
private NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (i != null) {
|
||||
i.writeToNBT(c);
|
||||
c.setInteger("Count", i.stackSize);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) {
|
||||
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
|
||||
final IAEItemStack out = packetPatternSlot.slotItem.copy();
|
||||
InventoryAdaptor inv = new AdaptorPlayerHand(this.getPlayerInv().player);
|
||||
final InventoryAdaptor playerInv =
|
||||
InventoryAdaptor.getAdaptor(this.getPlayerInv().player, ForgeDirection.UNKNOWN);
|
||||
|
||||
if (packetPatternSlot.shift) {
|
||||
inv = playerInv;
|
||||
}
|
||||
|
||||
if (inv.simulateAdd(out.getItemStack()) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IAEItemStack extracted = Platform.poweredExtraction(
|
||||
this.getPowerSource(), this.getCellInventory(), out, this.getActionSource());
|
||||
final EntityPlayer p = this.getPlayerInv().player;
|
||||
|
||||
if (extracted != null) {
|
||||
inv.addItems(extracted.getItemStack());
|
||||
if (p instanceof EntityPlayerMP) {
|
||||
this.updateHeld((EntityPlayerMP) p);
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
|
||||
final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3);
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(
|
||||
x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack());
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj);
|
||||
|
||||
if (r == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal().getItemInventory();
|
||||
final IItemList<IAEItemStack> all = storage.getStorageList();
|
||||
|
||||
final ItemStack is = r.getCraftingResult(ic);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
if (ic.getStackInSlot(x) != null) {
|
||||
final ItemStack pulled = Platform.extractItemsByRecipe(
|
||||
this.getPowerSource(),
|
||||
this.getActionSource(),
|
||||
storage,
|
||||
p.worldObj,
|
||||
r,
|
||||
is,
|
||||
ic,
|
||||
ic.getStackInSlot(x),
|
||||
x,
|
||||
all,
|
||||
Actionable.MODULATE,
|
||||
ItemViewCell.createFilter(this.getViewCells()));
|
||||
real.setInventorySlotContents(x, pulled);
|
||||
}
|
||||
}
|
||||
|
||||
final IRecipe rr = Platform.findMatchingRecipe(real, p.worldObj);
|
||||
|
||||
if (rr == r && Platform.isSameItemPrecise(rr.getCraftingResult(real), is)) {
|
||||
final SlotCrafting sc = new SlotCrafting(p, real, this.cOut, 0, 0, 0);
|
||||
sc.onPickupFromSlot(p, is);
|
||||
|
||||
for (int x = 0; x < real.getSizeInventory(); x++) {
|
||||
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x));
|
||||
|
||||
if (failed != null) {
|
||||
p.dropPlayerItemWithRandomChoice(failed, false);
|
||||
}
|
||||
}
|
||||
|
||||
inv.addItems(is);
|
||||
if (p instanceof EntityPlayerMP) {
|
||||
this.updateHeld((EntityPlayerMP) p);
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
} else {
|
||||
for (int x = 0; x < real.getSizeInventory(); x++) {
|
||||
final ItemStack failed = real.getStackInSlot(x);
|
||||
if (failed != null) {
|
||||
this.getCellInventory()
|
||||
.injectItems(
|
||||
AEItemStack.create(failed),
|
||||
Actionable.MODULATE,
|
||||
new MachineSource(this.getPatternTerminal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
this.substitute = this.patternTerminal.isSubstitution();
|
||||
this.combine = this.patternTerminal.shouldCombine();
|
||||
this.beSubstitute = this.patternTerminal.canBeSubstitute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
|
||||
if (field.equals("craftingMode")) {
|
||||
this.getAndUpdateOutput();
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
for (final Object crafter : this.crafters) {
|
||||
final ICrafting icrafting = (ICrafting) crafter;
|
||||
|
||||
for (final Object g : this.inventorySlots) {
|
||||
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
|
||||
final Slot sri = (Slot) g;
|
||||
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
|
||||
}
|
||||
}
|
||||
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.craftingSlots) {
|
||||
s.putStack(null);
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(null);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
private void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
public PartFluidPatternTerminal getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
private boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
private boolean isSubstitute() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public void setSubstitute(final boolean substitute) {
|
||||
this.substitute = substitute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("player")) {
|
||||
return this.getInventoryPlayer();
|
||||
}
|
||||
return this.getPatternTerminal().getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void toggleSubstitute() {
|
||||
this.substitute = !this.substitute;
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
public boolean isCraftingMode() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
public void doubleStacks(boolean isShift) {
|
||||
if (!isCraftingMode() && canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
if (isShift && (containsItem(outputSlots) || containsItem(craftingSlots))) {
|
||||
while (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
doubleStacksInternal(this.outputSlots);
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
+250
-225
@@ -1,26 +1,31 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
package com.glodblock.github.client.gui.container.base;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerItemMonitor;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.IPatternConsumer;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -30,65 +35,49 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
|
||||
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket, IPatternConsumer {
|
||||
|
||||
private static final int CRAFTING_GRID_PAGES = 2;
|
||||
private static final int CRAFTING_GRID_WIDTH = 4;
|
||||
private static final int CRAFTING_GRID_HEIGHT = 4;
|
||||
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
|
||||
protected final FCFluidEncodeTerminal patternTerminal;
|
||||
protected final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
protected final IInventory crafting;
|
||||
protected final SlotRestrictedInput patternSlotIN;
|
||||
protected final SlotRestrictedInput patternSlotOUT;
|
||||
protected SlotFake[] craftingSlots;
|
||||
protected OptionalSlotFake[] outputSlots;
|
||||
protected SlotPatternTerm craftSlot;
|
||||
|
||||
protected final ProcessingSlotFake[] craftingSlots =
|
||||
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
|
||||
private final PartFluidPatternTerminalEx patternTerminal;
|
||||
protected final ProcessingSlotFake[] outputSlots =
|
||||
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
|
||||
@GuiSync(96)
|
||||
public boolean substitute = false;
|
||||
|
||||
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
this.patternTerminal = (PartFluidPatternTerminalEx) monitorable;
|
||||
@GuiSync(95)
|
||||
public boolean combine = false;
|
||||
|
||||
@GuiSync(94)
|
||||
public boolean beSubstitute = false;
|
||||
|
||||
@GuiSync(93)
|
||||
public boolean inverted;
|
||||
|
||||
@GuiSync(92)
|
||||
public int activePage = 0;
|
||||
|
||||
@GuiSync(91)
|
||||
public boolean prioritize = false;
|
||||
|
||||
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
this.patternTerminal = (FCFluidEncodeTerminal) monitorable;
|
||||
this.inverted = patternTerminal.isInverted();
|
||||
|
||||
final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern");
|
||||
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
|
||||
IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting");
|
||||
|
||||
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
this.addSlotToContainer(
|
||||
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] =
|
||||
new ProcessingSlotFake(
|
||||
crafting,
|
||||
this,
|
||||
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
|
||||
15,
|
||||
-83,
|
||||
x,
|
||||
y,
|
||||
x + 4));
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
this.addSlotToContainer(
|
||||
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] =
|
||||
new ProcessingSlotFake(
|
||||
output,
|
||||
this,
|
||||
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
|
||||
112,
|
||||
-83,
|
||||
-x,
|
||||
y,
|
||||
x));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IInventory patternInv = this.patternTerminal.getInventoryByName("pattern");
|
||||
this.crafting = this.patternTerminal.getInventoryByName("crafting");
|
||||
this.addSlotToContainer(
|
||||
this.patternSlotIN = new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
|
||||
@@ -105,45 +94,95 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
147,
|
||||
-72 + 34,
|
||||
this.getInventoryPlayer()));
|
||||
|
||||
this.patternSlotOUT.setStackLimit(1);
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
protected final SlotRestrictedInput patternSlotIN;
|
||||
protected final SlotRestrictedInput patternSlotOUT;
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slotId, long id) {
|
||||
if (this.isCraftingMode()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (slotId < 0 || slotId >= this.inventorySlots.size()) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.MOVE_REGION) {
|
||||
super.doAction(player, InventoryAction.SPLIT_OR_PLACE_SINGLE, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (action == InventoryAction.PICKUP_SINGLE) {
|
||||
super.doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, slotId, id);
|
||||
return;
|
||||
}
|
||||
Slot slot = getSlot(slotId);
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
if (validPatternSlot(slot) && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
FluidStack fluid = null;
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
fluid = Util.getFluidFromItem(stack);
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
fluid = Util.getFluidFromItem(Util.copyStackWithSize(stack, 1));
|
||||
FluidStack origin = ItemFluidPacket.getFluidStack(slot.getStack());
|
||||
if (fluid != null && fluid.equals(origin)) {
|
||||
fluid.amount += origin.amount;
|
||||
if (fluid.amount <= 0) fluid = null;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluid));
|
||||
break;
|
||||
}
|
||||
if (fluid == null) {
|
||||
super.doAction(player, action, slotId, id);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.doAction(player, action, slotId, id);
|
||||
}
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 11)
|
||||
public boolean combine = false;
|
||||
protected abstract boolean validPatternSlot(Slot slot);
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 12)
|
||||
public boolean substitute = false;
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
ItemStack is = clickSlot.getStack();
|
||||
if (is != null
|
||||
&& !patternSlotOUT.getHasStack()
|
||||
&& is.stackSize == 1
|
||||
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
|
||||
ItemStack output = is.copy();
|
||||
patternSlotOUT.putStack(output);
|
||||
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
} else {
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
}
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 16)
|
||||
public boolean inverted;
|
||||
public FCFluidEncodeTerminal getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 17)
|
||||
public int activePage = 0;
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 13)
|
||||
public boolean prioritize = false;
|
||||
|
||||
@GuiSync(96 + (17 - 9) + 14)
|
||||
public boolean beSubstitute = false;
|
||||
|
||||
static boolean canDoubleStacks(SlotFake[] slots) {
|
||||
protected static boolean canDoubleStacks(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long emptyStots =
|
||||
long emptySlots =
|
||||
enabledSlots.stream().filter(s -> s.getStack() == null).count();
|
||||
long fullSlots = enabledSlots.stream()
|
||||
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
|
||||
.count();
|
||||
return fullSlots <= emptyStots;
|
||||
return fullSlots <= emptySlots;
|
||||
}
|
||||
|
||||
static void doubleStacksInternal(SlotFake[] slots) {
|
||||
protected static void doubleStacksInternal(SlotFake[] slots) {
|
||||
List<ItemStack> overFlowStacks = new ArrayList<>();
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
@@ -173,7 +212,7 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
assert !ow.hasNext();
|
||||
}
|
||||
|
||||
static boolean containsItem(SlotFake[] slots) {
|
||||
protected static boolean containsItem(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long item = enabledSlots.stream()
|
||||
@@ -182,7 +221,7 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
return item > 0;
|
||||
}
|
||||
|
||||
static boolean containsFluid(SlotFake[] slots) {
|
||||
protected static boolean containsFluid(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long fluid = enabledSlots.stream()
|
||||
@@ -191,18 +230,67 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
return fluid > 0;
|
||||
}
|
||||
|
||||
protected static boolean nonNullSlot(SlotFake[] slots) {
|
||||
List<SlotFake> enabledSlots =
|
||||
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
long object = enabledSlots.stream().filter(s -> s.getStack() != null).count();
|
||||
return object > 0;
|
||||
}
|
||||
|
||||
protected boolean checkHasFluidPattern() {
|
||||
if (this.craftingMode) {
|
||||
return false;
|
||||
}
|
||||
boolean hasFluid = containsFluid(this.craftingSlots);
|
||||
boolean search = nonNullSlot(this.craftingSlots);
|
||||
if (!search) { // search=false -> inputs were empty
|
||||
return false;
|
||||
}
|
||||
hasFluid |= containsFluid(this.outputSlots);
|
||||
search = nonNullSlot(this.outputSlots);
|
||||
return hasFluid && search; // search=false -> outputs were empty
|
||||
}
|
||||
|
||||
protected void encodeFluidPattern() {
|
||||
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
|
||||
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
|
||||
pattern.setInputs(collectInventory(this.craftingSlots));
|
||||
pattern.setOutputs(collectInventory(this.outputSlots));
|
||||
pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
|
||||
patternSlotOUT.putStack(pattern.writeToStack());
|
||||
}
|
||||
|
||||
protected static IAEItemStack[] collectInventory(Slot[] slots) {
|
||||
IAEItemStack[] stacks = new IAEItemStack[slots.length];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
ItemStack stack = slots[i].getStack();
|
||||
if (stack != null) {
|
||||
if (stack.getItem() instanceof ItemFluidPacket) {
|
||||
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
|
||||
if (dropStack != null) {
|
||||
stacks[i] = dropStack;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
IAEItemStack aeStack = AEItemStack.create(stack);
|
||||
stacks[i] = aeStack;
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {}
|
||||
public void saveChanges() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.craftingSlots) {
|
||||
s.putStack(null);
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(null);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@@ -212,7 +300,9 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
final int slot,
|
||||
final InvOperation mc,
|
||||
final ItemStack removedStack,
|
||||
final ItemStack newStack) {}
|
||||
final ItemStack newStack) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void encodeAndMoveToInventory() {
|
||||
encode();
|
||||
@@ -225,9 +315,43 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
public void encodeAllItemAndMoveToInventory() {
|
||||
encode();
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
if (output != null) {
|
||||
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
|
||||
if (!getPlayerInv().addItemStackToInventory(output)) {
|
||||
getPlayerInv().player.entityDropItem(output, 0);
|
||||
}
|
||||
this.patternSlotOUT.putStack(null);
|
||||
this.patternSlotIN.putStack(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
if (!checkHasFluidPattern()) {
|
||||
encodeItemPattern();
|
||||
return;
|
||||
}
|
||||
ItemStack stack = this.patternSlotOUT.getStack();
|
||||
if (stack == null) {
|
||||
stack = this.patternSlotIN.getStack();
|
||||
if (notPattern(stack)) {
|
||||
return;
|
||||
}
|
||||
if (stack.stackSize == 1) {
|
||||
this.patternSlotIN.putStack(null);
|
||||
} else {
|
||||
stack.stackSize--;
|
||||
}
|
||||
encodeFluidPattern();
|
||||
} else if (!notPattern(stack)) {
|
||||
encodeFluidPattern();
|
||||
}
|
||||
}
|
||||
|
||||
public void encodeItemPattern() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
|
||||
@@ -235,14 +359,13 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
if (in == null || out == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (output != null && !this.isPattern(output)) {
|
||||
if (output != null && this.notPattern(output)) {
|
||||
return;
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output == null) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (!this.isPattern(output)) {
|
||||
if (this.notPattern(output)) {
|
||||
return; // no blanks.
|
||||
}
|
||||
|
||||
@@ -290,137 +413,78 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("substitute", this.isSubstitute());
|
||||
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
|
||||
encodedValue.setTag("in", tagIn);
|
||||
encodedValue.setTag("out", tagOut);
|
||||
encodedValue.setBoolean("prioritize", this.isPrioritize());
|
||||
|
||||
encodedValue.setBoolean("crafting", this.craftingMode);
|
||||
encodedValue.setBoolean("substitute", this.substitute);
|
||||
encodedValue.setBoolean("beSubstitute", this.beSubstitute);
|
||||
encodedValue.setBoolean("prioritize", this.prioritize);
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
private ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (input[x] != null) {
|
||||
hasValue = true;
|
||||
}
|
||||
protected ItemStack[] getInputs() {
|
||||
final ArrayList<ItemStack> input = new ArrayList<>();
|
||||
for (SlotFake craftingSlot : this.craftingSlots) {
|
||||
input.add(craftingSlot.getStack());
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return input;
|
||||
if (input.stream().anyMatch(Objects::nonNull)) {
|
||||
return input.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] getOutputs() {
|
||||
final List<ItemStack> list = new ArrayList<>(CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
|
||||
if (out != null && out.stackSize > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
protected ItemStack[] getOutputs() {
|
||||
final ArrayList<ItemStack> output = new ArrayList<>();
|
||||
for (final SlotFake outputSlot : this.outputSlots) {
|
||||
output.add(outputSlot.getStack());
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[0]);
|
||||
if (output.stream().anyMatch(Objects::nonNull)) {
|
||||
return output.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPattern(final ItemStack output) {
|
||||
protected boolean notPattern(final ItemStack output) {
|
||||
if (output == null) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (output.getItem() instanceof ItemFluidEncodedPattern) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern;
|
||||
return !isPattern;
|
||||
}
|
||||
|
||||
private NBTBase createItemTag(final ItemStack i) {
|
||||
protected NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (i != null) {
|
||||
i.writeToNBT(c);
|
||||
c.setInteger("Count", i.stackSize);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx < 4) // outputs
|
||||
{
|
||||
return inverted || idx == 0;
|
||||
} else {
|
||||
return !inverted || idx == 4;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
this.substitute = this.patternTerminal.isSubstitution();
|
||||
this.combine = this.patternTerminal.shouldCombine(); // Check out
|
||||
this.combine = this.patternTerminal.shouldCombine();
|
||||
this.beSubstitute = this.patternTerminal.canBeSubstitute();
|
||||
this.prioritize = this.patternTerminal.isPrioritize();
|
||||
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
|
||||
inverted = patternTerminal.isInverted();
|
||||
activePage = patternTerminal.getActivePage();
|
||||
offsetSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void offsetSlots() {
|
||||
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
|
||||
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
|
||||
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
|
||||
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(
|
||||
page != activePage || x > 0 && inverted);
|
||||
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(
|
||||
page != activePage || x > 0 && !inverted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(String field, Object oldValue, Object newValue) {
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
|
||||
if (field.equals("inverted") || field.equals("activePage")) {
|
||||
offsetSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (s == this.patternSlotOUT && Platform.isServer()) {
|
||||
inverted = patternTerminal.isInverted();
|
||||
|
||||
for (final Object crafter : this.crafters) {
|
||||
final ICrafting icrafting = (ICrafting) crafter;
|
||||
|
||||
for (final Object g : this.inventorySlots) {
|
||||
if (g instanceof OptionalSlotFake) {
|
||||
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
|
||||
final Slot sri = (Slot) g;
|
||||
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
|
||||
}
|
||||
@@ -436,7 +500,7 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
if (name.equals("player")) {
|
||||
return this.getInventoryPlayer();
|
||||
}
|
||||
return this.getPatternTerminal().getInventoryByName(name);
|
||||
return this.patternTerminal.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -444,48 +508,6 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
public PartFluidPatternTerminalEx getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
private boolean isSubstitute() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
private boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
private boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
private static class ProcessingSlotFake extends OptionalSlotFake {
|
||||
|
||||
private static final int POSITION_SHIFT = 9000;
|
||||
private boolean hidden = false;
|
||||
|
||||
public ProcessingSlotFake(
|
||||
IInventory inv,
|
||||
IOptionalSlotHost containerBus,
|
||||
int idx,
|
||||
int x,
|
||||
int y,
|
||||
int offX,
|
||||
int offY,
|
||||
int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
this.setRenderDisabled(false);
|
||||
}
|
||||
|
||||
public void setHidden(boolean hide) {
|
||||
if (this.hidden != hide) {
|
||||
this.hidden = hide;
|
||||
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void doubleStacks(boolean isShift) {
|
||||
if (canDoubleStacks(craftingSlots) && canDoubleStacks(outputSlots)) {
|
||||
doubleStacksInternal(this.craftingSlots);
|
||||
@@ -500,11 +522,14 @@ public class FCBasePartContainerEx extends ContainerItemMonitor
|
||||
}
|
||||
}
|
||||
|
||||
public void setActivePage(final int activePage) {
|
||||
this.activePage = activePage;
|
||||
@Override
|
||||
public void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs) {
|
||||
if (this.patternTerminal != null) {
|
||||
this.patternTerminal.onChangeCrafting(inputs, outputs);
|
||||
}
|
||||
}
|
||||
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
public boolean isCraftingMode() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
package com.glodblock.github.client.gui.container.base;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
@@ -23,9 +23,9 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
|
||||
public abstract class FCContainerFluidConfigurable extends ContainerUpgradeable {
|
||||
|
||||
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
|
||||
public FCContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te) {
|
||||
super(ip, te);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
|
||||
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
protected final IConfigManager clientCM;
|
||||
protected final ITerminalHost host;
|
||||
|
||||
@GuiSync(99)
|
||||
public boolean canAccessViewCells = false;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -36,7 +37,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingRequester {
|
||||
public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingRequester {
|
||||
|
||||
private final BaseActionSource source;
|
||||
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
|
||||
|
||||
@@ -15,6 +15,7 @@ import appeng.me.GridAccessException;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -25,7 +26,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidImportBus extends PartSharedFluidBus {
|
||||
public class PartFluidImportBus extends FCSharedFluidBus {
|
||||
|
||||
private final BaseActionSource source;
|
||||
|
||||
|
||||
@@ -1,122 +1,37 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.BiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class PartFluidPatternTerminal extends FCBasePart {
|
||||
public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
|
||||
|
||||
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 9);
|
||||
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 3);
|
||||
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
private boolean craftingMode = true;
|
||||
private boolean substitute = false;
|
||||
private boolean combine = false;
|
||||
private boolean beSubstitute = false;
|
||||
|
||||
public PartFluidPatternTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 9);
|
||||
this.output = new BiggerAppEngInventory(this, 3);
|
||||
this.prioritize = false;
|
||||
this.inverted = false;
|
||||
this.activePage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
TileEntity te = this.getTile();
|
||||
BlockPos tePos = new BlockPos(te);
|
||||
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
|
||||
return super.onPartActivate(player, pos);
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
te.getWorldObj(),
|
||||
tePos,
|
||||
Objects.requireNonNull(Util.from(getSide())),
|
||||
GuiType.FLUID_PATTERN_TERMINAL);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().xCoord;
|
||||
y = this.getTile().yCoord;
|
||||
z = this.getTile().zCoord;
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,7 +56,7 @@ public class PartFluidPatternTerminal extends FCBasePart {
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
|
||||
this.crafting.setInventorySlotContents(i, null);
|
||||
@@ -189,69 +104,39 @@ public class PartFluidPatternTerminal extends FCBasePart {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
super.setCraftingRecipe(craftingMode);
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
public boolean isPrioritize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
@Override
|
||||
public boolean isInverted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
@Override
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = false;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
@Override
|
||||
public int getActivePage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,132 +1,35 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.BiggerAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.BiggerAppEngInventory;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.common.parts.base.FCFluidEncodeTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
public class PartFluidPatternTerminalEx extends FCFluidEncodeTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
|
||||
|
||||
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 32);
|
||||
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 32);
|
||||
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
private boolean substitute = false;
|
||||
private boolean combine = false;
|
||||
private boolean prioritize = false;
|
||||
private boolean inverted = false;
|
||||
private boolean beSubstitute = false;
|
||||
private int activePage = 0;
|
||||
|
||||
public PartFluidPatternTerminalEx(ItemStack is) {
|
||||
super(is, true);
|
||||
super(is);
|
||||
this.crafting = new BiggerAppEngInventory(this, 32);
|
||||
this.output = new BiggerAppEngInventory(this, 32);
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
TileEntity te = this.getTile();
|
||||
BlockPos tePos = new BlockPos(te);
|
||||
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
|
||||
return super.onPartActivate(player, pos);
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
te.getWorldObj(),
|
||||
tePos,
|
||||
Objects.requireNonNull(Util.from(getSide())),
|
||||
GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "craftingGrid");
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("combine", this.combine);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "craftingGrid");
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().xCoord;
|
||||
y = this.getTile().yCoord;
|
||||
z = this.getTile().zCoord;
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,15 +52,13 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
final IAEItemStack[] outItems = details.getOutputs();
|
||||
int inputsCount = 0;
|
||||
int outputCount = 0;
|
||||
|
||||
for (int i = 0; i < inItems.length; i++) {
|
||||
if (inItems[i] != null) {
|
||||
for (IAEItemStack inItem : inItems) {
|
||||
if (inItem != null) {
|
||||
inputsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < outItems.length; i++) {
|
||||
if (outItems[i] != null) {
|
||||
for (IAEItemStack outItem : outItems) {
|
||||
if (outItem != null) {
|
||||
outputCount++;
|
||||
}
|
||||
}
|
||||
@@ -166,7 +67,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
if (newStack != null) {
|
||||
NBTTagCompound data = newStack.getTagCompound();
|
||||
this.setCombineMode(data.getInteger("combine") == 1);
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setBeSubstitute(details.canBeSubstitute());
|
||||
}
|
||||
this.setInverted(inputsCount <= 8 && outputCount > 8);
|
||||
this.setActivePage(0);
|
||||
@@ -219,68 +120,14 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
public boolean isCraftingRecipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,20 +149,4 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
|
||||
public boolean isLightSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return inverted;
|
||||
}
|
||||
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,11 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class PartFluidTerminal extends FCBasePart {
|
||||
public class PartFluidTerminal extends FCPart {
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Dark;
|
||||
@@ -51,42 +40,7 @@ public class PartFluidTerminal extends FCBasePart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
TileEntity te = this.getTile();
|
||||
BlockPos tePos = new BlockPos(te);
|
||||
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
|
||||
return super.onPartActivate(player, pos);
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
te.getWorldObj(),
|
||||
tePos,
|
||||
Objects.requireNonNull(Util.from(getSide())),
|
||||
GuiType.FLUID_TERMINAL);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().xCoord;
|
||||
y = this.getTile().yCoord;
|
||||
z = this.getTile().zCoord;
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_WIRELESS_TERM.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
public GuiType getGui() {
|
||||
return GuiType.FLUID_TERMINAL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import java.util.List;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public abstract class FCFluidEncodeTerminal extends FCPart {
|
||||
|
||||
protected AppEngInternalInventory crafting;
|
||||
protected AppEngInternalInventory output;
|
||||
protected final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
|
||||
|
||||
protected boolean craftingMode = true;
|
||||
protected boolean substitute = false;
|
||||
protected boolean combine = false;
|
||||
protected boolean prioritize = false;
|
||||
protected boolean inverted = false;
|
||||
protected boolean beSubstitute = false;
|
||||
protected int activePage = 0;
|
||||
|
||||
public FCFluidEncodeTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
|
||||
super.getDrops(drops, wrenched);
|
||||
for (final ItemStack is : this.pattern) {
|
||||
if (is != null) {
|
||||
drops.add(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.setCraftingRecipe(data.getBoolean("craftingMode"));
|
||||
this.setSubstitution(data.getBoolean("substitute"));
|
||||
this.setCombineMode(data.getBoolean("combine"));
|
||||
this.setBeSubstitute(data.getBoolean("beSubstitute"));
|
||||
this.setPrioritization(data.getBoolean("priorization"));
|
||||
this.setInverted(data.getBoolean("inverted"));
|
||||
this.setActivePage(data.getInteger("activePage"));
|
||||
this.pattern.readFromNBT(data, "pattern");
|
||||
this.output.readFromNBT(data, "outputList");
|
||||
this.crafting.readFromNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
data.setBoolean("craftingMode", this.craftingMode);
|
||||
data.setBoolean("combine", this.combine);
|
||||
data.setBoolean("beSubstitute", this.beSubstitute);
|
||||
data.setBoolean("priorization", this.prioritize);
|
||||
data.setBoolean("substitute", this.substitute);
|
||||
data.setBoolean("inverted", this.inverted);
|
||||
data.setInteger("activePage", this.activePage);
|
||||
this.pattern.writeToNBT(data, "pattern");
|
||||
this.output.writeToNBT(data, "outputList");
|
||||
this.crafting.writeToNBT(data, "craftingGrid");
|
||||
}
|
||||
|
||||
public boolean shouldCombine() {
|
||||
return this.combine;
|
||||
}
|
||||
|
||||
public void setCombineMode(boolean shouldCombine) {
|
||||
this.combine = shouldCombine;
|
||||
}
|
||||
|
||||
public boolean isSubstitution() {
|
||||
return this.substitute;
|
||||
}
|
||||
|
||||
public boolean isPrioritize() {
|
||||
return this.prioritize;
|
||||
}
|
||||
|
||||
public void setBeSubstitute(boolean canBeSubstitute) {
|
||||
this.beSubstitute = canBeSubstitute;
|
||||
}
|
||||
|
||||
public boolean canBeSubstitute() {
|
||||
return this.beSubstitute;
|
||||
}
|
||||
|
||||
public void setSubstitution(boolean canSubstitute) {
|
||||
this.substitute = canSubstitute;
|
||||
}
|
||||
|
||||
public void setPrioritization(boolean canPrioritize) {
|
||||
this.prioritize = canPrioritize;
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return inverted;
|
||||
}
|
||||
|
||||
public void setInverted(boolean inverted) {
|
||||
this.inverted = inverted;
|
||||
}
|
||||
|
||||
public int getActivePage() {
|
||||
return this.activePage;
|
||||
}
|
||||
|
||||
public void setActivePage(int activePage) {
|
||||
this.activePage = activePage;
|
||||
}
|
||||
|
||||
public void setCraftingRecipe(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
}
|
||||
|
||||
public boolean isCraftingRecipe() {
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
public void onChangeCrafting(IAEItemStack[] newCrafting, IAEItemStack[] newOutput) {
|
||||
IInventory crafting = this.getInventoryByName("crafting");
|
||||
IInventory output = this.getInventoryByName("output");
|
||||
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
|
||||
final IAEItemStack item = newCrafting[x];
|
||||
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
|
||||
final IAEItemStack item = newOutput[x];
|
||||
output.setInventorySlotContents(x, item == null ? null : item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("crafting")) {
|
||||
return this.crafting;
|
||||
}
|
||||
|
||||
if (name.equals("output")) {
|
||||
return this.output;
|
||||
}
|
||||
|
||||
if (name.equals("pattern")) {
|
||||
return this.pattern;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
}
|
||||
+35
-32
@@ -1,12 +1,10 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
@@ -18,7 +16,6 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -28,11 +25,16 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -40,12 +42,13 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class FCBasePart extends AEBasePart
|
||||
public abstract class FCPart extends AEBasePart
|
||||
implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory {
|
||||
|
||||
protected static final int POWERED_FLAG = 4;
|
||||
@@ -59,11 +62,11 @@ public abstract class FCBasePart extends AEBasePart
|
||||
private final IConfigManager cm = new ConfigManager(this);
|
||||
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
|
||||
|
||||
public FCBasePart(final ItemStack is) {
|
||||
public FCPart(final ItemStack is) {
|
||||
this(is, false);
|
||||
}
|
||||
|
||||
protected FCBasePart(final ItemStack is, final boolean requireChannel) {
|
||||
protected FCPart(final ItemStack is, final boolean requireChannel) {
|
||||
super(is);
|
||||
|
||||
if (requireChannel) {
|
||||
@@ -137,9 +140,7 @@ public abstract class FCBasePart extends AEBasePart
|
||||
this.viewCell.writeToNBT(data, "viewCell");
|
||||
}
|
||||
|
||||
public GuiBridge getGui(final EntityPlayer player) {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
public abstract GuiType getGui();
|
||||
|
||||
@Override
|
||||
public void writeToStream(final ByteBuf data) throws IOException {
|
||||
@@ -148,15 +149,15 @@ public abstract class FCBasePart extends AEBasePart
|
||||
|
||||
try {
|
||||
if (this.getProxy().getEnergy().isNetworkPowered()) {
|
||||
this.clientFlags = this.getClientFlags() | FCBasePart.POWERED_FLAG;
|
||||
this.clientFlags = this.getClientFlags() | FCPart.POWERED_FLAG;
|
||||
}
|
||||
|
||||
if (this.getProxy().getPath().isNetworkBooting()) {
|
||||
this.clientFlags = this.getClientFlags() | FCBasePart.BOOTING_FLAG;
|
||||
this.clientFlags = this.getClientFlags() | FCPart.BOOTING_FLAG;
|
||||
}
|
||||
|
||||
if (this.getProxy().getNode().meetsChannelRequirements()) {
|
||||
this.clientFlags = this.getClientFlags() | FCBasePart.CHANNEL_FLAG;
|
||||
this.clientFlags = this.getClientFlags() | FCPart.CHANNEL_FLAG;
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// um.. nothing.
|
||||
@@ -215,18 +216,21 @@ public abstract class FCBasePart extends AEBasePart
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (!onPartActivate0(player, pos)) {
|
||||
if (!player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui(player));
|
||||
|
||||
return true;
|
||||
TileEntity te = this.getTile();
|
||||
BlockPos tePos = new BlockPos(te);
|
||||
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
|
||||
return super.onPartActivate(player, pos);
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), getGui());
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -251,7 +255,6 @@ public abstract class FCBasePart extends AEBasePart
|
||||
te.yCoord + this.getSide().offsetY,
|
||||
te.zCoord + this.getSide().offsetZ);
|
||||
}
|
||||
|
||||
return (int) (emit * (this.opacity / 255.0f));
|
||||
}
|
||||
|
||||
@@ -261,7 +264,7 @@ public abstract class FCBasePart extends AEBasePart
|
||||
if (Platform.isServer()) {
|
||||
return this.getProxy().getEnergy().isNetworkPowered();
|
||||
} else {
|
||||
return ((this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG);
|
||||
return ((this.getClientFlags() & FCPart.POWERED_FLAG) == FCPart.POWERED_FLAG);
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
return false;
|
||||
@@ -309,8 +312,8 @@ public abstract class FCBasePart extends AEBasePart
|
||||
@Override
|
||||
public final boolean isActive() {
|
||||
if (!this.isLightSource()) {
|
||||
return ((this.getClientFlags() & (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG))
|
||||
== (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG));
|
||||
return ((this.getClientFlags() & (FCPart.CHANNEL_FLAG | FCPart.POWERED_FLAG))
|
||||
== (FCPart.CHANNEL_FLAG | FCPart.POWERED_FLAG));
|
||||
} else {
|
||||
return this.isPowered();
|
||||
}
|
||||
@@ -407,9 +410,9 @@ public abstract class FCBasePart extends AEBasePart
|
||||
rh.setBounds(4, 4, 13, 12, 12, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
final boolean hasChan = (this.getClientFlags() & (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG))
|
||||
== (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG);
|
||||
final boolean hasPower = (this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG;
|
||||
final boolean hasChan = (this.getClientFlags() & (FCPart.POWERED_FLAG | FCPart.CHANNEL_FLAG))
|
||||
== (FCPart.POWERED_FLAG | FCPart.CHANNEL_FLAG);
|
||||
final boolean hasPower = (this.getClientFlags() & FCPart.POWERED_FLAG) == FCPart.POWERED_FLAG;
|
||||
|
||||
if (hasChan) {
|
||||
final int l = 14;
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -26,12 +26,12 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable {
|
||||
public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridTickable {
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9);
|
||||
private boolean lastRedstone;
|
||||
|
||||
public PartSharedFluidBus(ItemStack is) {
|
||||
public FCSharedFluidBus(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.glodblock.github.crossmod.waila.part;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.integration.modules.waila.part.BasePartWailaDataProvider;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.crossmod.waila.Tooltip;
|
||||
import java.util.List;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
@@ -20,9 +20,9 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider {
|
||||
final List<String> currentToolTip,
|
||||
final IWailaDataAccessor accessor,
|
||||
final IWailaConfigHandler config) {
|
||||
if (part instanceof PartSharedFluidBus) {
|
||||
if (part instanceof FCSharedFluidBus) {
|
||||
part.readFromNBT(accessor.getNBTData());
|
||||
currentToolTip.add(Tooltip.partFluidBusFormat(((PartSharedFluidBus) part).calculateAmountToSend() / 5));
|
||||
currentToolTip.add(Tooltip.partFluidBusFormat(((FCSharedFluidBus) part).calculateAmountToSend() / 5));
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class SpeedWailaDataProvider extends BasePartWailaDataProvider {
|
||||
final int x,
|
||||
final int y,
|
||||
final int z) {
|
||||
if (part instanceof PartSharedFluidBus) {
|
||||
if (part instanceof FCSharedFluidBus) {
|
||||
part.writeToNBT(tag);
|
||||
}
|
||||
return tag;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Since there is no ae2 available now for compiling, we copied it over, and it will need to be removed in the future.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BiggerAppEngInventory extends AppEngInternalInventory {
|
||||
|
||||
private final ItemStack[] inv;
|
||||
|
||||
public BiggerAppEngInventory(IAEAppEngInventory inventory, int size) {
|
||||
super(inventory, size);
|
||||
inv = ObfuscationReflectionHelper.getPrivateValue(AppEngInternalInventory.class, this, "inv");
|
||||
}
|
||||
|
||||
protected void writeToNBT(final NBTTagCompound target) {
|
||||
for (int x = 0; x < this.getSizeInventory(); x++) {
|
||||
try {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if (this.inv[x] != null) {
|
||||
this.inv[x].writeToNBT(c);
|
||||
c.setInteger("Count", this.inv[x].stackSize);
|
||||
}
|
||||
|
||||
target.setTag("#" + x, c);
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(final NBTTagCompound target) {
|
||||
for (int x = 0; x < this.getSizeInventory(); x++) {
|
||||
try {
|
||||
final NBTTagCompound c = target.getCompoundTag("#" + x);
|
||||
|
||||
if (c != null) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(c);
|
||||
if (stack != null) {
|
||||
stack.stackSize = c.getInteger("Count");
|
||||
}
|
||||
this.inv[x] = stack;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public interface PatternConsumer {
|
||||
public interface IPatternConsumer {
|
||||
|
||||
void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs);
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.*;
|
||||
import com.glodblock.github.common.parts.FCBasePart;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
@@ -126,14 +126,14 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_BUS_IO(new PartGuiFactory<PartSharedFluidBus>(PartSharedFluidBus.class) {
|
||||
FLUID_BUS_IO(new PartGuiFactory<FCSharedFluidBus>(FCSharedFluidBus.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartSharedFluidBus inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCSharedFluidBus inv) {
|
||||
return new ContainerFluidIO(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, PartSharedFluidBus inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCSharedFluidBus inv) {
|
||||
return new GuiFluidIO(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
@@ -174,14 +174,14 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
FLUID_PAT_TERM_CRAFTING_STATUS(new PartGuiFactory<FCPart>(FCPart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCPart inv) {
|
||||
return new ContainerCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCPart inv) {
|
||||
return new GuiFluidPatternTerminalCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
@@ -234,26 +234,26 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
FLUID_CRAFTING_CONFIRM(new PartGuiFactory<FCPart>(FCPart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCPart inv) {
|
||||
return new ContainerFluidCraftConfirm(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCPart inv) {
|
||||
return new GuiFluidCraftConfirm(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_CRAFTING_AMOUNT(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
FLUID_CRAFTING_AMOUNT(new PartGuiFactory<FCPart>(FCPart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCPart inv) {
|
||||
return new ContainerCraftAmount(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCPart inv) {
|
||||
return new GuiFluidCraftAmount(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
@@ -270,14 +270,14 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
PATTERN_VALUE_SET(new PartGuiFactory<FCBasePart>(FCBasePart.class) {
|
||||
PATTERN_VALUE_SET(new PartGuiFactory<FCPart>(FCPart.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createServerGui(EntityPlayer player, FCPart inv) {
|
||||
return new ContainerPatternValueAmount(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, FCBasePart inv) {
|
||||
protected Object createClientGui(EntityPlayer player, FCPart inv) {
|
||||
return new GuiPatternValueAmount(player.inventory, inv);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user