Compare commits

..
Author SHA1 Message Date
Yang Xizhi 9615e1cbf0 Merge pull request #86 from GTNewHorizons/blockingfix
Blockingfix
2023-02-23 20:40:23 +08:00
Martin Robertz 98c633e13d Merge pull request #94 from GTNewHorizons/master
merge from master
2023-02-22 12:12:18 +01:00
Yang Xizhi 704dbf6eec Merge pull request #92 from asdflj/master
fix bug
2023-02-22 18:35:31 +08:00
GlodBlock bf7190ce21 sa 2023-02-22 15:46:22 +08:00
GlodBlock 883ae61395 fix eio item conduit doesn't work 2023-02-22 15:44:28 +08:00
asdflj a203f2ff6b fix bug 2023-02-22 15:21:05 +08:00
GlodBlock fee5c6ee76 check gt pipe connection and fix eio fluid conduit 2023-02-21 18:22:53 +08:00
GlodBlock fb003da0a3 fix inventory check of gt machine 2023-02-21 15:36:10 +08:00
Martin Robertz 0e774f4e66 Merge pull request #91 from GTNewHorizons/master
merge master
2023-02-20 23:04:14 +01:00
Martin Robertz 25763691ca Merge pull request #90 from asdflj/master
fix fluid storage bus npe
2023-02-20 12:18:22 +01:00
asdflj bc053b2690 fix fluid storage bus crash 2023-02-20 18:19:47 +08:00
Martin Robertz 9761008907 Merge pull request #89 from GTNewHorizons/master
merge master
2023-02-18 23:25:05 +01:00
Martin Robertz 1a7acf4d28 Merge pull request #88 from asdflj/master
pattern terminal add auto fill blank pattern
2023-02-18 19:09:26 +01:00
asdflj c21752b80d fix bug 2023-02-18 14:18:22 +08:00
asdflj 80c364455d add Avaritia crafting table support 2023-02-18 14:16:40 +08:00
asdflj aef677868b add hotkey and baubles support 2023-02-17 22:34:06 +08:00
asdflj 09c1c49529 pattern terminal add auto fill blank pattern 2023-02-17 12:04:11 +08:00
Martin Robertz 18fb84de69 Merge branch 'master' into blockingfix 2023-02-16 20:41:21 +01:00
Yang Xizhi 271917c765 Merge pull request #85 from asdflj/nee
add nee support
2023-02-16 20:14:06 +08:00
GlodBlock e9c6c75ac9 ignore eio conduit in blocking check 2023-02-16 12:28:43 +08:00
asdflj 7d09bf606f add nee support 2023-02-16 11:29:34 +08:00
Martin Robertz 098561a01d Merge pull request #87 from GTNewHorizons/master
merge master
2023-02-15 17:36:17 +01:00
Yang Xizhi e292a4d35c Merge pull request #84 from asdflj/master
remove keep mouse pos
2023-02-15 18:02:13 +08:00
GlodBlock 52a985765c remove dep 2023-02-15 17:58:18 +08:00
GlodBlock 4f8811d376 make eio conduit consistant with ae2 2023-02-15 17:56:51 +08:00
asdflj bfcf33975c remove keep mouse pos 2023-02-15 09:30:13 +08:00
Yang Xizhi f3052c3353 Merge pull request #83 from asdflj/master
fix bug
2023-02-14 22:28:34 +08:00
GlodBlock b4a5c070e2 check every side in blocking mode 2023-02-14 22:20:47 +08:00
asdflj c8457bb7d3 fix bug 2023-02-14 22:12:40 +08:00
42 changed files with 977 additions and 192 deletions

No files matched your search

