mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-18 03:15:26 +00:00
save
This commit is contained in:
1 parent
be7b8d684e
commit
7c567e0c38
11 files changed
+159
-498
No files matched your search
@@ -1,108 +0,0 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.client.gui.base.FCGuiAmount;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
public class GuiFCPriority extends FCGuiAmount {
|
||||
|
||||
public GuiFCPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) {
|
||||
super(new ContainerPriority(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.submit.enabled = false;
|
||||
this.submit.visible = false;
|
||||
this.buttonList.remove(this.submit);
|
||||
((ContainerPriority) this.inventorySlots).setTextField(this.amountBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIncrementQuantity(int i) {
|
||||
return AEConfig.instance.priorityByStacksAmounts(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.amountBox.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addQty(final int i) {
|
||||
try {
|
||||
this.amountBox.setText(Long.toString(getAmount() + i));
|
||||
this.amountBox.setCursorPositionEnd();
|
||||
} catch (final NumberFormatException ignore) {}
|
||||
try {
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof IDualHost) {
|
||||
this.myIcon = ItemAndBlockHolder.INTERFACE.stack();
|
||||
this.originalGui = GuiType.DUAL_INTERFACE;
|
||||
} else if (target instanceof PartFluidStorageBus) {
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
|
||||
this.originalGui = GuiType.FLUID_STORAGE_BUS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
super.keyTyped(character, key);
|
||||
try {
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketValueConfig("PriorityHost.Priority", String.valueOf(getAmount())));
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getAmount() {
|
||||
try {
|
||||
String out = this.amountBox.getText();
|
||||
double result = Calculator.conversion(out);
|
||||
if (Double.isNaN(result)) {
|
||||
return 0;
|
||||
} else {
|
||||
return (int) ArithHelper.round(result, 0);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/priority.png";
|
||||
}
|
||||
}
|
||||
@@ -190,11 +190,9 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
} else if (btn == this.LevelTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
} else if (btn == this.magnetOff || btn == this.magnetME || btn == this.magnetInv) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketFluidPatternTermBtns("WirelessTerminal.MagnetMode", this.getMagnetMode().ordinal()));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.MagnetMode", this.getMagnetMode().ordinal()));
|
||||
} else if (btn == this.magnetFilter) {
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.OpenMagnet", 0));
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.OpenMagnet", 0));
|
||||
} else if (btn == this.restockDisableBtn || btn == this.restockEnableBtn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("WirelessTerminal.Stock", 1));
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
package com.glodblock.github.client.gui.base;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
public abstract class FCGuiAmount extends AEBaseGui {
|
||||
|
||||
protected MEGuiTextField amountBox;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
protected GuiButton submit;
|
||||
protected GuiButton plus1;
|
||||
protected GuiButton plus10;
|
||||
protected GuiButton plus100;
|
||||
protected GuiButton plus1000;
|
||||
protected GuiButton minus1;
|
||||
protected GuiButton minus10;
|
||||
protected GuiButton minus100;
|
||||
protected GuiButton minus1000;
|
||||
protected GuiType originalGui;
|
||||
protected ItemStack myIcon;
|
||||
|
||||
public FCGuiAmount(Container container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final int a = getIncrementQuantity(0);
|
||||
final int b = getIncrementQuantity(1);
|
||||
final int c = getIncrementQuantity(2);
|
||||
final int d = getIncrementQuantity(3);
|
||||
|
||||
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
|
||||
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
|
||||
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
|
||||
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
|
||||
|
||||
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
|
||||
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
|
||||
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
|
||||
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
|
||||
|
||||
this.buttonList.add(
|
||||
this.submit = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
|
||||
setOriginGUI(((AEBaseContainer) this.inventorySlots).getTarget());
|
||||
if (this.originalGui != null && this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
|
||||
this.amountBox = new MEGuiTextField(61, 12);
|
||||
this.amountBox.x = this.guiLeft + 60;
|
||||
this.amountBox.y = this.guiTop + 55;
|
||||
this.amountBox.setMaxStringLength(16);
|
||||
this.amountBox.setFocused(true);
|
||||
}
|
||||
|
||||
protected int getIncrementQuantity(int i) {
|
||||
return AEConfig.instance.craftItemsByStackAmounts(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.bindTexture(getBackground());
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
|
||||
this.actionPerformed(this.submit);
|
||||
}
|
||||
this.amountBox.textboxKeyTyped(character, key);
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|
||||
|| btn == this.minus100
|
||||
|| btn == this.minus1000;
|
||||
|
||||
if (isPlus || isMinus) {
|
||||
this.addQty(this.getQty(btn));
|
||||
}
|
||||
}
|
||||
|
||||
protected void addQty(final int i) {
|
||||
try {
|
||||
long resultI = getAmount();
|
||||
if (resultI == 1 && i > 1) {
|
||||
resultI = 0;
|
||||
}
|
||||
resultI += i;
|
||||
if (resultI < 1) {
|
||||
resultI = 1;
|
||||
}
|
||||
String out = Long.toString(resultI);
|
||||
this.amountBox.setText(out);
|
||||
this.amountBox.setCursorPositionEnd();
|
||||
} catch (final NumberFormatException ignore) {}
|
||||
}
|
||||
|
||||
protected abstract void setOriginGUI(Object target);
|
||||
|
||||
protected abstract String getBackground();
|
||||
|
||||
protected int getAmount() {
|
||||
try {
|
||||
String out = this.amountBox.getText();
|
||||
double result = Calculator.conversion(out);
|
||||
if (result <= 0 || Double.isNaN(result)) {
|
||||
return 0;
|
||||
} else {
|
||||
return (int) ArithHelper.round(result, 0);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.Platform.openGUI;
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.MODE;
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
|
||||
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
|
||||
@@ -7,8 +9,13 @@ import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.helpers.WirelessPatternTerminalGuiObject;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -32,8 +39,9 @@ import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory {
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory, IGuiItem {
|
||||
|
||||
protected Object type;
|
||||
public static String infinityBoosterCard = "infinityBoosterCard";
|
||||
@@ -50,38 +58,30 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
|
||||
// terminal
|
||||
if (ForgeEventFactory.onItemUseStart(player, item, 1) > 0) {
|
||||
if (Platform.isClient()) {
|
||||
return item;
|
||||
}
|
||||
if (Platform.isClient()) return item;
|
||||
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.toChat());
|
||||
return item;
|
||||
}
|
||||
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
Object gui = this.guiGuiType(item);
|
||||
if (gui instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
gt);
|
||||
} else if (gui instanceof GuiBridge gb) {
|
||||
Platform.openGUI(player, null, null, GuiBridge.GUI_PATTERN_TERMINAL);
|
||||
}
|
||||
openGui(item, w, player);
|
||||
} else {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.toChat());
|
||||
}
|
||||
@@ -135,12 +135,55 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object guiGuiType(ItemStack stack) {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public static void toggleRestockItemsMode(ItemStack is, boolean state) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(restockItems, state);
|
||||
}
|
||||
|
||||
public static UltraTerminalModes getMode(ItemStack is) {
|
||||
Item item = is.getItem();
|
||||
if (item instanceof ItemWirelessUltraTerminal) {
|
||||
return UltraTerminalModes.values()[is.getTagCompound().getInteger(MODE)];
|
||||
} else if (item instanceof ItemWirelessPatternTerminal) {
|
||||
return UltraTerminalModes.PATTERN;
|
||||
} else if (item instanceof ItemWirelessInterfaceTerminal) {
|
||||
return UltraTerminalModes.INTERFACE;
|
||||
} else if (item instanceof ItemWirelessLevelTerminal) {
|
||||
return UltraTerminalModes.LEVEL;
|
||||
} else {
|
||||
return UltraTerminalModes.INTERFACE; // any wireless gui object will fit
|
||||
}
|
||||
}
|
||||
|
||||
public static void setMode(ItemStack is, UltraTerminalModes utm) {
|
||||
is.getTagCompound().setInteger(MODE, utm.ordinal());
|
||||
}
|
||||
|
||||
public static void openGui(final ItemStack is, final World w, final EntityPlayer player) {
|
||||
final GuiBridge aeGui;
|
||||
switch (getMode(is)) {
|
||||
case CRAFTING -> aeGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
case PATTERN -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
case PATTERN_EX -> aeGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
case INTERFACE -> aeGui = GuiBridge.GUI_INTERFACE_TERMINAL;
|
||||
case LEVEL -> {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
return;
|
||||
}
|
||||
default -> aeGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
Platform.openGUI(player, null,null, aeGui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessTerminalGuiObject(wh, is, world.getClosestPlayer(x, y, z, 1), world, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,11 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.helpers.WirelessInterfaceTerminalGuiObject;
|
||||
import appeng.helpers.WirelessPatternTerminalGuiObject;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -39,13 +44,9 @@ public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
return null;
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessInterfaceTerminalGuiObject(wh, is);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -2,6 +2,12 @@ package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.helpers.WirelessInterfaceTerminalGuiObject;
|
||||
import appeng.helpers.WirelessPatternTerminalGuiObject;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -38,13 +44,9 @@ public class ItemWirelessPatternTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
// return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
return null;
|
||||
public IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(is);
|
||||
if (wh == null) return null;
|
||||
return new WirelessPatternTerminalGuiObject(wh, is, world.getClosestPlayer(x, y, z, 1), world, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.Platform.nextEnum;
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -7,6 +8,11 @@ import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnetCardFilterInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
|
||||
import com.glodblock.github.util.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -26,10 +32,6 @@ import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
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;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
@@ -49,12 +51,9 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles")
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
implements IBauble, IRegister<ItemWirelessUltraTerminal>, IGuiItem {
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal implements IRegister<ItemWirelessUltraTerminal>, IGuiItem {
|
||||
|
||||
public final static String MODE = "mode_main";
|
||||
private final static List<Object> guis = new ArrayList<>();
|
||||
public final static String MODE = "mode";
|
||||
|
||||
public ItemWirelessUltraTerminal() {
|
||||
super(null);
|
||||
@@ -62,14 +61,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL).toString());
|
||||
guis.add(GuiBridge.GUI_CRAFTING_TERMINAL);
|
||||
guis.add(GuiBridge.GUI_PATTERN_TERMINAL);
|
||||
guis.add(GuiBridge.GUI_PATTERN_TERMINAL_EX);
|
||||
guis.add(GuiBridge.GUI_INTERFACE_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
if (ModAndClassUtil.ThE) {
|
||||
// guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +77,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
|
||||
if (isShiftKeyDown()) {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL));
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + guiGuiType(stack)));
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_ULTRA_TERMINAL + "." + getMode(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 {
|
||||
@@ -96,37 +87,22 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + guiGuiType(stack) + ".name");
|
||||
return StatCollector.translateToLocalFormatted("item.wireless_ultra_terminal." + getMode(stack) + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
final Object gui;
|
||||
final IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
|
||||
//wireless magnet
|
||||
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z == -1) {
|
||||
gui = GuiType.WIRELESS_MAGNET_FILTER;
|
||||
} else if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
|
||||
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
|
||||
} else {
|
||||
gui = readMode(stack);
|
||||
return new WirelessMagnetCardFilterInventory(stack, x, gridNode, player);
|
||||
}
|
||||
|
||||
if (getMode(stack) == UltraTerminalModes.LEVEL) {
|
||||
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
/*
|
||||
* if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) { return new WirelessPatternTerminalInventory(stack,
|
||||
* x, gridNode, player); } else if (gui == GuiType.WIRELESS_CRAFTING_TERMINAL) { return new
|
||||
* WirelessCraftingTerminalInventory(stack, x, gridNode, player); } else if (ModAndClassUtil.ThE && gui ==
|
||||
* GuiType.WIRELESS_ESSENTIA_TERMINAL) { return new WirelessFluidTerminalInventory(stack, x, gridNode,
|
||||
* player); } else if (gui == GuiType.WIRELESS_FLUID_TERMINAL) { return new
|
||||
* WirelessFluidTerminalInventory(stack, x, gridNode, player); } else if (gui ==
|
||||
* GuiType.WIRELESS_INTERFACE_TERMINAL) { return new WirelessInterfaceTerminalInventory(stack, x, gridNode,
|
||||
* player); } else if (gui == GuiType.WIRELESS_LEVEL_TERMINAL) { return new
|
||||
* WirelessLevelTerminalInventory(stack, x, gridNode, player); } else if (gui ==
|
||||
* GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX) { return new WirelessPatternTerminalExInventory(stack, x,
|
||||
* gridNode, player); } else if (gui == GuiType.WIRELESS_MAGNET_FILTER) { return new
|
||||
* WirelessMagnetCardFilterInventory(stack, x, gridNode, player); } else {
|
||||
* this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode return new
|
||||
* WirelessFluidTerminalInventory(stack, x, gridNode, player); }
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
@@ -134,76 +110,24 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
public ItemStack onItemRightClick(final ItemStack is, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
setNext(readMode(item), item);
|
||||
return item;
|
||||
setMode(is, nextEnum(getMode(is)));
|
||||
return is;
|
||||
}
|
||||
readMode(item);
|
||||
return super.onItemRightClick(item, w, player);
|
||||
return super.onItemRightClick(is, w, player);
|
||||
}
|
||||
|
||||
public static Object readMode(ItemStack stack) {
|
||||
NBTTagCompound data = Platform.openNbtData(stack);
|
||||
if (data.hasKey(MODE)) {
|
||||
String GUI = data.getString(MODE);
|
||||
try {
|
||||
return GuiType.valueOf(GUI);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
} else {
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
}
|
||||
public static void switchTerminal(EntityPlayer player, UltraTerminalModes mode) {
|
||||
ImmutablePair<Integer, ItemStack> temp = Util.getUltraWirelessTerm(player);
|
||||
if (temp == null) return;
|
||||
ItemStack term = temp.getRight();
|
||||
if (term != null && term.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
if (mode != null) setMode(term, mode);
|
||||
else mode = getMode(term);
|
||||
|
||||
public void setNext(Object type, ItemStack stack) {
|
||||
boolean f = false;
|
||||
for (Object g : guis) {
|
||||
if (f) {
|
||||
setMode(g.toString(), stack);
|
||||
return;
|
||||
}
|
||||
if (g == type) {
|
||||
f = true;
|
||||
}
|
||||
}
|
||||
setMode(guis.get(0).toString(), stack);
|
||||
}
|
||||
|
||||
public void setMode(String mode, ItemStack stack) {
|
||||
NBTTagCompound data = Platform.openNbtData(stack);
|
||||
data.setString(MODE, mode);
|
||||
}
|
||||
|
||||
public void setMode(Object mode, ItemStack stack) {
|
||||
this.setMode(mode.toString(), stack);
|
||||
}
|
||||
|
||||
public static void switchTerminal(EntityPlayer player, Object guiType) {
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term == null) return;
|
||||
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
|
||||
} else {
|
||||
if (guiType instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
term.getLeft(),
|
||||
Util.GuiHelper.encodeType(
|
||||
guis.indexOf(GuiType.valueOf(guiType.toString())),
|
||||
Util.GuiHelper.GuiType.ITEM),
|
||||
1),
|
||||
ForgeDirection.UNKNOWN,
|
||||
gt);
|
||||
} else if (guiType instanceof GuiBridge gb) {
|
||||
Platform.openGUI(player, null, null, GuiBridge.GUI_PATTERN_TERMINAL);
|
||||
}
|
||||
if (Platform.isClient()) FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(mode, true));
|
||||
else openGui(term, player.worldObj, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,20 +140,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<Object> getGuis() {
|
||||
return guis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object guiGuiType(ItemStack stack) {
|
||||
return readMode(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
if (Platform.isServer() && entityLivingBase instanceof EntityPlayer player) {
|
||||
@@ -249,26 +159,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean p_77663_5_) {
|
||||
if (entityIn instanceof EntityPlayer player) {
|
||||
|
||||
@@ -20,6 +20,9 @@ import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.getMode;
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.switchTerminal;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class KeybindLoader implements Runnable {
|
||||
|
||||
@@ -58,16 +61,7 @@ public class KeybindLoader implements Runnable {
|
||||
private void handleOpenTerminalKey() {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.openContainer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term != null && term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(
|
||||
player,
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
|
||||
}
|
||||
if (player.openContainer != null) switchTerminal(player, null);
|
||||
}
|
||||
|
||||
private void handleRestockKey() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.glodblock.github.util.UltraTerminalModes;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,17 +25,19 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.switchTerminal;
|
||||
|
||||
public class CPacketSwitchGuis implements IMessage {
|
||||
|
||||
private Object guiType;
|
||||
private UltraTerminalModes mode;
|
||||
private boolean switchTerminal;
|
||||
|
||||
public CPacketSwitchGuis(Object guiType) {
|
||||
this(guiType, false);
|
||||
public CPacketSwitchGuis(UltraTerminalModes mode) {
|
||||
this(mode, false);
|
||||
}
|
||||
|
||||
public CPacketSwitchGuis(Object guiType, boolean switchTerminal) {
|
||||
this.guiType = guiType;
|
||||
public CPacketSwitchGuis(UltraTerminalModes mode, boolean switchTerminal) {
|
||||
this.mode = mode;
|
||||
this.switchTerminal = switchTerminal;
|
||||
}
|
||||
|
||||
@@ -44,25 +47,13 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
switch (byteBuf.readByte()) {
|
||||
case 0 -> {
|
||||
guiType = GuiType.getByOrdinal(byteBuf.readByte());
|
||||
}
|
||||
case 1 -> {
|
||||
guiType = GuiBridge.values()[(byteBuf.readByte())];
|
||||
}
|
||||
}
|
||||
mode = UltraTerminalModes.values()[byteBuf.readInt()];
|
||||
switchTerminal = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
if (guiType instanceof GuiType) {
|
||||
byteBuf.writeByte(0);
|
||||
} else if (guiType instanceof GuiBridge) {
|
||||
byteBuf.writeByte(1);
|
||||
}
|
||||
byteBuf.writeByte(guiType != null ? ((Enum<?>) guiType).ordinal() : 0);
|
||||
byteBuf.writeInt(mode.ordinal());
|
||||
byteBuf.writeBoolean(this.switchTerminal);
|
||||
}
|
||||
|
||||
@@ -71,50 +62,41 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSwitchGuis message, MessageContext ctx) {
|
||||
if (message.guiType == null) {
|
||||
return null;
|
||||
}
|
||||
if (message.mode == null) return null;
|
||||
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container cont = player.openContainer;
|
||||
|
||||
// switch terminal
|
||||
if (message.switchTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(player, message.guiType);
|
||||
return null;
|
||||
}
|
||||
|
||||
// open new terminal
|
||||
if (cont instanceof AEBaseContainer) {
|
||||
ContainerOpenContext context = ((AEBaseContainer) cont).getOpenContext();
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
TileEntity te = context.getTile();
|
||||
if (te != null) {
|
||||
if (message.guiType instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
if (message.switchTerminal) switchTerminal(player, message.mode);
|
||||
else {
|
||||
// open new terminal //TODO in world stuff
|
||||
if (cont instanceof AEBaseContainer aeBaseContainer) {
|
||||
ContainerOpenContext context = aeBaseContainer.getOpenContext();
|
||||
if (context == null) return null;
|
||||
TileEntity te = context.getTile();
|
||||
Object guiType = GuiType.GUI_SUPER_STOCK_REPLENISHER;
|
||||
if (te != null) {
|
||||
if (guiType instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
gt);
|
||||
} else if (message.guiType instanceof GuiBridge gb) {
|
||||
Platform.openGUI(player, te, context.getSide(), gb);
|
||||
}
|
||||
} else if (((AEBaseContainer) cont).getTarget() instanceof IWirelessTerminal) {
|
||||
if (message.guiType instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
} else if (guiType instanceof GuiBridge gb) Platform.openGUI(player, te, context.getSide(), gb);
|
||||
} else if (aeBaseContainer.getTarget() instanceof IWirelessTerminal wt) {
|
||||
if (guiType instanceof GuiType gt) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
((IWirelessTerminal) ((AEBaseContainer) cont).getTarget()).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
wt.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
gt);
|
||||
} else if (message.guiType instanceof GuiBridge gb) {
|
||||
Platform.openGUI(player, null, null, gb);
|
||||
} else if (guiType instanceof GuiBridge gb) Platform.openGUI(player, null, null, gb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
public enum UltraTerminalModes {
|
||||
ME,
|
||||
CRAFTING,
|
||||
PATTERN,
|
||||
PATTERN_EX,
|
||||
INTERFACE,
|
||||
LEVEL
|
||||
}
|
||||
Reference in new issue
Block a user