mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge pull request #95 from asdflj/master
fix can't be display in network details
This commit is contained in:
21 files changed
+412
-111
No files matched your search
@@ -16,7 +16,6 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
@@ -42,6 +41,7 @@ import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
|
||||
@@ -52,7 +52,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, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
|
||||
private final HashMap<ClientDCInternalInv, Util.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<>();
|
||||
@@ -352,10 +352,15 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (guiButtonHashMap.containsKey(btn)) {
|
||||
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
|
||||
Util.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));
|
||||
new CPacketRenamer(
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
blockPos.getSide()));
|
||||
} else {
|
||||
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
@@ -497,17 +502,6 @@ 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();
|
||||
@@ -527,7 +521,9 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
int Z = invData.getInteger("z");
|
||||
int dim = invData.getInteger("dim");
|
||||
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
|
||||
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
|
||||
blockPosHashMap.put(
|
||||
current,
|
||||
new Util.DimensionalCoordSide(X, Y, Z, dim, side, current.getUnlocalizedName()));
|
||||
|
||||
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerRenamer;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
|
||||
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
|
||||
private MEGuiTextField textField;
|
||||
|
||||
public GuiRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(new ContainerRenamer(ip, monitorable));
|
||||
this.xSize = 256;
|
||||
|
||||
this.textField = new MEGuiTextField(230, 12);
|
||||
this.textField.setMaxStringLength(32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
|
||||
this.textField.x = this.guiLeft + 12;
|
||||
this.textField.y = this.guiTop + 35;
|
||||
this.textField.setFocused(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.Renamer.getLocal(), 12, 8, GuiColors.RenamerTitle.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.bindTexture("guis/renamer.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
this.textField.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
this.textField.mouseClicked(xCoord, yCoord, btn);
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (key == 28) { // Enter
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(this.textField.getText()));
|
||||
} else if (!this.textField.textboxKeyTyped(character, key)) {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOverTextField(final int mousex, final int mousey) {
|
||||
return textField.isMouseIn(mousex, mousey);
|
||||
}
|
||||
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
textField.setText(displayName);
|
||||
}
|
||||
|
||||
public void postUpdate(String text) {
|
||||
this.textField.setText(text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
|
||||
public class ContainerRenamer extends AEBaseContainer {
|
||||
|
||||
public ContainerRenamer(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,9 @@ import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.BlockStackSrc;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
@@ -27,6 +30,7 @@ public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<F
|
||||
|
||||
@Override
|
||||
public void setTileEntity(final Class<? extends TileEntity> clazz) {
|
||||
AEBaseTile.registerTileItem(clazz, new BlockStackSrc(this, 0, ActivityState.Enabled));
|
||||
super.setTileEntity(clazz);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.glodblock.github.common.item;
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -77,6 +78,8 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
if (isShiftKeyDown()) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
|
||||
lines.add(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS));
|
||||
lines.addAll(Arrays.asList(NameConst.i18n(NameConst.TT_ULTRA_TERMINAL_TIPS_DESC).split("\\\\n")));
|
||||
} else {
|
||||
lines.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
|
||||
@@ -40,9 +40,6 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
case "appeng.core.sync.packets.PacketCompressedNBT":
|
||||
tform = PacketCompressedNBTTransformer.INSTANCE;
|
||||
break;
|
||||
case "appeng.client.gui.implementations.GuiRenamer":
|
||||
tform = GuiRenamerTransformer.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,9 @@ package com.glodblock.github.coremod.hooker;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
|
||||
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -26,12 +19,4 @@ public class CoreModHooksClient {
|
||||
}
|
||||
}
|
||||
|
||||
public static void reopenInterfaceTerminal() {
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack c = p.getCurrentEquippedItem();
|
||||
if (c.getItem() instanceof ItemWirelessInterfaceTerminal || c.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.WIRELESS_INTERFACE_TERMINAL, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class GuiRenamerTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final GuiRenamerTransformer INSTANCE = new GuiRenamerTransformer();
|
||||
|
||||
private GuiRenamerTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new GuiRenamerTransformer.TransformGuiRenamer(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformGuiRenamer extends ClassVisitor {
|
||||
|
||||
TransformGuiRenamer(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("keyTyped")) {
|
||||
return new GuiRenamerTransformer.TransformKeyTyped(
|
||||
api,
|
||||
super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformKeyTyped extends MethodVisitor {
|
||||
|
||||
TransformKeyTyped(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
super.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
if (owner.equals("net/minecraft/client/entity/EntityClientPlayerMP") && name.equals("closeScreen")) {
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooksClient",
|
||||
"reopenInterfaceTerminal",
|
||||
"()V",
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,14 @@ public class ItemBiggerAppEngInventory extends BiggerAppEngInventory {
|
||||
this.readFromNBT(Platform.openNbtData(is), name);
|
||||
}
|
||||
|
||||
public void setCraftingMode(boolean mode) {
|
||||
Platform.openNbtData(is).setBoolean("craftingMode", mode);
|
||||
}
|
||||
|
||||
public boolean getCraftingMode(boolean mode) {
|
||||
return Platform.openNbtData(is).getBoolean("craftingMode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
boolean isCraft = Platform.openNbtData(is).getBoolean("craftingMode");
|
||||
|
||||
@@ -27,6 +27,18 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
RENAMER(new PartOrItemGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new ContainerRenamer(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiRenamer(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
FLUID_AUTO_FILLER(new TileGuiFactory<TileFluidAutoFiller>(TileFluidAutoFiller.class) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public interface IWirelessInterfaceTerminal extends IWirelessTerminal {
|
||||
|
||||
void setClickedInterface(Util.DimensionalCoordSide tile);
|
||||
|
||||
Util.DimensionalCoordSide getClickedInterface();
|
||||
}
|
||||
+34
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -10,6 +12,7 @@ import appeng.api.config.*;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
@@ -19,18 +22,38 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final IGridNode grid;
|
||||
private Util.DimensionalCoordSide tile;
|
||||
|
||||
public WirelessInterfaceTerminalInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
Objects.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS));
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
readFromNBT();
|
||||
}
|
||||
|
||||
public void readFromNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
if (data.hasKey("clickedInterface")) {
|
||||
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
|
||||
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT() {
|
||||
NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
NBTTagCompound tileMsg = new NBTTagCompound();
|
||||
tile.writeToNBT(tileMsg);
|
||||
data.setTag("clickedInterface", tileMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,4 +131,15 @@ public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTer
|
||||
ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickedInterface(Util.DimensionalCoordSide tile) {
|
||||
this.tile = tile;
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
}
|
||||
+2
@@ -326,6 +326,8 @@ public class WirelessPatternTerminalExInventory extends MEMonitorHandler<IAEItem
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
// force update crafting mode
|
||||
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
@@ -298,6 +298,8 @@ public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemSt
|
||||
public void setCraftingRecipe(boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.fixCraftingRecipes();
|
||||
// force update crafting mode
|
||||
((ItemBiggerAppEngInventory) this.crafting).setCraftingMode(craftingMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,6 +54,8 @@ public class ChannelLoader implements Runnable {
|
||||
.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.getGuis;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -19,10 +30,28 @@ public class CPacketRenamer implements IMessage {
|
||||
private int z;
|
||||
private int dim;
|
||||
private ForgeDirection side;
|
||||
private Action action;
|
||||
private String text;
|
||||
|
||||
public enum Action {
|
||||
OPEN,
|
||||
GET_TEXT,
|
||||
SET_TEXT,
|
||||
}
|
||||
|
||||
public CPacketRenamer() {}
|
||||
|
||||
public CPacketRenamer(String text) {
|
||||
this.action = Action.SET_TEXT;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public CPacketRenamer(Action a) {
|
||||
this.action = a;
|
||||
}
|
||||
|
||||
public CPacketRenamer(int x, int y, int z, int dim, ForgeDirection side) {
|
||||
this.action = Action.OPEN;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
@@ -32,31 +61,114 @@ public class CPacketRenamer implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.dim = buf.readInt();
|
||||
this.side = ForgeDirection.getOrientation(buf.readInt());
|
||||
this.action = Action.values()[buf.readInt()];
|
||||
if (this.action == Action.OPEN) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.dim = buf.readInt();
|
||||
this.side = ForgeDirection.getOrientation(buf.readInt());
|
||||
} else if (this.action == Action.SET_TEXT) {
|
||||
int leName = buf.readInt();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < leName; i++) {
|
||||
sb.append(buf.readChar());
|
||||
}
|
||||
this.text = sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeInt(this.dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
buf.writeInt(this.action.ordinal());
|
||||
if (this.action == Action.OPEN) {
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeInt(this.dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
} else if (this.action == Action.SET_TEXT) {
|
||||
buf.writeInt(this.text.length());
|
||||
for (int i = 0; i < this.text.length(); i++) {
|
||||
buf.writeChar(this.text.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketRenamer, IMessage> {
|
||||
|
||||
private String getName(TileEntity tile, ForgeDirection side) {
|
||||
if (tile instanceof TileCableBus) {
|
||||
return ((ICustomNameObject) ((TileCableBus) tile).getPart(side)).getCustomName();
|
||||
} else {
|
||||
return ((ICustomNameObject) tile).getCustomName();
|
||||
}
|
||||
}
|
||||
|
||||
private void setName(TileEntity tile, ForgeDirection side, String text) {
|
||||
if (tile instanceof TileCableBus) {
|
||||
((ICustomNameObject) ((TileCableBus) tile).getPart(side)).setCustomName(text);
|
||||
} else {
|
||||
((ICustomNameObject) tile).setCustomName(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketRenamer message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
|
||||
if (tile != null) {
|
||||
Platform.openGUI(player, tile, message.side, GuiBridge.GUI_RENAMER);
|
||||
AEBaseContainer con = (AEBaseContainer) player.openContainer;
|
||||
TileEntity tile;
|
||||
if (message.action == Action.OPEN) {
|
||||
tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
|
||||
if (tile != null && con.getTarget() instanceof IWirelessInterfaceTerminal
|
||||
&& tile instanceof ICustomNameObject) {
|
||||
String name = getName(tile, message.side);
|
||||
((IWirelessInterfaceTerminal) con.getTarget()).setClickedInterface(
|
||||
new Util.DimensionalCoordSide(
|
||||
message.x,
|
||||
message.y,
|
||||
message.z,
|
||||
message.dim,
|
||||
message.side,
|
||||
name));
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
1),
|
||||
message.side,
|
||||
GuiType.RENAMER);
|
||||
}
|
||||
} else {
|
||||
if (con.getTarget() instanceof IWirelessInterfaceTerminal) {
|
||||
Util.DimensionalCoordSide intMsg = ((IWirelessInterfaceTerminal) con.getTarget())
|
||||
.getClickedInterface();
|
||||
tile = DimensionManager.getWorld(intMsg.getDimension()).getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
if (message.action == Action.GET_TEXT) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendTo(new SPacketStringUpdate(this.getName(tile, intMsg.getSide())), player);
|
||||
} else {
|
||||
this.setName(tile, intMsg.getSide(), message.text);
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
((IWirelessInterfaceTerminal) con.getTarget()).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(
|
||||
getGuis().indexOf(
|
||||
GuiType.valueOf(
|
||||
GuiType.WIRELESS_INTERFACE_TERMINAL.toString())),
|
||||
Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import com.glodblock.github.client.gui.*;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class SPacketStringUpdate implements IMessage {
|
||||
|
||||
private String text;
|
||||
private int slot;
|
||||
|
||||
public SPacketStringUpdate() {}
|
||||
|
||||
public SPacketStringUpdate(String text, int slot) {
|
||||
this.text = text;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public SPacketStringUpdate(String text) {
|
||||
this.text = text;
|
||||
this.slot = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.slot = buf.readInt();
|
||||
int leName = buf.readInt();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < leName; i++) {
|
||||
sb.append(buf.readChar());
|
||||
}
|
||||
this.text = sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.slot);
|
||||
buf.writeInt(this.text.length());
|
||||
for (int i = 0; i < this.text.length(); i++) {
|
||||
buf.writeChar(this.text.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketStringUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SPacketStringUpdate message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiRenamer) {
|
||||
((GuiRenamer) gs).postUpdate(message.text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,8 @@ public class NameConst {
|
||||
public static final String TT_WIRELESS_INSTALLED = TT_WIRELESS + "installed";
|
||||
public static final String TT_FLUID_AUTO_FILLER = TT_KEY + "fluid_auto_filler";
|
||||
public static final String TT_ULTRA_TERMINAL = TT_KEY + "ultra_terminal";
|
||||
public static final String TT_ULTRA_TERMINAL_TIPS = TT_ULTRA_TERMINAL + ".tips";
|
||||
public static final String TT_ULTRA_TERMINAL_TIPS_DESC = TT_ULTRA_TERMINAL_TIPS + ".desc";
|
||||
|
||||
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
|
||||
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
|
||||
|
||||
@@ -31,6 +31,7 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
@@ -110,10 +111,11 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler<?> getWirelessInv(ItemStack is, EntityPlayer player, StorageChannel channel) {
|
||||
if (Platform.isClient()) return new NullInventory<>();
|
||||
IGridNode gridNode = getWirelessGrid(is);
|
||||
if (gridNode == null) return new NullInventory<>();
|
||||
if (gridNode == null) return null;
|
||||
IGrid grid = gridNode.getGrid();
|
||||
if (grid == null) return new NullInventory<>();
|
||||
if (grid == null) return null;
|
||||
boolean canConnect = false;
|
||||
if (hasInfinityBoosterCard(is)) {
|
||||
canConnect = true;
|
||||
@@ -141,7 +143,7 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new NullInventory<>();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
|
||||
@@ -553,4 +555,43 @@ public final class Util {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DimensionalCoordSide extends DimensionalCoord {
|
||||
|
||||
private ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
private final String name;
|
||||
|
||||
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side,
|
||||
String name) {
|
||||
super(_x, _y, _z, _dim);
|
||||
this.side = side;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ForgeDirection getSide() {
|
||||
return this.side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
data.setInteger("side", this.side.ordinal());
|
||||
data.setString("name", this.name);
|
||||
super.writeToNBT(data);
|
||||
}
|
||||
|
||||
public static DimensionalCoordSide readFromNBT(final NBTTagCompound data) {
|
||||
return new DimensionalCoordSide(
|
||||
data.getInteger("x"),
|
||||
data.getInteger("y"),
|
||||
data.getInteger("z"),
|
||||
data.getInteger("dim"),
|
||||
ForgeDirection.getOrientation(data.getInteger("side")),
|
||||
data.getString("name"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user