Merge pull request #74 from asdflj/wireless

Wireless
This commit is contained in:
Yang Xizhi authored and GitHub committed 2023-02-05 15:34:36 +08:00
commit 66ac56434a
15 files changed
+231 -100

No files matched your search

+2 -1
View File
@@ -5,7 +5,8 @@ dependencies {
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-149-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.25:dev') { transitive = false }
compile('com.github.GTNewHorizons:CraftTweaker:3.2.11:dev')
compile('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.5.6:dev')
@@ -4,8 +4,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -24,6 +22,8 @@ import com.glodblock.github.client.me.EssentiaRepo;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.crossmod.thaumcraft.AspectRender;
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
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.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
@@ -1,10 +1,5 @@
package com.glodblock.github.client.gui;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -15,10 +10,13 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
@@ -3,9 +3,6 @@ package com.glodblock.github.client.gui;
import java.text.NumberFormat;
import java.util.*;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -26,10 +23,13 @@ import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.coremod.hooker.CoreModHooks;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
@@ -1,7 +1,5 @@
package com.glodblock.github.client.gui;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -18,6 +16,8 @@ import appeng.core.sync.packets.PacketInventoryAction;
import appeng.helpers.InventoryAction;
import com.glodblock.github.client.gui.container.ContainerCraftingWireless;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
public class GuiFluidCraftingWireless extends GuiItemMonitor {
@@ -44,7 +44,10 @@ public class GuiFluidCraftingWireless extends GuiItemMonitor {
}
}
if (s != null) {
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0);
final PacketInventoryAction p = new PacketInventoryAction(
InventoryAction.MOVE_REGION,
s.slotNumber,
0);
NetworkHandler.instance.sendToServer(p);
}
}
@@ -1,7 +1,5 @@
package com.glodblock.github.client.gui;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -10,11 +8,13 @@ import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
@@ -56,8 +56,8 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host))
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof WirelessFluidTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
@@ -1,8 +1,5 @@
package com.glodblock.github.client.gui;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -13,9 +10,12 @@ import appeng.core.localization.GuiText;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.base.FCGuiAmount;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketPatternValueSet;
@@ -49,8 +49,10 @@ import codechicken.nei.LayoutManager;
import codechicken.nei.util.TextHistory;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.FCGuiTextField;
import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
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;
@@ -85,6 +87,11 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
protected GuiImgButton searchBoxSettings;
protected GuiImgButton terminalStyleBox;
protected GuiImgButton searchStringSave;
protected GuiFCImgButton FluidTerminal;
protected GuiFCImgButton CraftingTerminal;
protected GuiFCImgButton PatternTerminal;
protected GuiFCImgButton EssentiaTerminal;
protected boolean drawSwitchGuiBtn;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -97,6 +104,8 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCContainerMonitor<T>) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
if (inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
this.drawSwitchGuiBtn = true;
}
public abstract void postUpdate(final List<T> list);
@@ -114,7 +123,17 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if (btn instanceof GuiFCImgButton) {
if (btn == this.FluidTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_TERMINAL);
} else if (btn == this.CraftingTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_CRAFTING_TERMINAL);
} else if (btn == this.EssentiaTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_ESSENTIA_TERMINAL);
} else if (btn == this.PatternTerminal) {
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
}
}
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
@@ -323,6 +342,51 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
if (drawSwitchGuiBtn) drawSwitchGuiBtns();
}
private void drawSwitchGuiBtns() {
if (!(this instanceof GuiFluidCraftingWireless)) {
this.buttonList.add(
this.CraftingTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"CRAFT_TEM",
"YES",
false));
this.offsetY += 20;
}
if (!(this instanceof GuiFluidPatternWireless)) {
this.buttonList.add(
this.PatternTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"PATTERN_TEM",
"YES",
false));
this.offsetY += 20;
}
if (!(this instanceof GuiFluidPortableCell)) {
this.buttonList.add(
this.FluidTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"FLUID_TEM",
"YES",
false));
this.offsetY += 20;
}
if (!(this instanceof GuiEssentiaTerminal)) {
this.buttonList.add(
this.EssentiaTerminal = new GuiFCImgButton(
this.guiLeft - 18,
this.offsetY,
"ESSENTIA_TEM",
"YES",
false));
this.offsetY += 20;
}
}
public void setSearchString(String memoryText, boolean updateView) {
@@ -79,19 +79,21 @@ public abstract class FCContainerMonitor<T extends IAEStack<T>> extends AEBaseCo
if (isInvalid()) {
this.setValidContainer(false);
}
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (this.serverCM != null) {
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()),
(EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()),
(EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
@@ -1,15 +1,17 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import com.glodblock.github.util.ModAndClassUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.networking.IGridNode;
@@ -19,11 +21,15 @@ import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.IRegister;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
@@ -63,17 +69,17 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines,
boolean displayMoreInfo) {
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
if (isShiftKeyDown()) {
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
} else {
lines.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return StatCollector.translateToLocalFormatted(
"item.wireless_ultra_terminal." +
guiGuiType(stack) +
".name"
);
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + guiGuiType(stack) + ".name");
}
@Override
@@ -140,6 +146,31 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
data.setString(MODE, mode);
}
public void setMode(GuiType mode, ItemStack stack) {
this.setMode(mode.toString(), stack);
}
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());
}
if (Platform.isClient()) {
player.closeScreen();
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
} else {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
guiType);
}
}
@Override
public GuiType guiGuiType(ItemStack stack) {
return readMode(stack);
@@ -1,14 +1,17 @@
package com.glodblock.github.inventory.item;
import net.minecraft.item.ItemStack;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.api.implementations.tiles.IViewCellStorage;
import appeng.api.networking.IGridHost;
import appeng.api.networking.security.IActionHost;
import appeng.tile.inventory.IAEAppEngInventory;
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import net.minecraft.item.ItemStack;
public interface IWirelessTerminal extends IFluidPortableCell, IViewCellStorage, IAEAppEngInventory, IGridHost, IActionHost {
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
public interface IWirelessTerminal
extends IFluidPortableCell, IViewCellStorage, IAEAppEngInventory, IGridHost, IActionHost {
default boolean isUniversal(Object holder) {
if (holder instanceof IGuiItemObject) {
@@ -4,6 +4,7 @@ import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
@@ -16,6 +17,10 @@ public class NEI_FC_Config implements IConfigureNEI {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
for (String identifier : FluidRecipe.getSupportRecipes()) {
API.registerGuiOverlayHandler(
GuiFluidCraftingWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
identifier);
API.registerGuiOverlayHandler(
GuiFluidPatternWireless.class,
FluidPatternTerminalRecipeTransferHandler.INSTANCE,
@@ -92,18 +92,18 @@ public class CPacketCraftRequest implements IMessage {
final TileEntity te = context.getTile();
if (te != null) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM);
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM);
} else {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
player,
player.worldObj,
new BlockPos(player.inventory.currentItem, 0, 0),
Objects.requireNonNull(context.getSide()),
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
}
if (player.openContainer instanceof ContainerFluidCraftConfirm) {
@@ -5,7 +5,6 @@ import java.util.Objects;
import javax.annotation.Nullable;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -24,6 +23,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.util.BlockPos;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
@@ -100,18 +100,21 @@ public class CPacketInventoryAction implements IMessage {
final TileEntity te = context.getTile();
if (te != null) {
InventoryHandler.openGui(
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.FLUID_CRAFTING_AMOUNT);
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.FLUID_CRAFTING_AMOUNT);
} else {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(sender.inventory.currentItem, Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM), 0),
ForgeDirection.UNKNOWN,
GuiType.FLUID_CRAFTING_AMOUNT);
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
GuiType.FLUID_CRAFTING_AMOUNT);
}
if (sender.openContainer instanceof ContainerCraftAmount) {
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
@@ -128,18 +131,21 @@ public class CPacketInventoryAction implements IMessage {
final TileEntity te = context.getTile();
if (te != null) {
InventoryHandler.openGui(
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.PATTERN_VALUE_SET);
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
GuiType.PATTERN_VALUE_SET);
} else {
InventoryHandler.openGui(
sender,
sender.worldObj,
new BlockPos(sender.inventory.currentItem, Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM), 0),
ForgeDirection.UNKNOWN,
GuiType.PATTERN_VALUE_SET);
sender,
sender.worldObj,
new BlockPos(
sender.inventory.currentItem,
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
ForgeDirection.UNKNOWN,
GuiType.PATTERN_VALUE_SET);
}
int amt = (int) message.stack.getStackSize();
if (message.stack.getItem() instanceof ItemFluidPacket) {
@@ -11,6 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import appeng.container.AEBaseContainer;
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.util.BlockPos;
@@ -24,9 +25,15 @@ import io.netty.buffer.ByteBuf;
public class CPacketSwitchGuis implements IMessage {
private GuiType guiType;
private boolean switchTerminal;
public CPacketSwitchGuis(GuiType guiType) {
this(guiType, false);
}
public CPacketSwitchGuis(GuiType guiType, boolean switchTerminal) {
this.guiType = guiType;
this.switchTerminal = switchTerminal;
}
public CPacketSwitchGuis() {
@@ -36,11 +43,13 @@ public class CPacketSwitchGuis implements IMessage {
@Override
public void fromBytes(ByteBuf byteBuf) {
guiType = GuiType.getByOrdinal(byteBuf.readByte());
switchTerminal = byteBuf.readBoolean();
}
@Override
public void toBytes(ByteBuf byteBuf) {
byteBuf.writeByte(guiType != null ? guiType.ordinal() : 0);
byteBuf.writeBoolean(this.switchTerminal);
}
public static class Handler implements IMessageHandler<CPacketSwitchGuis, IMessage> {
@@ -51,35 +60,44 @@ public class CPacketSwitchGuis implements IMessage {
if (message.guiType == null) {
return null;
}
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
Container cont = player.openContainer;
if (!(cont instanceof AEBaseContainer)) {
// switch terminal
if (message.switchTerminal) {
ItemWirelessUltraTerminal.switchTerminal(player, message.guiType);
return null;
}
ContainerOpenContext context = ((AEBaseContainer) cont).getOpenContext();
if (context == null) {
return null;
}
TileEntity te = context.getTile();
if (te != null) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
message.guiType);
} else {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
Objects.requireNonNull(context.getSide()),
message.guiType);
// open new terminal
if (cont instanceof AEBaseContainer) {
ContainerOpenContext context = ((AEBaseContainer) cont).getOpenContext();
if (context == null) {
return null;
}
TileEntity te = context.getTile();
if (te != null) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(context.getSide()),
message.guiType);
} else {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(
player.inventory.currentItem,
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
0),
Objects.requireNonNull(context.getSide()),
message.guiType);
}
}
return null;
}
}
}