This commit is contained in:
asdflj committed 2023-02-05 15:06:06 +08:00
1 parent 1bbc575f6e
commit f81fab984a
4 files changed
+157 -39

No files matched your search

@@ -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 drawSwitchGuiIcon = true;
@SuppressWarnings("unchecked")
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
@@ -114,7 +121,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 +340,52 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
craftingGridOffsetX -= 25;
craftingGridOffsetY -= 6;
if (drawSwitchGuiIcon) drawSwitchGuiBtn();
}
private void drawSwitchGuiBtn() {
if (this.mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal) {
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,5 +1,7 @@
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;
@@ -9,6 +11,7 @@ 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;
@@ -18,11 +21,14 @@ 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,8 +69,12 @@ 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
@@ -136,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);
@@ -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;
}
}
}