mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
Merge remote-tracking branch 'origin/gui-reaper' into gui-reaper
# Conflicts: # src/main/java/com/glodblock/github/client/gui/GuiFluidLevelEmitter.java # src/main/java/com/glodblock/github/inventory/gui/GuiType.java
This commit is contained in:
commit
461d574a54
6 files changed
+193
-20
No files matched your search
+1
-1
@@ -48,7 +48,7 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.0:dev')
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.12:dev') {
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.20:dev') {
|
||||
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
|
||||
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.implementations.GuiLevelEmitter;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class GuiLevelEmitterProxy extends GuiLevelEmitter {
|
||||
|
||||
protected GuiType originalGui;
|
||||
protected Util.DimensionalCoordSide originalBlockPos;
|
||||
protected ItemStack originalGuiIcon;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final PartLevelEmitter te) {
|
||||
super(inventoryPlayer, te);
|
||||
|
||||
if (inventoryPlayer.player.openContainer instanceof AEBaseContainer container) {
|
||||
var target = container.getTarget();
|
||||
if (target instanceof PartLevelTerminal terminal) {
|
||||
originalGuiIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
terminal.getSide(),
|
||||
"");
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
originalGuiIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
inventoryPlayer.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
|
||||
originalGuiIcon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
inventoryPlayer.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (this.originalGuiIcon != null) {
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.originalGuiIcon,
|
||||
this.originalGuiIcon.getDisplayName(),
|
||||
itemRender);
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
this.buttonList.add(originalGuiBtn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn) {
|
||||
if (btn == this.originalGuiBtn) {
|
||||
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide());
|
||||
message.setOriginalGui(originalGui.ordinal());
|
||||
FluidCraft.proxy.netHandler.sendToServer(message);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
|
||||
@@ -1224,7 +1224,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
dim,
|
||||
ForgeDirection.getOrientation(side),
|
||||
"");
|
||||
if (isCtrlKeyDown() && isShiftKeyDown() && hasInfinityBoosterCard(mc.thePlayer)) {
|
||||
if (isCtrlKeyDown() && isShiftKeyDown()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelTerminalCommands(
|
||||
Action.EDIT,
|
||||
|
||||
@@ -59,6 +59,7 @@ import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.SettingsFrom;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@@ -101,10 +102,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
|
||||
int idx = this.getRequestIndexByLink(link);
|
||||
if (idx == -1) {
|
||||
AELog.warn("Invalid crafting link: " + link);
|
||||
return items;
|
||||
}
|
||||
|
||||
try {
|
||||
if (getProxy().isActive()) {
|
||||
final IEnergyGrid energy = getProxy().getEnergy();
|
||||
@@ -116,7 +114,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, source);
|
||||
if (notInjectedItems != null) {
|
||||
items.setStackSize(notInjectedItems.getStackSize());
|
||||
this.updateState(idx, LevelState.Export);
|
||||
if (idx != -1) {
|
||||
this.updateState(idx, LevelState.Export);
|
||||
}
|
||||
|
||||
return items;
|
||||
} else {
|
||||
@@ -163,7 +163,8 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
try {
|
||||
final ICraftingGrid craftingGrid = getProxy().getCrafting();
|
||||
final IGrid grid = getProxy().getGrid();
|
||||
final IItemList<IAEItemStack> inv = getProxy().getStorage().getItemInventory().getStorageList();
|
||||
final IItemList<IAEItemStack> invItems = getProxy().getStorage().getItemInventory().getStorageList();
|
||||
final IItemList<IAEFluidStack> invFluid = getProxy().getStorage().getFluidInventory().getStorageList();
|
||||
|
||||
// Check there are available crafting CPUs before doing any work.
|
||||
// This hopefully stops level maintainers busy-looping calculating
|
||||
@@ -205,9 +206,16 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack aeItem = inv.findPrecise(craftItem);
|
||||
IAEItemStack aeItem = invItems.findPrecise(craftItem);
|
||||
|
||||
long stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
long stackSize;
|
||||
|
||||
if (craftItem.getItem() instanceof ItemFluidDrop) {
|
||||
IAEFluidStack ifs = invFluid.findPrecise(ItemFluidDrop.getAeFluidStack(craftItem));
|
||||
stackSize = ifs == null ? 0 : ifs.getStackSize();
|
||||
} else {
|
||||
stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
}
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (aeItem != null && ThaumicEnergisticsCrafting.isAspectStack(aeItem.getItemStack())) {
|
||||
@@ -430,7 +438,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
if (this.requests[i] != null) {
|
||||
tagList.appendTag(this.requests[i].writeToNBT());
|
||||
tagList.appendTag(this.requests[i].writeToNBT(true));
|
||||
} else {
|
||||
tagList.appendTag(new NBTTagCompound());
|
||||
}
|
||||
@@ -544,6 +552,42 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
data.writeBoolean(isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadSettings(SettingsFrom from, NBTTagCompound compound) {
|
||||
super.uploadSettings(from, compound);
|
||||
NBTTagList tagList = compound.getTagList(NBT_REQUESTS, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound tag = tagList.getCompoundTagAt(i);
|
||||
if (tag == null || !tag.hasKey(NBT_STACK)) {
|
||||
this.requests[i] = null;
|
||||
} else {
|
||||
try {
|
||||
this.requests[i] = new RequestInfo(tag, this);
|
||||
this.requests[i].state = LevelState.None;
|
||||
} catch (Exception ignored) {
|
||||
this.requests[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound downloadSettings(SettingsFrom from) {
|
||||
NBTTagCompound compound = super.downloadSettings(from);
|
||||
compound = compound == null ? new NBTTagCompound() : compound;
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
if (this.requests[i] != null) {
|
||||
tagList.appendTag(this.requests[i].writeToNBT(false));
|
||||
} else {
|
||||
tagList.appendTag(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
compound.setTag(NBT_REQUESTS, tagList);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkPowerStatusChange p) {
|
||||
updatePowerState();
|
||||
@@ -643,7 +687,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
public NBTTagCompound writeToNBT(boolean includeLink) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
itemStack.writeToNBT(stackTag);
|
||||
@@ -652,7 +696,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
tag.setLong(NBT_BATCH, batchSize);
|
||||
tag.setBoolean(NBT_ENABLE, enable);
|
||||
tag.setInteger(NBT_STATE, state.ordinal());
|
||||
if (this.link != null) {
|
||||
if (this.link != null && includeLink) {
|
||||
NBTTagCompound linkTag = new NBTTagCompound();
|
||||
this.link.writeToNBT(linkTag);
|
||||
tag.setTag(NBT_LINK, linkTag);
|
||||
|
||||
@@ -5,10 +5,14 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -110,12 +114,33 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
case EDIT -> {
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim)
|
||||
.getTileEntity(message.x, message.y, message.z);
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
|
||||
if (tile instanceof IPartHost host) {
|
||||
IPart part = host.getPart(message.side);
|
||||
if (part instanceof PartLevelEmitter) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.LEVEL_EMITTER_PROXY);
|
||||
} else if (part instanceof PartFluidLevelEmitter) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
}
|
||||
} else {
|
||||
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
}
|
||||
case BACK -> {
|
||||
GuiType originalGui = GuiType.getByOrdinal(message.originalGui);
|
||||
|
||||
Reference in new issue
Block a user