+3 -3
View File
@@ -1,8 +1,8 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.21-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-156-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.32-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-160-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.32:dev') { transitive = false }
@@ -23,5 +23,5 @@ dependencies {
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
runtimeOnly('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
compile('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
@@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
modid = FluidCraft.MODID,
version = FluidCraft.VERSION,
name = FluidCraft.MODNAME,
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;after:waila;after:thaumicenergistics;after:ae2wct")
dependencies = "required-after:appliedenergistics2;required-after:CoFHCore;required-after:Baubles;after:waila;after:thaumicenergistics;after:ae2wct")
public class FluidCraft {
public static final String MODID = "GRADLETOKEN_MODID";
@@ -57,6 +57,8 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
}
}
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
@@ -9,4 +12,13 @@ public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -20,6 +20,8 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -29,6 +31,10 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
}
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -11,7 +11,9 @@ import appeng.client.gui.widgets.GuiImgButton;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
@@ -24,6 +26,12 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@SuppressWarnings("unchecked")
public void initGui() {
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.SlotDisabled;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
@@ -9,4 +12,13 @@ public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
super(inventoryPlayer, te);
}
@Override
protected void repositionSlot(final AppEngSlot s) {
if (s instanceof SlotDisabled || s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -302,6 +302,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
buttonList.add(terminalStyleBox);
buttonList.add(searchStringSave);
buttonList.add(craftingStatusBtn);
this.guiButtonHashMap.clear();
addSwitchGuiBtns();
int offset = 51;
@@ -10,10 +10,11 @@ import net.minecraft.inventory.Container;
import appeng.client.gui.AEBaseMEGui;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
public abstract class FCBaseMEGui extends AEBaseMEGui {
@@ -28,21 +29,23 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
super(container);
if (inventoryPlayer.getCurrentItem() != null
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
this.drawSwitchGuiBtn = true;
if (container instanceof FCBaseContainer) {
Object target = ((FCBaseContainer) container).getTarget();
if (target instanceof IWirelessTerminal
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
this.drawSwitchGuiBtn = true;
}
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Util.MouseHandler.saveMousePos();
}
protected void initGuiDone() {
if (drawSwitchGuiBtn) {
drawSwitchGuiBtns();
Util.MouseHandler.loadMousePos();
}
}
@@ -138,14 +141,4 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
}
super.actionPerformed(btn);
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
}
}
@@ -51,6 +51,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
protected GuiImgButton beSubstitutionsDisabledBtn;
protected GuiFCImgButton combineEnableBtn;
protected GuiFCImgButton combineDisableBtn;
protected GuiFCImgButton autoFillPatternEnableBtn;
protected GuiFCImgButton autoFillPatternDisableBtn;
protected final GuiScrollbar processingScrollBar = new GuiScrollbar();
protected final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
@@ -62,6 +64,24 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
setReservedSpace(81);
}
@Override
public void initGui() {
super.initGui();
this.buttonList.add(
this.autoFillPatternEnableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FILL_PATTERN",
"DO_FILL"));
this.buttonList.add(
this.autoFillPatternDisableBtn = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"NOT_FILL_PATTERN",
"DONT_FILL"));
this.offsetY += 20;
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -108,6 +128,11 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler
.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
} else if (this.autoFillPatternDisableBtn == btn || this.autoFillPatternEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns(
"PatternTerminal.AutoFillerPattern",
this.autoFillPatternDisableBtn == btn ? "1" : "0"));
}
}
@@ -124,6 +149,8 @@ public abstract class FCGuiEncodeTerminal extends GuiItemMonitor {
updateButton(this.beSubstitutionsDisabledBtn, !this.container.beSubstitute);
updateButton(this.fluidPrioritizedEnabledBtn, this.container.prioritize);
updateButton(this.fluidPrioritizedDisabledBtn, !this.container.prioritize);
updateButton(this.autoFillPatternEnableBtn, this.container.autoFillPattern);
updateButton(this.autoFillPatternDisableBtn, !this.container.autoFillPattern);
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@@ -33,10 +33,8 @@ import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
@@ -50,6 +48,8 @@ import codechicken.nei.util.TextHistory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
@@ -119,7 +119,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
@@ -314,7 +314,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
this.repositionSlot((AppEngSlot) s);
}
}
@@ -11,8 +11,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -37,10 +39,12 @@ import appeng.core.AELog;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
@@ -269,6 +273,12 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if (ah instanceof IWirelessTerminal) {
ItemStack terminal = ((IWirelessTerminal) ah).getItemStack();
if (terminal.getItem() instanceof ItemBaseWirelessTerminal) {
originalGui = ((ItemBaseWirelessTerminal) terminal.getItem()).guiGuiType(terminal);
}
}
if (this.result != null && !this.isSimulation() && getGrid() != null) {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
@@ -279,13 +289,22 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
true,
this.getActionSrc());
this.setAutoStart(false);
if (g != null && originalGui != null && this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
if (g != null && originalGui != null) {
if (ah instanceof IWirelessTerminal) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
ForgeDirection.UNKNOWN,
originalGui);
} else if (this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(this.getOpenContext().getSide()),
originalGui);
}
}
}
}
@@ -29,7 +29,9 @@ public abstract class FCBaseContainer extends AEBaseContainer {
if (isWirelessTerminal()) {
if (this.host != null) {
final int slotIndex = this.host.getInventorySlot();
this.lockPlayerInventorySlot(slotIndex);
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
this.lockPlayerInventorySlot(slotIndex);
}
return slotIndex;
} else {
this.lockPlayerInventorySlot(ip.currentItem);
@@ -18,6 +18,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
@@ -75,6 +76,9 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
@GuiSync(91)
public boolean prioritize = false;
@GuiSync(90)
public boolean autoFillPattern = false;
public FCContainerEncodeTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable);
this.patternTerminal = (IItemPatternTerminal) monitorable;
@@ -302,6 +306,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
}
this.patternSlotOUT.putStack(null);
}
fillPattern();
}
public void encodeAllItemAndMoveToInventory() {
@@ -315,9 +320,38 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
fillPattern();
}
private void fillPattern() {
if (this.autoFillPattern && this.getHost().getItemInventory() != null) {
// try to use me network item to fill pattern input slot
final IDefinitions definitions = AEApi.instance().definitions();
int fillStackSize = this.patternSlotIN.getHasStack() ? 64 - this.patternSlotIN.getStack().stackSize : 64;
if (fillStackSize == 0) return;
for (ItemStack blankPattern : definitions.materials().blankPattern().maybeStack(fillStackSize).asSet()) {
IAEItemStack iBlankPattern = AEApi.instance().storage().createItemStack(blankPattern);
if (this.patternSlotIN.getHasStack() && !iBlankPattern.isSameType(this.patternSlotIN.getStack()))
continue;
IAEItemStack out = this.getHost().getItemInventory()
.extractItems(iBlankPattern, Actionable.MODULATE, this.getActionSource());
if (out != null) {
ItemStack outPattern;
if (this.patternSlotIN.getHasStack()) {
outPattern = this.patternSlotIN.getStack().copy();
outPattern.stackSize += out.getItemStack().stackSize;
} else {
outPattern = out.getItemStack();
}
this.patternSlotIN.putStack(outPattern);
return;
}
}
}
}
public void encode() {
fillPattern();
if (!checkHasFluidPattern()) {
encodeItemPattern();
return;
@@ -454,6 +488,7 @@ public abstract class FCContainerEncodeTerminal extends ContainerItemMonitor
this.combine = this.patternTerminal.shouldCombine();
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
this.autoFillPattern = this.patternTerminal.isAutoFillPattern();
}
}
@@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -13,11 +14,15 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.apache.commons.lang3.tuple.ImmutablePair;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
import appeng.core.features.AEFeature;
import appeng.core.localization.PlayerMessages;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
@@ -36,7 +41,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
implements IRegister<ItemWirelessUltraTerminal> {
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
public final static String MODE = "mode_main";
private final static List<GuiType> guis = new ArrayList<>();
@@ -162,9 +167,10 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
}
public static void switchTerminal(EntityPlayer player, GuiType guiType) {
if (player.inventory.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal) {
((ItemWirelessUltraTerminal) player.inventory.getCurrentItem().getItem())
.setMode(guiType, player.inventory.getCurrentItem());
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
}
if (Platform.isClient()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
@@ -173,7 +179,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
term.getLeft(),
Util.GuiHelper.encodeType(
guis.indexOf(GuiType.valueOf(guiType.toString())),
Util.GuiHelper.GuiType.ITEM),
@@ -191,4 +197,34 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public GuiType guiGuiType(ItemStack stack) {
return readMode(stack);
}
@Override
public BaubleType getBaubleType(ItemStack itemStack) {
return BaubleType.RING;
}
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
}
@Override
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
return true;
}
}
@@ -259,7 +259,9 @@ public class PartFluidStorageBus extends PartUpgradeable
@Override
public void onNeighborChanged() {
BlockPos neighbor = new BlockPos(this.getTile()).getOffSet(this.getSide());
TileEntity tile = this.getTile();
if (tile == null || this.getProxy() == null || !this.getProxy().isActive()) return;
BlockPos neighbor = new BlockPos(tile).getOffSet(this.getSide());
final TileEntity te = neighbor.getTileEntity();
// In case the TE was destroyed, we have to do a full reset immediately.
if (te instanceof TileCableBus) {
@@ -288,6 +290,7 @@ public class PartFluidStorageBus extends PartUpgradeable
} else {
this.resetCache(false);
}
}
@Override
@@ -25,6 +25,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
public FCFluidEncodeTerminal(ItemStack is) {
@@ -51,6 +52,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
@@ -66,6 +68,7 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
@@ -204,4 +207,14 @@ public abstract class FCFluidEncodeTerminal extends FCPart implements IItemPatte
}
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
}
@@ -1,9 +1,8 @@
package com.glodblock.github.inventory;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import javax.annotation.Nullable;
@@ -16,9 +15,14 @@ import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.api.parts.IPart;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.tile.misc.TileInterface;
import appeng.tile.networking.TileCableBus;
import appeng.util.InventoryAdaptor;
import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
@@ -34,24 +38,47 @@ import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import crazypants.enderio.conduit.item.IItemConduit;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
// facing is the target TE direction
// |T|-facing->|I|
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids,
ForgeDirection facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
ForgeDirection facing, BlockPos pos, boolean isOnmi) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = facing;
this.posInterface = pos;
this.eioDuct = eioConduct;
this.onmi = isOnmi;
this.selfInterface = getInterfaceTE(pos.getTileEntity(), facing.getOpposite());
}
private final InventoryAdaptor invItems;
private final IFluidHandler invFluids;
private final ForgeDirection side;
private final BlockPos posInterface;
private final Object eioDuct;
@Nullable
private final IInterfaceHost selfInterface;
private final boolean onmi;
private static Method eioTypeCheck;
private static Class<?> conduitClazz;
static {
if (ModAndClassUtil.EIO) {
try {
conduitClazz = Class.forName("crazypants.enderio.conduit.TileConduitBundle");
eioTypeCheck = conduitClazz.getDeclaredMethod("getConduit", Class.class);
} catch (ClassNotFoundException | NoSuchMethodException e) {
eioTypeCheck = null;
}
} else {
eioTypeCheck = null;
}
}
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
// sometimes i wish 1.7.10 has cap system.
@@ -69,31 +96,69 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
if (inter instanceof TileInterface) {
onmi = ((TileInterface) inter).getTargets().size() > 1;
}
Object conduct = null;
if (ModAndClassUtil.COFH && capProvider instanceof IItemDuct) {
conduct = capProvider;
}
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct);
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi);
}
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeAdded);
if (fluid != null) {
if (invFluids != null) {
if (invFluids.canFill(side, fluid.getFluid())) {
int filled = invFluids.fill(side, fluid, true);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
}
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeAdded;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, true);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack notFilled = fillSideItem(toBeAdded, this.invItems, insertionMode, true);
if (notFilled != null) {
// Fill EIO Conduit at last.
return fillEIOConduit(
notFilled,
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side);
}
return null;
}
} else {
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (fluid.amount <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), true);
fluid.amount -= filled;
}
return ItemFluidPacket.newStack(fluid);
} else {
ItemStack item = toBeAdded.copy();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillSideItem(item, getSideItem(dir), insertionMode, true);
}
// Fill EIO Conduit at last.
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (item == null || item.stackSize <= 0) {
return null;
}
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
item = fillEIOConduit(item, this.posInterface.getOffSet(dir).getTileEntity(), dir.getOpposite());
}
return item;
}
return toBeAdded;
}
if (eioDuct != null) {
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
}
return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded;
}
@Override
@@ -109,35 +174,56 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
FluidStack fluid = Util.getFluidFromVirtual(toBeSimulated);
if (fluid != null) {
if (onmi) {
boolean sus = false;
for (ForgeDirection dir : ForgeDirection.values()) {
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
if (te instanceof IFluidHandler) {
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
if (filled > 0) {
sus = true;
break;
}
if (!this.onmi) {
if (!checkValidSide(
this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity(),
this.side.getOpposite())) {
return toBeSimulated;
}
if (fluid != null) {
int filled = fillSideFluid(fluid, this.invFluids, this.side, false);
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(this.side.getOpposite()).getTileEntity())) {
return null;
} else {
return fillSideItem(toBeSimulated, this.invItems, insertionMode, false);
}
}
} else {
// In onmi mode, fluid/item only need to be partly inserted.
boolean sus = false;
if (fluid != null) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
int filled = fillSideFluid(fluid, getSideFluid(dir), dir.getOpposite(), false);
if (filled > 0) {
sus = true;
break;
}
}
return sus ? null : toBeSimulated;
}
if (invFluids != null) {
int filled = invFluids.fill(side, fluid, false);
if (filled > 0) {
fluid.amount -= filled;
return ItemFluidPacket.newStack(fluid);
} else {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (!checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)) {
continue;
}
// Assert EIO conduit can hold all item, as it is the origin practice in AE2
if (isConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
return null;
}
ItemStack notFilled = fillSideItem(toBeSimulated, getSideItem(dir), insertionMode, false);
if (notFilled == null || notFilled.stackSize < toBeSimulated.stackSize) {
sus = true;
break;
}
}
}
return toBeSimulated;
return sus ? null : toBeSimulated;
}
// Assert EIO conduct can hold all item, as it is the origin practice in AE2
if (eioDuct != null) {
return null;
}
return invItems != null ? invItems.simulateAdd(toBeSimulated, insertionMode) : toBeSimulated;
}
@Override
@@ -164,15 +250,123 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public boolean containsItems() {
if (invFluids == null && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
return true;
if (!this.onmi) {
// If there is no fluid tank or item inventory, it shouldn't send stuff here.
return checkItemFluids(this.invFluids, this.invItems, this.side) > 0;
}
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
boolean anyValid = false;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
// Avoid sending stuff into itself me network
if (checkValidSide(this.posInterface.getOffSet(dir).getTileEntity(), dir)
&& !isItemConduit(this.posInterface.getOffSet(dir).getTileEntity())) {
final int result = checkItemFluids(this.getSideFluid(dir), this.getSideItem(dir), dir.getOpposite());
if (result == 1) {
return true;
}
if (result != 2) {
anyValid = true;
}
}
}
// Same here. if there is no fluid tank or item inventory existed, it shouldn't send stuff here.
return !anyValid;
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
}
private IFluidHandler getSideFluid(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
if (te instanceof IFluidHandler) {
return (IFluidHandler) te;
}
return null;
}
private int fillSideFluid(FluidStack fluid, IFluidHandler tank, ForgeDirection direction, boolean doFill) {
if (tank != null) {
return tank.fill(direction, fluid, doFill);
}
return 0;
}
// EIO conduit isn't considered here
private ItemStack fillSideItem(ItemStack item, InventoryAdaptor inv, InsertionMode mode, boolean doFill) {
if (inv != null) {
if (doFill) {
return inv.addItems(item, mode);
} else {
return inv.simulateAdd(item, mode);
}
}
return item;
}
private int gtMachineCircuitCheck(InventoryAdaptor ad) {
if (ad == null) {
return 0;
}
for (ItemSlot i : ad) {
ItemStack is = i.getItemStack();
if (is == null || Objects.requireNonNull(is.getItem()).getUnlocalizedName().equals("gt.integrated_circuit"))
continue;
return 1;
}
return 0;
}
private boolean isGTMachine(Object o) {
return ModAndClassUtil.GT5 && o instanceof TileEntity
&& ((TileEntity) o).getBlockType().getUnlocalizedName().equals("gt.blockmachines");
}
private boolean isItemConduit(TileEntity te) {
if (ModAndClassUtil.EIO && conduitClazz.isInstance(te)) {
try {
return eioTypeCheck.invoke(te, IItemConduit.class) != null;
} catch (InvocationTargetException | IllegalAccessException e) {
return false;
}
}
return false;
}
private boolean isConduit(TileEntity te) {
return ModAndClassUtil.EIO && te instanceof IItemDuct;
}
private ItemStack fillEIOConduit(ItemStack item, TileEntity te, ForgeDirection direction) {
if (isConduit(te)) {
return ((IItemDuct) te).insertItem(direction, item);
}
return item;
}
private InventoryAdaptor getSideItem(ForgeDirection direction) {
TileEntity te = this.posInterface.getOffSet(direction).getTileEntity();
return InventoryAdaptor.getAdaptor(te, direction.getOpposite());
}
// 0 - It is empty
// 1 - It contains item/fluid
// 2 - It doesn't exist
private int checkItemFluids(IFluidHandler tank, InventoryAdaptor inv, ForgeDirection direction) {
if (tank == null && inv == null) {
return 2;
}
if (tank != null && tank.getTankInfo(direction) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (Util.getPart(invFluids, this.side) instanceof PartP2PLiquids) {
if (Util.getPart(tank, direction) instanceof PartP2PLiquids) {
// read other ends of p2p for blocking mode
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(invFluids, this.side);
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(tank, direction);
try {
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
boolean checkedInput = false;
@@ -191,35 +385,72 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
}
} catch (GridAccessException ignore) {}
} else {
tankInfos.add(invFluids.getTankInfo(this.side));
tankInfos.add(tank.getTankInfo(direction));
}
boolean hasTank = false;
for (FluidTankInfo[] tankInfoArray : tankInfos) {
for (FluidTankInfo tank : tankInfoArray) {
for (FluidTankInfo tankInfo : tankInfoArray) {
hasTank = true;
FluidStack fluid = tank.fluid;
FluidStack fluid = tankInfo.fluid;
if (fluid != null && fluid.amount > 0) {
return true;
return 1;
}
}
}
if (!hasTank && invItems == null) {
// If this entity doesn't have fluid or item inventory, we just view it as full of things.
if (!hasTank && inv == null) {
return 2;
}
}
if (isGTMachine(tank)) {
return gtMachineCircuitCheck(inv);
}
return inv != null && inv.containsItems() ? 1 : 0;
}
private boolean checkValidSide(TileEntity te, ForgeDirection direction) {
if (isGTMachine(te)) {
return checkGTPipeConnection(te, direction.getOpposite());
}
return isDifferentGrid(getInterfaceTE(te, direction.getOpposite()));
}
private boolean checkGTPipeConnection(TileEntity te, ForgeDirection direction) {
if (te instanceof IGregTechTileEntity) {
IMetaTileEntity mte = ((IGregTechTileEntity) te).getMetaTileEntity();
if (mte instanceof MetaPipeEntity) {
return ((MetaPipeEntity) mte).isConnectedAtSide(direction.ordinal());
}
}
return true;
}
private static IInterfaceHost getInterfaceTE(TileEntity te, ForgeDirection face) {
if (te instanceof IInterfaceHost) {
return (IInterfaceHost) te;
} else if (te instanceof TileCableBus) {
IPart part = ((TileCableBus) te).getPart(face);
if (part instanceof IInterfaceHost) {
return (IInterfaceHost) part;
}
}
return null;
}
private boolean isDifferentGrid(IInterfaceHost target) {
if (this.selfInterface != null && target != null) {
DualityInterface other = target.getInterfaceDuality();
DualityInterface self = this.selfInterface.getInterfaceDuality();
try {
AENetworkProxy proxy1 = Ae2Reflect.getInterfaceProxy(other);
AENetworkProxy proxy2 = Ae2Reflect.getInterfaceProxy(self);
if (proxy1.getGrid() == proxy2.getGrid()) {
return false;
}
} catch (GridAccessException e) {
return true;
}
}
return invItems != null && invItems.containsItems();
}
public boolean hasSlots() {
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
}
@Override
public Iterator<ItemSlot> iterator() {
return new SlotIterator(
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
invItems != null ? invItems.iterator() : Collections.emptyIterator());
return true;
}
private static class SlotIterator implements Iterator<ItemSlot> {
@@ -3,20 +3,54 @@ package com.glodblock.github.inventory;
import net.minecraft.item.ItemStack;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.inventory.item.IWirelessPatternTerminal;
public class WirelessFluidPatternTerminalPatterns extends AppEngInternalInventory {
private final ItemStack is;
private final IWirelessPatternTerminal terminal;
public WirelessFluidPatternTerminalPatterns(final ItemStack is) {
public WirelessFluidPatternTerminalPatterns(final ItemStack is, final IWirelessPatternTerminal term) {
super(null, 2);
this.is = is;
this.terminal = term;
this.readFromNBT(Platform.openNbtData(is), "pattern");
}
@Override
public void markDirty() {
this.writeToNBT(Platform.openNbtData(is), "pattern");
}
@Override
public void setInventorySlotContents(final int slot, final ItemStack newItemStack) {
final ItemStack oldStack = this.inv[slot];
this.inv[slot] = newItemStack;
if (this.eventsEnabled()) {
ItemStack removed = oldStack;
ItemStack added = newItemStack;
if (oldStack != null && newItemStack != null && Platform.isSameItemPrecise(oldStack, newItemStack)) {
if (oldStack.stackSize > newItemStack.stackSize) {
removed = removed.copy();
removed.stackSize -= newItemStack.stackSize;
added = null;
} else if (oldStack.stackSize < newItemStack.stackSize) {
added = added.copy();
added.stackSize -= oldStack.stackSize;
removed = null;
} else {
removed = added = null;
}
}
this.terminal.onChangeInventory(this, slot, InvOperation.setInventorySlotContents, removed, added);
}
this.markDirty();
}
}
@@ -12,6 +12,7 @@ import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import com.glodblock.github.inventory.item.IItemInventory;
import com.glodblock.github.util.Util;
public abstract class ItemGuiFactory<T> implements IGuiFactory {
@@ -29,7 +30,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -56,7 +57,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
@Nullable
@Override
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -30,9 +30,8 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
@Override
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -63,7 +62,7 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
if (result.left == Util.GuiHelper.GuiType.ITEM) {
ItemStack item = player.getHeldItem();
ItemStack item = Util.getWirelessTerminal(player, x);
if (item == null || !(item.getItem() instanceof IItemInventory)) {
return null;
}
@@ -35,4 +35,8 @@ public interface IItemPatternTerminal extends IItemTerminal {
boolean isCraftingRecipe();
void sortCraftingItems();
boolean isAutoFillPattern();
void setAutoFillPattern(boolean canFill);
}
@@ -88,6 +88,7 @@ public class WirelessFluidTerminalInventory extends MEMonitorHandler<IAEFluidSta
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
out.putSetting(Settings.VIEW_MODE, ViewItems.ALL);
return out;
}
@@ -11,8 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
@@ -28,6 +30,7 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
@@ -53,6 +56,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -67,7 +71,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting_ex", 32);
this.output = new ItemBiggerAppEngInventory(is, "output_ex", 32);
}
@@ -108,6 +112,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
this.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
@@ -118,6 +123,7 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
data.setBoolean("priorization", this.prioritize);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
@@ -167,7 +173,84 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
int inputsCount = 0;
int outputCount = 0;
for (IAEItemStack inItem : inItems) {
if (inItem != null) {
inputsCount++;
}
}
for (IAEItemStack outItem : outItems) {
if (outItem != null) {
outputCount++;
}
}
this.setSubstitution(details.canSubstitute());
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
this.setBeSubstitute(details.canBeSubstitute());
}
this.setInverted(inputsCount <= 8 && outputCount > 8);
this.setActivePage(0);
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
final IAEItemStack item = inItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
}
}
if (inverted) {
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else this.output.setInventorySlotContents(i, item.getItemStack());
}
}
} else {
for (int i = 0; i < outItems.length && i < 8; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
} else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
}
}
}
}
}
}
}
private void fixCraftingRecipes() {
@@ -316,6 +399,16 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -11,8 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
@@ -28,6 +30,7 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
@@ -53,6 +56,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
protected boolean prioritize = false;
protected boolean inverted = false;
protected boolean beSubstitute = false;
protected boolean autoFillPattern = false;
protected int activePage = 0;
@SuppressWarnings("unchecked")
@@ -67,7 +71,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.pattern = new WirelessFluidPatternTerminalPatterns(is);
this.pattern = new WirelessFluidPatternTerminalPatterns(is, this);
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
}
@@ -106,9 +110,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
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.setAutoFillPattern(data.getBoolean("autoFillPattern"));
}
public void writeToNBT() {
@@ -117,9 +120,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
data.setBoolean("priorization", this.prioritize);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
data.setBoolean("autoFillPattern", this.autoFillPattern);
}
@Override
@@ -169,7 +171,58 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern
.getPatternForItem(is, this.getActionableNode().getWorld());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
this.setCraftingRecipe(details.isCraftable());
this.setSubstitution(details.canSubstitute());
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
this.setBeSubstitute(details.canBeSubstitute());
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
if (inItems[i] != null) {
final IAEItemStack item = inItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
}
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
if (outItems[i] != null) {
final IAEItemStack item = outItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket
.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
}
}
}
}
if (inv == this.crafting) {
this.fixCraftingRecipes();
}
}
private void fixCraftingRecipes() {
@@ -185,7 +238,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isInverted() {
return this.inverted;
return false;
}
@Override
@@ -212,7 +265,7 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
@Override
public boolean isPrioritize() {
return this.prioritize;
return false;
}
@Override
@@ -318,6 +371,16 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
saveChanges();
}
@Override
public boolean isAutoFillPattern() {
return this.autoFillPattern;
}
@Override
public void setAutoFillPattern(boolean canFill) {
this.autoFillPattern = canFill;
}
@Override
public void saveSettings() {
this.writeToNBT();
@@ -0,0 +1,50 @@
package com.glodblock.github.loader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.lwjgl.input.Keyboard;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.util.Util;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class KeybindLoader implements Runnable {
public static KeyBinding openTerminal;
@Override
public void run() {
openTerminal = new KeyBinding("key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
ClientRegistry.registerKeyBinding(openTerminal);
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (Minecraft.getMinecraft().currentScreen != null) return;
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
if (p.openContainer == null) {
return;
}
if (openTerminal.isPressed()) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(p);
if (term != null && term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
ItemWirelessUltraTerminal.switchTerminal(
p,
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
}
}
}
}
@@ -6,6 +6,7 @@ import codechicken.nei.api.IConfigureNEI;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.nei.recipes.FluidRecipe;
import com.glodblock.github.util.ModAndClassUtil;
public class NEI_FC_Config implements IConfigureNEI {
@@ -13,27 +14,46 @@ public class NEI_FC_Config implements IConfigureNEI {
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
if (ModAndClassUtil.AVARITIA) {
API.registerGuiOverlay(GuiFluidPatternWireless.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternExWireless.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternTerminal.class, "extreme", null);
API.registerGuiOverlay(GuiFluidPatternTerminalEx.class, "extreme", null);
}
for (String identifier : FluidRecipe.getSupportRecipes()) {
API.registerGuiOverlayHandler(
GuiFluidCraftingWireless.class,
FluidCraftingTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternExWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternTerminal.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternTerminalEx.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
// that NEE handlers take priority
if (!API.hasGuiOverlayHandler(GuiFluidCraftingWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidCraftingWireless.class,
FluidCraftingTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternExWireless.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternExWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternTerminal.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternTerminal.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
if (!API.hasGuiOverlayHandler(GuiFluidPatternTerminalEx.class, identifier)) {
API.registerGuiOverlayHandler(
GuiFluidPatternTerminalEx.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
}
}
}
@@ -50,6 +50,10 @@ public class DefaultExtractorLoader implements Runnable {
FluidRecipe.addRecipeMap("EnderIOVat", new EnderIORecipeExtractor());
}
if (ModAndClassUtil.AVARITIA) {
FluidRecipe.addRecipeMap("extreme", new AvaritiaRecipeExtractor());
}
if (ModAndClassUtil.FTR) {
// GTNH
FluidRecipe.addRecipeMap("forestry.bottler", new ForestryRecipeExtractor(new NEIHandlerBottler()));
@@ -0,0 +1,36 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import com.glodblock.github.nei.NEIUtils;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
public class AvaritiaRecipeExtractor implements IRecipeExtractor {
public AvaritiaRecipeExtractor() {}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
return getInputIngredients(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
return getOutputIngredients(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return NEIUtils.compress(ExtractorUtil.packItemStack(rawInputs));
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
}
@@ -21,6 +21,7 @@ import appeng.core.AELog;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
@@ -97,11 +98,11 @@ public class CPacketCraftRequest implements IMessage {
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
}
@@ -116,6 +116,9 @@ public class CPacketFluidPatternTermBtns implements IMessage {
break;
}
break;
case "PatternTerminal.AutoFillerPattern":
cpt.getPatternTerminal().setAutoFillPattern(Value.equals("1"));
break;
}
cpt.getPatternTerminal().saveSettings();
} else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) {
@@ -22,6 +22,7 @@ import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -94,6 +95,7 @@ public class CPacketInventoryAction implements IMessage {
final EntityPlayerMP sender = ctx.getServerHandler().playerEntity;
if (sender.openContainer instanceof AEBaseContainer) {
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
Object target = baseContainer.getTarget();
if (message.action == InventoryAction.AUTO_CRAFT) {
final ContainerOpenContext context = baseContainer.getOpenContext();
if (context != null) {
@@ -105,12 +107,12 @@ public class CPacketInventoryAction implements IMessage {
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.FLUID_CRAFTING_AMOUNT);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
((IWirelessTerminal) target).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
@@ -136,12 +138,12 @@ public class CPacketInventoryAction implements IMessage {
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.PATTERN_VALUE_SET);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
((IWirelessTerminal) target).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
@@ -18,6 +18,7 @@ import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.gui.PartOrItemGuiFactory;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -85,11 +86,11 @@ public class CPacketPatternValueSet implements IMessage {
0),
Objects.requireNonNull(context.getSide()),
message.originGui);
} else {
} else if (target instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
Objects.requireNonNull(context.getSide()),
message.originGui);
}
@@ -14,6 +14,7 @@ import appeng.container.ContainerOpenContext;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
@@ -84,12 +85,12 @@ public class CPacketSwitchGuis implements IMessage {
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
message.guiType);
} else {
} else if (((AEBaseContainer) cont).getTarget() instanceof IWirelessTerminal) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
((IWirelessTerminal) ((AEBaseContainer) cont).getTarget()).getInventorySlot(),
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
Objects.requireNonNull(context.getSide()),
@@ -135,10 +135,12 @@ public class CPacketTransferRecipe implements IMessage {
IAEItemStack iaeItemStack = AEApi.instance().storage().createItemStack(is);
if (storageList.findPrecise(iaeItemStack) == null) {
for (IAEItemStack tmp : storageList.findFuzzy(iaeItemStack, FuzzyMode.IGNORE_ALL)) {
ItemStack substitute = tmp.getItemStack().copy();
substitute.stackSize = is.stackSize;
stack.putStack(substitute);
break;
if (iaeItemStack.sameOre(tmp)) {
ItemStack substitute = tmp.getItemStack().copy();
substitute.stackSize = is.stackSize;
stack.putStack(substitute);
break;
}
}
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.proxy;
import com.glodblock.github.loader.KeybindLoader;
import com.glodblock.github.loader.ListenerLoader;
import com.glodblock.github.loader.RenderLoader;
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
@@ -21,6 +22,7 @@ public class ClientProxy extends CommonProxy {
super.init(event);
(new ListenerLoader()).run();
(new RenderLoader()).run();
(new KeybindLoader()).run();
}
@Override
@@ -16,7 +16,9 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.CraftingCPURecord;
import appeng.crafting.MECraftingInventory;
import appeng.helpers.DualityInterface;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEPassThrough;
import appeng.parts.p2p.PartP2PLiquids;
@@ -35,6 +37,7 @@ public class Ae2Reflect {
private static final Field fCPU_inventory;
private static final Field fCPU_machineSrc;
private static final Field fContainerUpgradeable_upgradeable;
private static final Field fDualInterface_gridProxy;
private static final Method mItemSlot_setExtractable;
private static final Method mCPU_getGrid;
private static final Method mCPU_postChange;
@@ -54,6 +57,7 @@ public class Ae2Reflect {
fCPU_machineSrc = Ae2Reflect.reflectField(CraftingCPUCluster.class, "machineSrc");
fContainerUpgradeable_upgradeable = Ae2Reflect.reflectField(ContainerUpgradeable.class, "upgradeable");
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
fDualInterface_gridProxy = reflectField(DualityInterface.class, "gridProxy");
mCPU_getGrid = reflectMethod(CraftingCPUCluster.class, "getGrid");
mCPU_postChange = reflectMethod(
CraftingCPUCluster.class,
@@ -164,6 +168,10 @@ public class Ae2Reflect {
return Ae2Reflect.readField(owner, fContainerUpgradeable_upgradeable);
}
public static AENetworkProxy getInterfaceProxy(DualityInterface owner) {
return Ae2Reflect.readField(owner, fDualInterface_gridProxy);
}
public static void postCPUChange(CraftingCPUCluster cpu, IAEItemStack stack, MachineSource src) {
try {
mCPU_postChange.invoke(cpu, stack, src);
@@ -25,6 +25,7 @@ public final class ModAndClassUtil {
public static boolean COFH = false;
public static boolean GTPP = false;
public static boolean WAILA = false;
public static boolean AVARITIA = false;
public static boolean isV2;
public static boolean isDoubleButton;
public static boolean isSaveText;
@@ -130,5 +131,6 @@ public final class ModAndClassUtil {
if (Loader.isModLoaded("CoFHCore")) COFH = true;
if (Loader.isModLoaded("miscutils")) GTPP = true;
if (Loader.isModLoaded("Waila")) WAILA = true;
if (Loader.isModLoaded("Avaritia")) AVARITIA = true;
}
}
@@ -16,7 +16,6 @@ import net.minecraftforge.fluids.*;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.lwjgl.input.Mouse;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -40,10 +39,12 @@ import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import baubles.api.BaublesApi;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.item.IFluidPortableCell;
@@ -53,39 +54,30 @@ import io.netty.buffer.ByteBuf;
public final class Util {
public static class MouseHandler {
private static int mouse_x = 0;
private static int mouse_y = 0;
public static void saveMousePos() {
mouse_x = Mouse.getX();
mouse_y = Mouse.getY();
}
public static void loadMousePos() {
if (mouse_x != 0 && mouse_y != 0) {
Mouse.setCursorPosition(mouse_x, mouse_y);
mouse_y = 0;
mouse_x = 0;
}
}
}
public static int drainItemPower(AEBaseContainer c, InventoryPlayer ip, int slot, int ticks, double pm,
IFluidPortableCell wt) {
final ItemStack currentItem = slot < 0 ? ip.getCurrentItem() : ip.getStackInSlot(slot);
if (wt != null) {
if (currentItem != wt.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
ip.setInventorySlotContents(ip.currentItem, wt.getItemStack());
if (slot != -1) {
final ItemStack currentItem = getWirelessTerminal(ip.player, slot);
if (wt != null) {
if (currentItem != wt.getItemStack()) {
if (currentItem != null) {
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
if (GuiHelper.decodeInvType(slot).getLeft() == GuiHelper.InvType.PLAYER_INV) {
ip.setInventorySlotContents(slot, wt.getItemStack());
} else {
BaublesApi.getBaubles(ip.player).setInventorySlotContents(
GuiHelper.decodeInvType(slot).getRight(),
wt.getItemStack());
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
}
} else {
c.setValidContainer(false);
@@ -152,6 +144,40 @@ public final class Util {
return new NullInventory<>();
}
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
ImmutablePair<GuiHelper.InvType, Integer> result = GuiHelper.decodeInvType(x);
if (result.getLeft() == GuiHelper.InvType.PLAYER_INV) {
return player.inventory.getStackInSlot(result.getRight());
} else {
return BaublesApi.getBaubles(player).getStackInSlot(result.getRight());
}
}
public static ImmutablePair<Integer, ItemStack> getUltraWirelessTerm(EntityPlayer player) {
int invSize = player.inventory.getSizeInventory();
if (invSize <= 0) {
return null;
}
for (int i = 0; i < invSize; ++i) {
ItemStack is = player.inventory.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
return new ImmutablePair<>(i, is);
}
}
IInventory handler = BaublesApi.getBaubles(player);
if (handler != null) {
invSize = handler.getSizeInventory();
for (int i = 0; i < invSize; ++i) {
ItemStack is = handler.getStackInSlot(i);
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
return new ImmutablePair<>(GuiHelper.encodeType(i, GuiHelper.InvType.PLAYER_BAUBLES), is);
}
}
}
return null;
}
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
@@ -343,6 +369,11 @@ public final class Util {
ITEM
}
public enum InvType {
PLAYER_INV,
PLAYER_BAUBLES
}
private static final int value = 1 << 30;
public static int encodeType(int y, GuiType type) {
@@ -352,6 +383,13 @@ public final class Util {
return value | (type.ordinal() << 29) | y;
}
public static int encodeType(int x, InvType type) {
if (Math.abs(x) > (1 << 28)) {
throw new IllegalArgumentException("out of range");
}
return value | (type.ordinal() << 29) | x;
}
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
if (Math.abs(y) > (1 << 28)) {
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
@@ -359,6 +397,14 @@ public final class Util {
return new ImmutablePair<>(GuiType.TILE, y);
}
}
public static ImmutablePair<InvType, Integer> decodeInvType(int x) {
if (Math.abs(x) > (1 << 28)) {
return new ImmutablePair<>(InvType.values()[x >> 29 & 1], x - (3 << 29 & x));
} else {
return new ImmutablePair<>(InvType.PLAYER_INV, x);
}
}
}
public static int clamp(int value, int min, int max) {
@@ -131,6 +131,10 @@ ae2fc.tooltip.submit=Submit
ae2fc.tooltip.enable=Enabled
ae2fc.tooltip.disable=Disabled
ae2fc.tooltip.edit=Edit
ae2fc.tooltip.fill_pattern=Allow auto fill blank pattern
ae2fc.tooltip.not_fill_pattern=Allow auto fill blank pattern
ae2fc.tooltip.fill_pattern.hint=Enabled
ae2fc.tooltip.not_fill_pattern.hint=Disabled
ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal
ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal
@@ -157,4 +161,6 @@ ae2fc.gui.fluid_auto_filler=ME Fluid Auto Filler
error.unknown=Unknown
key.OpenTerminal=Open Wireless Universal Terminal
itemGroup.ae2fc=Fluid Craft For AE2
@@ -64,7 +64,8 @@ tile.level_maintainer.name=ME库存维持器
tile.fluid_buffer.name=ME流体缓存器
tile.walrus.name=海象
tile.fluid_auto_filler.name=ME流体自动装填器
tile.certus_quartz_tank.name=赛特斯石英水槽
tile.certus_quartz_tank.name=赛特斯石英水槽 - %s
tile.certus_quartz_tank_empty.name=赛特斯石英水槽
ae2fc.waila.speed=速度
ae2fc.waila.enable=启用
@@ -130,6 +131,10 @@ ae2fc.tooltip.submit=提交
ae2fc.tooltip.enable=启用
ae2fc.tooltip.disable=禁用
ae2fc.tooltip.edit=编辑
ae2fc.tooltip.fill_pattern=允许自动填充空白样板
ae2fc.tooltip.not_fill_pattern=允许自动填充空白样板
ae2fc.tooltip.fill_pattern.hint=启用
ae2fc.tooltip.not_fill_pattern.hint=禁用
ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端
ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端
@@ -156,7 +161,8 @@ ae2fc.gui.fluid_auto_filler=ME流体自动装填器
error.unknown=未知流体
key.OpenTerminal=打开无线通用终端
itemGroup.ae2fc=AE2流体合成套件重置
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB