mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 07:47:55 +00:00
fix bug
This commit is contained in:
1 parent
9f53884572
commit
c8457bb7d3
5 files changed
+205
-16
No files matched your search
+26
-7
@@ -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(this.getPlayerInv().currentItem, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+35
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
+82
-2
@@ -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;
|
||||
@@ -67,7 +70,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);
|
||||
}
|
||||
@@ -167,7 +170,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() {
|
||||
|
||||
+56
-2
@@ -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;
|
||||
@@ -67,7 +70,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);
|
||||
}
|
||||
@@ -169,7 +172,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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user