mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 09:34:42 +00:00
fix interface terminal bug
This commit is contained in:
1 parent
d2c420d193
commit
c935e85a2f
12 files changed
+222
-31
No files matched your search
@@ -48,6 +48,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio");
|
||||
this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio");
|
||||
this.registerApp(4, "SUBMIT", "SUBMIT", "submit");
|
||||
this.registerApp(5, "EDIT", "YES", "edit");
|
||||
this.registerApp(6, "DISABLE", "DISABLE", "disable");
|
||||
this.registerApp(7, "ENABLE", "ENABLE", "enable");
|
||||
this.registerApp(10, "FLUID_TEM", "YES", "fluid_terminal_w");
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -39,9 +40,11 @@ import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCBaseMEGui;
|
||||
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
@@ -53,7 +56,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final HashMap<ClientDCInternalInv, DimensionalCoord> blockPosHashMap = new HashMap<>();
|
||||
private final HashMap<ClientDCInternalInv, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
|
||||
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
@@ -310,8 +313,14 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
guiTop + offset + 1,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.HIGHLIGHT_INTERFACE);
|
||||
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
|
||||
guiButtonHashMap.put(guiButton, inv);
|
||||
buttonList.add(guiButton);
|
||||
guiButtonHashMap.put(editButton, inv);
|
||||
if (isShiftKeyDown()) {
|
||||
buttonList.add(editButton);
|
||||
} else {
|
||||
buttonList.add(guiButton);
|
||||
}
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
@@ -336,28 +345,34 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (guiButtonHashMap.containsKey(btn)) {
|
||||
DimensionalCoord blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
(int) mc.thePlayer.posX,
|
||||
(int) mc.thePlayer.posY,
|
||||
(int) mc.thePlayer.posZ);
|
||||
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceInOtherDim.getName(),
|
||||
blockPos.getDimension()));
|
||||
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketRenamer(blockPos.x, blockPos.y, blockPos.z, blockPos.getDimension(), blockPos.side));
|
||||
} else {
|
||||
BlockPosHighlighter.highlightBlock(
|
||||
blockPos,
|
||||
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceHighlighted.getName(),
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z));
|
||||
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
(int) mc.thePlayer.posX,
|
||||
(int) mc.thePlayer.posY,
|
||||
(int) mc.thePlayer.posZ);
|
||||
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceInOtherDim.getName(),
|
||||
blockPos.getDimension()));
|
||||
} else {
|
||||
BlockPosHighlighter.highlightBlock(
|
||||
blockPos,
|
||||
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceHighlighted.getName(),
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z));
|
||||
}
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
mc.thePlayer.closeScreen();
|
||||
} else if (btn == guiButtonHideFull) {
|
||||
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
|
||||
this.refreshList();
|
||||
@@ -473,6 +488,17 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class DimensionalCoordSide extends DimensionalCoord {
|
||||
|
||||
private ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
|
||||
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side) {
|
||||
super(_x, _y, _z, _dim);
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postUpdate(final NBTTagCompound in) {
|
||||
if (in.getBoolean("clear")) {
|
||||
this.byId.clear();
|
||||
@@ -491,7 +517,8 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
int Y = invData.getInteger("y");
|
||||
int Z = invData.getInteger("z");
|
||||
int dim = invData.getInteger("dim");
|
||||
blockPosHashMap.put(current, new DimensionalCoord(X, Y, Z, dim));
|
||||
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
|
||||
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
|
||||
|
||||
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
|
||||
+28
-8
@@ -10,9 +10,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
@@ -23,6 +21,7 @@ import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.p2p.PartP2PInterface;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -36,7 +35,9 @@ import appeng.util.inv.WrapperInvSlot;
|
||||
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
@@ -49,15 +50,22 @@ public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
|
||||
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
|
||||
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<Long, ContainerInterfaceWireless.InvTracker>();
|
||||
private final IWirelessInterfaceTerminal it;
|
||||
// private final Map<Long, InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private NBTTagCompound data = new NBTTagCompound();
|
||||
private int ticks;
|
||||
private final int slot;
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal anchor) {
|
||||
super(ip, anchor);
|
||||
|
||||
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
this.it = (IWirelessInterfaceTerminal) monitorable;
|
||||
final int slotIndex = monitorable.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
if (Platform.isServer()) {
|
||||
this.grid = anchor.getActionableNode().getGrid();
|
||||
this.grid = monitorable.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
@@ -73,12 +81,17 @@ public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
return union;
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.ticks = Util
|
||||
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.it);
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
@@ -311,6 +324,7 @@ public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
tag.setInteger("y", inv.Y);
|
||||
tag.setInteger("z", inv.Z);
|
||||
tag.setInteger("dim", inv.dim);
|
||||
tag.setInteger("side", inv.side.ordinal());
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++) {
|
||||
@@ -343,6 +357,7 @@ public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
private final int Y;
|
||||
private final int Z;
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
|
||||
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
|
||||
int offset, int size) {
|
||||
@@ -355,6 +370,11 @@ public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
Y = dual.getLocation().y;
|
||||
Z = dual.getLocation().z;
|
||||
dim = dual.getLocation().getDimension();
|
||||
if (dual.getHost() instanceof AEBasePart) {
|
||||
side = ((AEBasePart) dual.getHost()).getSide();
|
||||
} else {
|
||||
side = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user