mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
feat: Add new item LevelTerminal
This commit is contained in:
31 files changed
+2987
-52
No files matched your search
@@ -59,6 +59,13 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
|
||||
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
|
||||
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
|
||||
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
|
||||
this.registerApp(21, "SWITCH", "ON", "edit");
|
||||
this.registerApp(22, "SWITCH", "OFF", "view");
|
||||
this.registerApp(21, "SWITCH", "ENABLE", "enable");
|
||||
this.registerApp(22, "SWITCH", "DISABLE", "disable");
|
||||
this.registerApp(23, "CONFIG", "YES", "open_configuration");
|
||||
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +117,10 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
public boolean getMouseIn() {
|
||||
return this.field_146123_n;
|
||||
}
|
||||
|
||||
public void set(final String e) {
|
||||
if (!this.currentValue.equals(e)) {
|
||||
this.currentValue = e;
|
||||
|
||||
+5
-5
@@ -57,7 +57,7 @@ import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
|
||||
public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillTextField {
|
||||
|
||||
protected int offsetY;
|
||||
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
|
||||
@@ -93,7 +93,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
|
||||
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
|
||||
|
||||
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
public GuiInterfaceWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
|
||||
|
||||
this.setScrollBar(new GuiScrollbar());
|
||||
@@ -248,7 +248,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
GuiColors.InterfaceTerminalTitle.getColor());
|
||||
fontRendererObj.drawString(
|
||||
GuiText.inventory.getLocal(),
|
||||
GuiInterfaceTerminalWireless.offsetX + 2,
|
||||
GuiInterfaceWireless.offsetX + 2,
|
||||
this.ySize - 96,
|
||||
GuiColors.InterfaceTerminalInventory.getColor());
|
||||
|
||||
@@ -279,7 +279,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
|
||||
this.fontRendererObj.drawString(
|
||||
name + postfix,
|
||||
GuiInterfaceTerminalWireless.offsetX + 3,
|
||||
GuiInterfaceWireless.offsetX + 3,
|
||||
6 + offset,
|
||||
GuiColors.InterfaceTerminalName.getColor());
|
||||
}
|
||||
@@ -288,6 +288,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
@@ -383,7 +384,6 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo
|
||||
blockPos.getDimension(),
|
||||
blockPos.getSide()));
|
||||
} else {
|
||||
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
(int) mc.thePlayer.posX,
|
||||
(int) mc.thePlayer.posY,
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,24 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
|
||||
public class GuiLevelWireless extends GuiLevelTerminal {
|
||||
|
||||
public GuiLevelWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, new ContainerLevelWireless(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlots() {
|
||||
for (final Object obj : this.inventorySlots.inventorySlots) {
|
||||
if (obj instanceof final AppEngSlot slot) {
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ import com.glodblock.github.client.gui.GuiFluidCraftingWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPortableCell;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceWireless;
|
||||
import com.glodblock.github.client.gui.GuiLevelWireless;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
@@ -29,7 +30,8 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
protected GuiFCImgButton PatternTerminal;
|
||||
protected GuiFCImgButton EssentiaTerminal;
|
||||
protected GuiFCImgButton InterfaceTerminal;
|
||||
protected GuiFCImgButton PatternTerminaleEx;
|
||||
protected GuiFCImgButton LevelTerminal;
|
||||
protected GuiFCImgButton PatternTerminalEx;
|
||||
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
|
||||
protected boolean drawSwitchGuiBtn;
|
||||
|
||||
@@ -87,13 +89,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
}
|
||||
if (!(this instanceof GuiFluidPatternExWireless)) {
|
||||
this.buttonList.add(
|
||||
this.PatternTerminaleEx = new GuiFCImgButton(
|
||||
this.PatternTerminalEx = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"PATTERN_EX_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.PatternTerminaleEx);
|
||||
termBtns.add(this.PatternTerminalEx);
|
||||
}
|
||||
if (!(this instanceof GuiFluidPortableCell)) {
|
||||
this.buttonList.add(
|
||||
@@ -101,7 +103,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.FluidTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiInterfaceTerminalWireless)) {
|
||||
if (!(this instanceof GuiInterfaceWireless)) {
|
||||
this.buttonList.add(
|
||||
this.InterfaceTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
@@ -111,6 +113,12 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.InterfaceTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiLevelWireless)) {
|
||||
this.buttonList.add(
|
||||
this.LevelTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "LEVEL_TEM", "YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.LevelTerminal);
|
||||
}
|
||||
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
|
||||
this.buttonList.add(
|
||||
this.EssentiaTerminal = new GuiFCImgButton(
|
||||
@@ -123,6 +131,7 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
this.buttonList.addAll(termBtns);
|
||||
@@ -141,7 +150,9 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
} else if (btn == this.InterfaceTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
} else if (btn == this.PatternTerminaleEx) {
|
||||
} else if (btn == this.LevelTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
} else if (btn == this.PatternTerminalEx) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
|
||||
public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
|
||||
/**
|
||||
* this stuff is all server side
|
||||
*/
|
||||
private int nextId = 0;
|
||||
|
||||
private final Map<ILevelViewable, ContainerLevelTerminal.InvTracker> tracked = new HashMap<>();
|
||||
private final Map<Long, ContainerLevelTerminal.InvTracker> trackedById = new HashMap<>();
|
||||
|
||||
private IGrid grid;
|
||||
private SPacketLevelTerminalUpdate dirty;
|
||||
private boolean isDirty;
|
||||
private boolean wasOff;
|
||||
private int ticks = 0;
|
||||
|
||||
public ContainerLevelTerminal(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
if (Platform.isServer()) {
|
||||
if (monitorable instanceof PartLevelTerminal terminal) {
|
||||
grid = terminal.getActionableNode().getGrid();
|
||||
} else if (monitorable instanceof IWirelessTerminal wirelessTerminal) {
|
||||
grid = wirelessTerminal.getActionableNode().getGrid();
|
||||
}
|
||||
dirty = this.updateList();
|
||||
if (dirty != null) {
|
||||
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) ip.player);
|
||||
this.isDirty = true;
|
||||
} else {
|
||||
dirty = new SPacketLevelTerminalUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
|
||||
if (!host.getActionableNode().isActive()) {
|
||||
if (!wasOff) {
|
||||
SPacketLevelTerminalUpdate update = new SPacketLevelTerminalUpdate();
|
||||
|
||||
update.setDisconnect();
|
||||
wasOff = true;
|
||||
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
wasOff = false;
|
||||
|
||||
if (isDirty) {
|
||||
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
dirty = new SPacketLevelTerminalUpdate();
|
||||
isDirty = false;
|
||||
} else if (++ticks % 20 == 0) {
|
||||
ticks = 0;
|
||||
SPacketLevelTerminalUpdate update = this.updateList();
|
||||
if (update != null) {
|
||||
FluidCraft.proxy.netHandler.sendTo(update, (EntityPlayerMP) this.getPlayerInv().player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge from slot -> player inv. Returns the items not added.
|
||||
*/
|
||||
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack) {
|
||||
if (stack == null) return null;
|
||||
for (ItemSlot slot : playerInv) {
|
||||
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
|
||||
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
|
||||
++slot.getItemStack().stackSize;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return playerInv.addItems(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slotIdx, final long id) {
|
||||
final ContainerLevelTerminal.InvTracker invTracker = this.trackedById.get(id);
|
||||
if (invTracker != null) {
|
||||
final ItemStack handStack = player.inventory.getItemStack();
|
||||
|
||||
if (handStack != null && !(handStack.getItem() instanceof ItemEncodedPattern)) {
|
||||
// Why even bother if we're not dealing with an encoded pattern in hand
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack slotStack = invTracker.requests.getStackInSlot(slotIdx);
|
||||
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
|
||||
|
||||
switch (action) {
|
||||
/* Set down/pickup. This is the same as SPLIT_OR_PLACE_SINGLE as our max stack sizes are 1 in slots. */
|
||||
case PICKUP_OR_SET_DOWN -> {
|
||||
if (handStack != null) {
|
||||
for (int s = 0; s < invTracker.requests.getSizeInventory(); s++) {
|
||||
/* Is there a duplicate pattern here? */
|
||||
if (Platform.isSameItemPrecise(invTracker.requests.getStackInSlot(s), handStack)) {
|
||||
/* We're done here - dupe found. */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slotStack == null) {
|
||||
/* Insert to container, if valid */
|
||||
if (handStack == null) {
|
||||
/* Nothing happens */
|
||||
return;
|
||||
}
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
|
||||
} else {
|
||||
/* Exchange? */
|
||||
if (handStack != null && handStack.stackSize > 1) {
|
||||
/* Exchange is impossible, abort */
|
||||
return;
|
||||
}
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, playerHand.removeItems(1, null, null));
|
||||
playerHand.addItems(slotStack.copy());
|
||||
}
|
||||
syncLevelTerminalSlot(invTracker, id, slotIdx, invTracker.requests.getStackInSlot(slotIdx));
|
||||
}
|
||||
/* Shift click from slotIdx -> player. Player -> slotIdx is not supported. */
|
||||
case SHIFT_CLICK -> {
|
||||
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player.inventory, ForgeDirection.UNKNOWN);
|
||||
ItemStack leftOver = mergeToPlayerInventory(playerInv, slotStack);
|
||||
|
||||
if (leftOver == null) {
|
||||
invTracker.requests.setInventorySlotContents(slotIdx, null);
|
||||
syncLevelTerminalSlot(invTracker, id, slotIdx, null);
|
||||
}
|
||||
}
|
||||
/* Move all blank patterns -> player */
|
||||
case MOVE_REGION -> {
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
List<Integer> valid = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < invTracker.requests.getSizeInventory(); i++) {
|
||||
ItemStack toExtract = invTracker.requests.getStackInSlot(i);
|
||||
|
||||
if (toExtract == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack leftOver = mergeToPlayerInventory(playerInv, toExtract);
|
||||
|
||||
if (leftOver != null) {
|
||||
break;
|
||||
} else {
|
||||
invTracker.requests.setInventorySlotContents(i, null);
|
||||
}
|
||||
valid.add(i);
|
||||
}
|
||||
if (valid.size() > 0) {
|
||||
int[] validIndices = Ints.toArray(valid);
|
||||
NBTTagList tag = new NBTTagList();
|
||||
for (int i = 0; i < valid.size(); ++i) {
|
||||
tag.appendTag(new NBTTagCompound());
|
||||
}
|
||||
dirty.addOverwriteEntry(id).setItems(validIndices, tag);
|
||||
isDirty = true;
|
||||
}
|
||||
}
|
||||
case CREATIVE_DUPLICATE -> {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
playerHand.addItems(handStack);
|
||||
}
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void syncLevelTerminalSlot(ContainerLevelTerminal.InvTracker inv, long id, int slot, ItemStack stack) {
|
||||
int[] validIndices = { slot };
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
}
|
||||
list.appendTag(item);
|
||||
inv.updateNBT();
|
||||
this.dirty.addOverwriteEntry(id).setItems(validIndices, list);
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
private SPacketLevelTerminalUpdate updateList() {
|
||||
SPacketLevelTerminalUpdate update = null;
|
||||
var supported = LevelTerminalRegistry.instance().getSupportedClasses();
|
||||
Set<ILevelViewable> visited = new HashSet<>();
|
||||
|
||||
for (Class<? extends ILevelViewable> clz : supported) {
|
||||
boolean isAdopted = LevelTerminalRegistry.instance().isAdopted(clz);
|
||||
Class<? extends IGridHost> machineClass = isAdopted ? LevelTerminalRegistry.instance().getAdopted(clz)
|
||||
: clz;
|
||||
for (IGridNode gridNode : grid.getMachines(machineClass)) {
|
||||
final ILevelViewable machine = isAdopted
|
||||
? LevelTerminalRegistry.instance().getAdapter(clz).adapt(gridNode.getMachine())
|
||||
: (ILevelViewable) gridNode.getMachine();
|
||||
|
||||
/* First check if we are already tracking this node */
|
||||
if (tracked.containsKey(machine)) {
|
||||
/* Check for updates */
|
||||
ContainerLevelTerminal.InvTracker knownTracker = tracked.get(machine);
|
||||
|
||||
/* Name changed? */
|
||||
String name = machine.getCustomName();
|
||||
|
||||
if (!Objects.equals(knownTracker.name, name)) {
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
update.addRenamedEntry(knownTracker.id, name);
|
||||
knownTracker.name = name;
|
||||
}
|
||||
|
||||
/* Status changed? */
|
||||
boolean isActive = gridNode.isActive() || machine.shouldDisplay();
|
||||
|
||||
if (!knownTracker.online && isActive) {
|
||||
/* Node offline -> online */
|
||||
knownTracker.online = true;
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
knownTracker.updateNBT();
|
||||
update.addOverwriteEntry(knownTracker.id).setOnline(true)
|
||||
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
|
||||
} else if (knownTracker.online && !isActive) {
|
||||
/* Node online -> offline */
|
||||
knownTracker.online = false;
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
update.addOverwriteEntry(knownTracker.id).setOnline(false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < knownTracker.requests.getSizeInventory(); i++) {
|
||||
ItemStack knowmItemStack = ItemStack
|
||||
.loadItemStackFromNBT(knownTracker.inventoryNbt.getCompoundTagAt(i));
|
||||
ItemStack machineItemStack = machine.getInventoryByName("config").getStackInSlot(i);
|
||||
if (isDifferent(knowmItemStack, machineItemStack)) {
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
knownTracker.updateNBT();
|
||||
update.addOverwriteEntry(knownTracker.id)
|
||||
.setItems(knownTracker.requests.getSizeInventory(), knownTracker.inventoryNbt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Add a new entry */
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
ContainerLevelTerminal.InvTracker entry = new ContainerLevelTerminal.InvTracker(
|
||||
nextId++,
|
||||
machine,
|
||||
gridNode.isActive());
|
||||
update.addNewEntry(entry.id, entry.name, entry.online)
|
||||
.setLocation(entry.x, entry.y, entry.z, entry.dim, entry.side.ordinal())
|
||||
.setItems(entry.rows, entry.rowSize, entry.inventoryNbt)
|
||||
.setViewItemStack(machine.getSelfItemStack(), machine.getDisplayItemStack());
|
||||
tracked.put(machine, entry);
|
||||
trackedById.put(entry.id, entry);
|
||||
}
|
||||
visited.add(machine);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now find any entries that we need to remove */
|
||||
Iterator<Map.Entry<ILevelViewable, ContainerLevelTerminal.InvTracker>> it = tracked.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
var entry = it.next();
|
||||
if (visited.contains(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
|
||||
trackedById.remove(entry.getValue().id);
|
||||
it.remove();
|
||||
update.addRemovalEntry(entry.getValue().id);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isDifferent(final ItemStack a, final ItemStack b) {
|
||||
if (a == null && b == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a == null || b == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !ItemStack.areItemStacksEqual(a, b);
|
||||
}
|
||||
|
||||
private static class InvTracker {
|
||||
|
||||
private final long id;
|
||||
private String name;
|
||||
private final IInventory requests;
|
||||
private final int rowSize;
|
||||
private final int rows;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
private boolean online;
|
||||
private NBTTagList inventoryNbt;
|
||||
|
||||
public InvTracker(long id, ILevelViewable machine, boolean online) {
|
||||
|
||||
DimensionalCoord location = machine.getLocation();
|
||||
|
||||
this.id = id;
|
||||
this.name = machine.getCustomName();
|
||||
this.requests = machine.getInventoryByName("config");
|
||||
this.rowSize = machine.rowSize();
|
||||
this.rows = machine.rows();
|
||||
this.x = location.x;
|
||||
this.y = location.y;
|
||||
this.z = location.z;
|
||||
this.dim = location.getDimension();
|
||||
this.side = machine.getSide();
|
||||
this.online = online;
|
||||
this.inventoryNbt = new NBTTagList();
|
||||
updateNBT();
|
||||
}
|
||||
|
||||
private void updateNBT() {
|
||||
this.inventoryNbt = new NBTTagList();
|
||||
for (int i = 0; i < this.rows; ++i) {
|
||||
for (int j = 0; j < this.rowSize; ++j) {
|
||||
final int offset = this.rowSize * i;
|
||||
ItemStack stack = this.requests.getStackInSlot(offset + j);
|
||||
|
||||
if (stack != null) {
|
||||
this.inventoryNbt.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
} else {
|
||||
this.inventoryNbt.appendTag(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class ContainerLevelWireless extends ContainerLevelTerminal {
|
||||
|
||||
public ContainerLevelWireless(InventoryPlayer ip, IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isWirelessTerminal() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ public enum FCPartsTexture {
|
||||
PartFluidPatternTerminal_Bright("pattern_terminal_bright"),
|
||||
PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
|
||||
PartFluidPatternTerminal_Colored("pattern_terminal_medium"),
|
||||
PartLevelTerminal_Bright("level_terminal_bright"),
|
||||
PartLevelTerminal_Dark("level_terminal_dark"),
|
||||
PartLevelTerminal_Colored("level_terminal_medium"),
|
||||
PartTerminalBroad("terminal_broad"),
|
||||
PartFluidImportBus("fluid_import_face"),
|
||||
PartFluidExportBus("fluid_export_face"),
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemPartLevelTerminal extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartLevelTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_LEVEL_TERMINAL);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PartLevelTerminal createPartFromItemStack(ItemStack is) {
|
||||
return new PartLevelTerminal(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
||||
float xOffset, float yOffset, float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List toolTip, boolean flag) {
|
||||
if (isShiftKeyDown()) {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_LEVEL_TERMINAL));
|
||||
} else {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartLevelTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_LEVEL_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessLevelTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessLevelTerminal> {
|
||||
|
||||
public ItemWirelessLevelTerminal() {
|
||||
super(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_LEVEL_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessLevelTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_LEVEL_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
return new WirelessLevelTerminalInventory(stack, x, gridNode, player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ 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.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalExInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
@@ -63,6 +64,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL_EX);
|
||||
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_LEVEL_TERMINAL);
|
||||
if (ModAndClassUtil.ThE) {
|
||||
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
}
|
||||
@@ -115,6 +117,8 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
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 {
|
||||
@@ -197,6 +201,15 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term == null) return false;
|
||||
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
return Util.hasInfinityBoosterCard(term.getRight());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<GuiType> getGuis() {
|
||||
return guis;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.parts.base.FCPart;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class PartLevelTerminal extends FCPart implements IClickableInTerminal {
|
||||
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartLevelTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartLevelTerminal_Colored;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartLevelTerminal_Dark;
|
||||
|
||||
private Util.DimensionalCoordSide tile;
|
||||
|
||||
public PartLevelTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
if (data.hasKey("clickedInterface")) {
|
||||
NBTTagCompound tileMsg = (NBTTagCompound) data.getTag("clickedInterface");
|
||||
this.tile = Util.DimensionalCoordSide.readFromNBT(tileMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
if (this.tile == null) return;
|
||||
|
||||
NBTTagCompound tileMsg = new NBTTagCompound();
|
||||
tile.writeToNBT(tileMsg);
|
||||
data.setTag("clickedInterface", tileMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontColored() {
|
||||
return FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FCPartsTexture getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLightSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBooting() {
|
||||
return super.isBooting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType getGui() {
|
||||
return GuiType.LEVEL_TERMINAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickedInterface(Util.DimensionalCoordSide tile) {
|
||||
this.tile = tile;
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiCraftingStatus;
|
||||
import com.glodblock.github.client.gui.GuiDualInterface;
|
||||
import com.glodblock.github.client.gui.GuiEssentiaTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFCPriority;
|
||||
@@ -20,16 +21,17 @@ import com.glodblock.github.client.gui.GuiFluidPacketDecoder;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternEncoder;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternExWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalCraftingStatus;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternWireless;
|
||||
import com.glodblock.github.client.gui.GuiFluidPortableCell;
|
||||
import com.glodblock.github.client.gui.GuiFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.GuiFluidTerminal;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceWireless;
|
||||
import com.glodblock.github.client.gui.GuiLargeIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLevelMaintainer;
|
||||
import com.glodblock.github.client.gui.GuiLevelTerminal;
|
||||
import com.glodblock.github.client.gui.GuiLevelWireless;
|
||||
import com.glodblock.github.client.gui.GuiOCPatternEditor;
|
||||
import com.glodblock.github.client.gui.GuiPatternValueAmount;
|
||||
import com.glodblock.github.client.gui.GuiRenamer;
|
||||
@@ -54,6 +56,8 @@ import com.glodblock.github.client.gui.container.ContainerIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
|
||||
import com.glodblock.github.client.gui.container.ContainerLargeIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelWireless;
|
||||
import com.glodblock.github.client.gui.container.ContainerOCPatternEditor;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.client.gui.container.ContainerRenamer;
|
||||
@@ -246,7 +250,7 @@ public enum GuiType {
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiFluidPatternTerminalCraftingStatus(player.inventory, inv);
|
||||
return new GuiCraftingStatus(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -263,6 +267,19 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
LEVEL_TERMINAL(new TileOrPartGuiFactory<>(ITerminalHost.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new ContainerLevelTerminal(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiLevelTerminal(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
PORTABLE_FLUID_CELL(new ItemGuiFactory<>(IFluidPortableCell.class) {
|
||||
|
||||
@Override
|
||||
@@ -335,7 +352,20 @@ public enum GuiType {
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiInterfaceTerminalWireless(player.inventory, inv);
|
||||
return new GuiInterfaceWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
WIRELESS_LEVEL_TERMINAL(new ItemGuiFactory<>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerLevelWireless(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiLevelWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
+2
-4
@@ -27,7 +27,7 @@ import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
|
||||
public class WirelessInterfaceTerminalInventory implements IClickableInTerminal, IWirelessTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
@@ -125,9 +125,7 @@ public class WirelessInterfaceTerminalInventory implements IWirelessInterfaceTer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
|
||||
}
|
||||
public void saveChanges() {}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
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;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
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;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class WirelessLevelTerminalInventory implements IClickableInTerminal, IWirelessTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final IGridNode grid;
|
||||
private Util.DimensionalCoordSide tile;
|
||||
|
||||
public WirelessLevelTerminalInventory(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
|
||||
public IGridNode getActionableNode() {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return this.grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
|
||||
amt = usePowerMultiplier.multiply(amt);
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
|
||||
}
|
||||
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
|
||||
final NBTTagCompound data = Platform.openNbtData(this.target);
|
||||
manager.writeToNBT(data);
|
||||
});
|
||||
out.registerSetting(Settings.TERMINAL_STYLE, TerminalStyle.SMALL);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
|
||||
ItemStack newStack) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickedInterface(Util.DimensionalCoordSide tile) {
|
||||
this.tile = tile;
|
||||
this.writeToNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Util.DimensionalCoordSide getClickedInterface() {
|
||||
return this.tile;
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,20 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.network.CPacketPatternValueSet;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.network.CPacketTransferRecipe;
|
||||
import com.glodblock.github.network.CPacketValueConfig;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
import com.glodblock.github.network.SPacketMEFluidInvUpdate;
|
||||
import com.glodblock.github.network.SPacketMEItemInvUpdate;
|
||||
import com.glodblock.github.network.SPacketSetItemAmount;
|
||||
import com.glodblock.github.network.SPacketStringUpdate;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ChannelLoader implements Runnable {
|
||||
@@ -33,48 +36,47 @@ public class ChannelLoader implements Runnable {
|
||||
@SuppressWarnings("all")
|
||||
public void run() {
|
||||
int id = 0;
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
SimpleNetworkWrapper netHandler = FluidCraft.proxy.netHandler;
|
||||
netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(
|
||||
new CPacketFluidPatternTermBtns.Handler(),
|
||||
CPacketFluidPatternTermBtns.class,
|
||||
id++,
|
||||
Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketEncodePattern.Handler(), CPacketEncodePattern.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
netHandler.registerMessage(new CPacketEncodePattern.Handler(), CPacketEncodePattern.class, id++, Side.SERVER);
|
||||
netHandler
|
||||
.registerMessage(new SPacketMEItemInvUpdate.Handler(), SPacketMEItemInvUpdate.class, id++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
netHandler.registerMessage(
|
||||
new SPacketMEFluidInvUpdate.Handler(),
|
||||
SPacketMEFluidInvUpdate.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketCraftRequest.Handler(), CPacketCraftRequest.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
netHandler.registerMessage(new CPacketCraftRequest.Handler(), CPacketCraftRequest.class, id++, Side.SERVER);
|
||||
netHandler
|
||||
.registerMessage(new CPacketInventoryAction.Handler(), CPacketInventoryAction.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler
|
||||
netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id++, Side.CLIENT);
|
||||
netHandler
|
||||
.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketValueConfig.Handler(), CPacketValueConfig.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
netHandler.registerMessage(new CPacketValueConfig.Handler(), CPacketValueConfig.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER);
|
||||
netHandler
|
||||
.registerMessage(new CPacketLevelMaintainer.Handler(), CPacketLevelMaintainer.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler
|
||||
.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);
|
||||
netHandler.registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(new CPacketRenamer.Handler(), CPacketRenamer.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(new SPacketStringUpdate.Handler(), SPacketStringUpdate.class, id++, Side.CLIENT);
|
||||
netHandler.registerMessage(
|
||||
new SPacketLevelTerminalUpdate.Handler(),
|
||||
SPacketLevelTerminalUpdate.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
netHandler.registerMessage(
|
||||
new CPacketLevelTerminalCommands.Handler(),
|
||||
CPacketLevelTerminalCommands.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
|
||||
@@ -35,9 +35,11 @@ import com.glodblock.github.common.item.ItemPartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.item.ItemPartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.item.ItemPartFluidStorageBus;
|
||||
import com.glodblock.github.common.item.ItemPartFluidTerminal;
|
||||
import com.glodblock.github.common.item.ItemPartLevelTerminal;
|
||||
import com.glodblock.github.common.item.ItemPortableFluidCell;
|
||||
import com.glodblock.github.common.item.ItemWirelessFluidTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessLevelTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessPatternTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
@@ -64,6 +66,7 @@ public class ItemAndBlockHolder {
|
||||
public static ItemPartFluidPatternTerminalEx FLUID_TERMINAL_EX = new ItemPartFluidPatternTerminalEx().register();
|
||||
public static ItemPartFluidInterface FLUID_INTERFACE = new ItemPartFluidInterface().register();
|
||||
public static ItemPartFluidP2PInterface FLUID_INTERFACE_P2P = new ItemPartFluidP2PInterface().register();
|
||||
public static ItemPartLevelTerminal LEVEL_TERMINAL = new ItemPartLevelTerminal().register();
|
||||
public static ItemFluidImportBus FLUID_IMPORT_BUS = new ItemFluidImportBus().register();
|
||||
public static ItemFluidExportBus FLUID_EXPORT_BUS = new ItemFluidExportBus().register();
|
||||
public static ItemPartFluidStorageBus FLUID_STORAGE_BUS = new ItemPartFluidStorageBus().register();
|
||||
@@ -72,8 +75,9 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
|
||||
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
|
||||
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
|
||||
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
|
||||
public static ItemWirelessLevelTerminal WIRELESS_LEVEL_TERM = new ItemWirelessLevelTerminal().register();
|
||||
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
|
||||
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
|
||||
public static ItemWirelessInterfaceTerminal WIRELESS_INTERFACE_TERM = new ItemWirelessInterfaceTerminal()
|
||||
.register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
|
||||
@@ -1,7 +1,56 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import static com.glodblock.github.common.storage.CellType.Cell16384kPart;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.BUFFER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1024K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1024KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16384K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16384KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL16KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL1KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL256K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL256KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4096K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4096KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL4KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL64K;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL64KM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CELL_HOUSING;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.CERTUS_QUARTZ_TANK;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.DECODER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.DISCRETIZER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.ENCODER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_AUTO_FILLER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_BUFFER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_CONVERSION_MONITOR;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_EXPORT_BUS;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_IMPORT_BUS;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_INTERFACE;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_INTERFACE_P2P;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_LEVEL_EMITTER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_STORAGE_BUS;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_STORAGE_MONITOR;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERMINAL;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.FLUID_TERMINAL_EX;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.INTERFACE;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.LARGE_BUFFER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.LEVEL_MAINTAINER;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.LEVEL_TERMINAL;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.OC_EDITOR;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.PATTERN;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.PORTABLE_FLUID_CELL;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.QUANTUM_CELL;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.SINGULARITY_CELL;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WALRUS;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_FLUID_TERM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_INTERFACE_TERM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_LEVEL_TERM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_PATTERN_TERM;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.WIRELESS_ULTRA_TERM;
|
||||
import static net.minecraft.init.Blocks.redstone_torch;
|
||||
import static net.minecraft.init.Items.fish;
|
||||
|
||||
@@ -156,6 +205,7 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_WIRELESS_TERMINAL, BUCKET);
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_PATTERN_TERM.stack(), WIRELESS_FLUID_TERM, FLUID_TERMINAL);
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_INTERFACE_TERM.stack(), AE2_WIRELESS_TERMINAL, AE2_INTERFACE_TERMINAL);
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_LEVEL_TERM.stack(), AE2_WIRELESS_TERMINAL, LEVEL_MAINTAINER);
|
||||
GameRegistry
|
||||
.addRecipe(new ShapedOreRecipe(CERTUS_QUARTZ_TANK.stack(), "GGG", "G G", "GGG", 'G', AE2_QUARTZ_GLASS));
|
||||
GameRegistry.addShapelessRecipe(FLUID_AUTO_FILLER.stack(), FLUID_TERMINAL, ENCODER);
|
||||
@@ -276,6 +326,7 @@ public class RecipeLoader implements Runnable {
|
||||
AE2_PROCESS_ENG));
|
||||
GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN, PATTERN.stack());
|
||||
GameRegistry.addShapelessRecipe(FLUID_TERM.stack(), AE2_TERMINAL, BUFFER);
|
||||
GameRegistry.addShapelessRecipe(LEVEL_TERMINAL.stack(), AE2_TERMINAL, LEVEL_MAINTAINER);
|
||||
GameRegistry.addShapelessRecipe(
|
||||
FLUID_BUFFER.stack(),
|
||||
LARGE_BUFFER.stack(),
|
||||
@@ -594,10 +645,11 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_FLUID_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_ULTRA_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_INTERFACE_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_LEVEL_TERM.stack()));
|
||||
}
|
||||
|
||||
ItemStack[] term = { AE2_WIRELESS_TERMINAL, WIRELESS_FLUID_TERM.stack(), WIRELESS_PATTERN_TERM.stack(),
|
||||
WIRELESS_INTERFACE_TERM.stack(), THE_WIRELESS_TERM, WCT_WIRELESS_TERM };
|
||||
WIRELESS_INTERFACE_TERM.stack(), WIRELESS_LEVEL_TERM.stack(), THE_WIRELESS_TERM, WCT_WIRELESS_TERM };
|
||||
GameRegistry.addShapelessRecipe(
|
||||
WIRELESS_ULTRA_TERM.stack(),
|
||||
Arrays.stream(term).filter(Objects::nonNull).toArray());
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
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 CPacketLevelTerminalCommands implements IMessage {
|
||||
|
||||
private Action action;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int dim;
|
||||
private ForgeDirection side;
|
||||
|
||||
public enum Action {
|
||||
EDIT,
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
ENABLE_ALL,
|
||||
DISABLE_ALL,
|
||||
}
|
||||
|
||||
public CPacketLevelTerminalCommands() {}
|
||||
|
||||
public CPacketLevelTerminalCommands(Action action, int x, int y, int z, int dim, ForgeDirection side) {
|
||||
this.action = action;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dim = dim;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
action = Action.values()[buf.readInt()];
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
dim = buf.readInt();
|
||||
side = ForgeDirection.getOrientation(buf.readInt());
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
case DISABLE_ALL -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(action.ordinal());
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeInt(this.dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
case DISABLE_ALL -> {}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketLevelTerminalCommands, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketLevelTerminalCommands message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
AEBaseContainer con = (AEBaseContainer) player.openContainer;
|
||||
switch (message.action) {
|
||||
case EDIT -> {
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim)
|
||||
.getTileEntity(message.x, message.y, message.z);
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
case ENABLE -> {
|
||||
if (con.getTarget() instanceof IClickableInTerminal clickableInterface) {
|
||||
Util.DimensionalCoordSide intMsg = clickableInterface.getClickedInterface();
|
||||
TileEntity tile = DimensionManager.getWorld(intMsg.getDimension())
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
}
|
||||
}
|
||||
case DISABLE -> {
|
||||
if (con.getTarget() instanceof IClickableInTerminal clickableInterface) {
|
||||
Util.DimensionalCoordSide intMsg = clickableInterface.getClickedInterface();
|
||||
TileEntity tile = DimensionManager.getWorld(intMsg.getDimension())
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
}
|
||||
}
|
||||
case ENABLE_ALL -> {
|
||||
if (con.getTarget() instanceof IClickableInTerminal clickableInterface) {
|
||||
Util.DimensionalCoordSide intMsg = clickableInterface.getClickedInterface();
|
||||
TileEntity tile = DimensionManager.getWorld(intMsg.getDimension())
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
}
|
||||
}
|
||||
case DISABLE_ALL -> {
|
||||
if (con.getTarget() instanceof IClickableInTerminal clickableInterface) {
|
||||
Util.DimensionalCoordSide intMsg = clickableInterface.getClickedInterface();
|
||||
TileEntity tile = DimensionManager.getWorld(intMsg.getDimension())
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiLevelTerminal;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
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;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
/**
|
||||
* Packet used for level terminal updates. Packet allows the server to send an array of command packets, which are then
|
||||
* processed in order. This allows for chaining commands to produce the desired update.
|
||||
*/
|
||||
public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
|
||||
public static final int CLEAR_ALL_BIT = 1;
|
||||
public static final int DISCONNECT_BIT = 2;
|
||||
|
||||
private final List<PacketEntry> commands = new ArrayList<>();
|
||||
private int statusFlags;
|
||||
|
||||
public SPacketLevelTerminalUpdate() {}
|
||||
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.statusFlags = buf.readByte();
|
||||
int numEntries = buf.readInt();
|
||||
|
||||
for (int i = 0; i < numEntries; ++i) {
|
||||
PacketType type = PacketType.values()[buf.readByte()];
|
||||
|
||||
try {
|
||||
switch (type) {
|
||||
case ADD -> this.commands.add(new PacketAdd(buf));
|
||||
case REMOVE -> this.commands.add(new PacketRemove(buf));
|
||||
case OVERWRITE -> this.commands.add(new PacketOverwrite(buf));
|
||||
case RENAME -> this.commands.add(new PacketRename(buf));
|
||||
default -> throw new IOException("Unknown packet type received of index " + type);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
AELog.debug(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
buf.writeByte(statusFlags);
|
||||
buf.writeInt(commands.size());
|
||||
for (PacketEntry entry : commands) {
|
||||
entry.write(buf);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all entries on the terminal. This is done BEFORE any entries are processed, so you can set this to clear
|
||||
* old entries, and add new ones after in one packet.
|
||||
*/
|
||||
public void setClear() {
|
||||
statusFlags |= CLEAR_ALL_BIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* The terminal disconnected. Entries are still processed, but indicates for the GUI to darken/turn off the
|
||||
* terminal. No further updates will arrive until the terminal reconnects.
|
||||
*/
|
||||
public void setDisconnect() {
|
||||
this.statusFlags |= DISCONNECT_BIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new entry. Fill out the rest of the command using the {@link PacketAdd#setItems(int, int, NBTTagList)} and
|
||||
* {@link PacketAdd#setLocation(int, int, int, int, int)}.
|
||||
*
|
||||
* @return the packet, which needs to have information filled out.
|
||||
*/
|
||||
public PacketAdd addNewEntry(long id, String name, boolean online) {
|
||||
PacketAdd packet = new PacketAdd(id, name, online);
|
||||
|
||||
commands.add(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the entry with the id from the terminal.
|
||||
*/
|
||||
public void addRemovalEntry(long id) {
|
||||
commands.add(new PacketRemove(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the entry
|
||||
*/
|
||||
public void addRenamedEntry(long id, String newName) {
|
||||
commands.add(new PacketRename(id, newName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the entry with new items or new status
|
||||
*/
|
||||
public PacketOverwrite addOverwriteEntry(long id) {
|
||||
PacketOverwrite packet = new PacketOverwrite(id);
|
||||
|
||||
commands.add(packet);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketLevelTerminalUpdate, IMessage> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(SPacketLevelTerminalUpdate message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if (gs instanceof GuiLevelTerminal levelTerminal) {
|
||||
levelTerminal.postUpdate(message.commands, message.statusFlags);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
enum PacketType {
|
||||
ADD,
|
||||
REMOVE,
|
||||
OVERWRITE,
|
||||
RENAME,
|
||||
}
|
||||
|
||||
/**
|
||||
* A packet for updating an entry.
|
||||
*/
|
||||
public abstract static class PacketEntry {
|
||||
|
||||
public final long entryId;
|
||||
|
||||
protected PacketEntry(long entryId) {
|
||||
this.entryId = entryId;
|
||||
}
|
||||
|
||||
protected PacketEntry(ByteBuf buf) throws IOException {
|
||||
this.entryId = buf.readLong();
|
||||
read(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Needs to write the packet id.
|
||||
*/
|
||||
protected abstract void write(ByteBuf buf) throws IOException;
|
||||
|
||||
/**
|
||||
* Reading the entry id is not needed.
|
||||
*/
|
||||
protected abstract void read(ByteBuf buf) throws IOException;
|
||||
}
|
||||
|
||||
/**
|
||||
* A command for sending a new entry.
|
||||
*/
|
||||
public static class PacketAdd extends PacketEntry {
|
||||
|
||||
public String name;
|
||||
public int x, y, z, dim, side;
|
||||
public int rows, rowSize;
|
||||
public boolean online;
|
||||
public ItemStack selfItemStack;
|
||||
public ItemStack displayItemStack;
|
||||
public NBTTagList items;
|
||||
|
||||
PacketAdd(long id, String name, boolean online) {
|
||||
super(id);
|
||||
this.name = name;
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
PacketAdd(ByteBuf buf) throws IOException {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
public PacketAdd setLocation(int x, int y, int z, int dim, int side) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dim = dim;
|
||||
this.side = side;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketAdd setItems(int rows, int rowSize, NBTTagList items) {
|
||||
this.rows = rows;
|
||||
this.rowSize = rowSize;
|
||||
this.items = items;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketAdd setViewItemStack(ItemStack selfItemStack, ItemStack displayItemStack) {
|
||||
this.selfItemStack = selfItemStack;
|
||||
this.displayItemStack = displayItemStack;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(ByteBuf buf) throws IOException {
|
||||
buf.writeByte(PacketType.ADD.ordinal());
|
||||
buf.writeLong(entryId);
|
||||
ByteBufUtils.writeUTF8String(buf, this.name);
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side);
|
||||
buf.writeInt(rows);
|
||||
buf.writeInt(rowSize);
|
||||
|
||||
ByteBuf tempBuf = Unpooled.directBuffer(256);
|
||||
try {
|
||||
try (ByteBufOutputStream stream = new ByteBufOutputStream(tempBuf)) {
|
||||
|
||||
NBTTagCompound wrapper = new NBTTagCompound();
|
||||
|
||||
if (selfItemStack != null) {
|
||||
wrapper.setTag("self", selfItemStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
if (displayItemStack != null) {
|
||||
wrapper.setTag("display", displayItemStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
wrapper.setTag("data", items);
|
||||
CompressedStreamTools.writeCompressed(wrapper, stream);
|
||||
}
|
||||
buf.writeInt(tempBuf.readableBytes());
|
||||
buf.writeBytes(tempBuf);
|
||||
} finally {
|
||||
tempBuf.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(ByteBuf buf) throws IOException {
|
||||
this.name = ByteBufUtils.readUTF8String(buf);
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.dim = buf.readInt();
|
||||
this.side = buf.readInt();
|
||||
this.rows = buf.readInt();
|
||||
this.rowSize = buf.readInt();
|
||||
int payloadSize = buf.readInt();
|
||||
try (ByteBufInputStream stream = new ByteBufInputStream(buf, payloadSize)) {
|
||||
NBTTagCompound payload = CompressedStreamTools.readCompressed(stream);
|
||||
if (payload.hasKey("self", NBT.TAG_COMPOUND)) {
|
||||
this.selfItemStack = ItemStack.loadItemStackFromNBT(payload.getCompoundTag("self"));
|
||||
}
|
||||
|
||||
if (payload.hasKey("display", NBT.TAG_COMPOUND)) {
|
||||
this.displayItemStack = ItemStack.loadItemStackFromNBT(payload.getCompoundTag("display"));
|
||||
}
|
||||
|
||||
this.items = payload.getTagList("data", NBT.TAG_COMPOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PacketRemove extends PacketEntry {
|
||||
|
||||
PacketRemove(long id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
PacketRemove(ByteBuf buf) throws IOException {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(ByteBuf buf) {
|
||||
buf.writeByte(PacketType.REMOVE.ordinal());
|
||||
buf.writeLong(entryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(ByteBuf buf) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite online status or inventory of the entry.
|
||||
*/
|
||||
public static class PacketOverwrite extends PacketEntry {
|
||||
|
||||
public static final int ONLINE_BIT = 1;
|
||||
public static final int ONLINE_VALID = 1 << 1;
|
||||
public static final int ITEMS_VALID = 1 << 2;
|
||||
public static final int ALL_ITEM_UPDATE_BIT = 1 << 3;
|
||||
public boolean onlineValid;
|
||||
public boolean online;
|
||||
public boolean itemsValid;
|
||||
public boolean allItemUpdate;
|
||||
public int[] validIndices;
|
||||
public NBTTagList items;
|
||||
|
||||
protected PacketOverwrite(long id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
protected PacketOverwrite(ByteBuf buf) throws IOException {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
public PacketOverwrite setOnline(boolean online) {
|
||||
this.onlineValid = true;
|
||||
this.online = online;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketOverwrite setItems(int[] validIndices, NBTTagList items) {
|
||||
this.itemsValid = true;
|
||||
this.allItemUpdate = validIndices == null || validIndices.length == 0;
|
||||
this.validIndices = validIndices;
|
||||
this.items = items;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PacketOverwrite setItems(int newSize, NBTTagList items) {
|
||||
this.itemsValid = true;
|
||||
this.allItemUpdate = true;
|
||||
this.validIndices = new int[newSize];
|
||||
this.items = items;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(ByteBuf buf) throws IOException {
|
||||
buf.writeByte(PacketType.OVERWRITE.ordinal());
|
||||
buf.writeLong(entryId);
|
||||
|
||||
int flags = 0;
|
||||
|
||||
if (onlineValid) {
|
||||
flags |= ONLINE_VALID;
|
||||
flags |= online ? ONLINE_BIT : 0;
|
||||
}
|
||||
if (itemsValid) {
|
||||
flags |= ITEMS_VALID;
|
||||
if (allItemUpdate) {
|
||||
flags |= ALL_ITEM_UPDATE_BIT;
|
||||
buf.writeByte(flags);
|
||||
buf.writeInt(validIndices.length);
|
||||
} else {
|
||||
buf.writeByte(flags);
|
||||
buf.writeInt(validIndices.length);
|
||||
for (int validIndex : validIndices) {
|
||||
buf.writeInt(validIndex);
|
||||
}
|
||||
}
|
||||
try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) {
|
||||
|
||||
NBTTagCompound wrapper = new NBTTagCompound();
|
||||
|
||||
wrapper.setTag("data", items);
|
||||
CompressedStreamTools.writeCompressed(wrapper, stream);
|
||||
}
|
||||
} else {
|
||||
buf.writeByte(flags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(ByteBuf buf) throws IOException {
|
||||
int flags = buf.readByte();
|
||||
|
||||
/* Decide whether to use online flag or not */
|
||||
if ((flags & ONLINE_VALID) == ONLINE_VALID) {
|
||||
this.onlineValid = true;
|
||||
this.online = (flags & ONLINE_BIT) == ONLINE_BIT;
|
||||
}
|
||||
/* Decide whether to read item list or not */
|
||||
if ((flags & ITEMS_VALID) == ITEMS_VALID) {
|
||||
this.itemsValid = true;
|
||||
if ((flags & ALL_ITEM_UPDATE_BIT) == ALL_ITEM_UPDATE_BIT) {
|
||||
this.allItemUpdate = true;
|
||||
int numItems = buf.readInt();
|
||||
this.validIndices = new int[numItems];
|
||||
} else {
|
||||
int numItems = buf.readInt();
|
||||
this.validIndices = new int[numItems];
|
||||
for (int i = 0; i < numItems; ++i) {
|
||||
this.validIndices[i] = buf.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
try (ByteBufInputStream stream = new ByteBufInputStream(buf)) {
|
||||
this.items = CompressedStreamTools.readCompressed(stream).getTagList("data", NBT.TAG_COMPOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the entry.
|
||||
*/
|
||||
public static class PacketRename extends PacketEntry {
|
||||
|
||||
public String newName;
|
||||
|
||||
protected PacketRename(long id, String newName) {
|
||||
super(id);
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
protected PacketRename(ByteBuf buf) throws IOException {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(ByteBuf buf) {
|
||||
buf.writeByte(PacketType.RENAME.ordinal());
|
||||
buf.writeLong(entryId);
|
||||
ByteBufUtils.writeUTF8String(buf, newName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(ByteBuf buf) {
|
||||
newName = ByteBufUtils.readUTF8String(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import appeng.core.AELog;
|
||||
|
||||
public enum FCGuiColors {
|
||||
|
||||
// ARGB Colors: Name and default value
|
||||
StateNone(0x00000000),
|
||||
StateIdle(0xFF55FF55),
|
||||
StateCraft(0xFFFFFF55),
|
||||
StateExport(0xFFAA00AA),
|
||||
StateError(0xFFFF5555);
|
||||
|
||||
private final String root;
|
||||
private final int color;
|
||||
|
||||
FCGuiColors() {
|
||||
this.root = "ae2fc.gui.color";
|
||||
this.color = 0x000000;
|
||||
}
|
||||
|
||||
FCGuiColors(final int hex) {
|
||||
this.root = "ae2fc.gui.color";
|
||||
this.color = hex;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
String hex = StatCollector.translateToLocal(this.getUnlocalized());
|
||||
int color = this.color;
|
||||
|
||||
if (hex.length() <= 8) {
|
||||
try {
|
||||
color = Integer.parseUnsignedInt(hex, 16);
|
||||
} catch (final NumberFormatException e) {
|
||||
AELog.warn("Couldn't format color correctly for: " + this.root + " -> " + hex);
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getUnlocalized() {
|
||||
return this.root + '.' + this.toString();
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public class NameConst {
|
||||
public static final String ITEM_PART_FLUID_STORAGE_MONITOR = "part_fluid_storage_monitor";
|
||||
public static final String ITEM_PART_FLUID_CONVERSION_MONITOR = "part_fluid_conversion_monitor";
|
||||
public static final String ITEM_PART_FLUID_TERMINAL = "part_fluid_terminal";
|
||||
public static final String ITEM_PART_LEVEL_TERMINAL = "part_level_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL = "part_fluid_pattern_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL_EX = "part_fluid_pattern_terminal_ex";
|
||||
public static final String ITEM_PART_FLUID_INTERFACE = "part_fluid_interface";
|
||||
@@ -43,6 +44,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
|
||||
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
|
||||
public static final String ITEM_WIRELESS_INTERFACE_TERMINAL = "wireless_interface_terminal";
|
||||
public static final String ITEM_WIRELESS_LEVEL_TERMINAL = "wireless_level_terminal";
|
||||
public static final String ITEM_WIRELESS_ULTRA_TERMINAL = "wireless_ultra_terminal";
|
||||
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
@@ -50,6 +52,7 @@ public class NameConst {
|
||||
|
||||
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
|
||||
public static final String TT_FLUID_TERMINAL = TT_KEY + "fluid_terminal";
|
||||
public static final String TT_LEVEL_TERMINAL = TT_KEY + "level_terminal";
|
||||
public static final String TT_INVALID_FLUID = TT_KEY + "invalid_fluid";
|
||||
public static final String TT_FLUID_PACKET = TT_KEY + "fluid_packet";
|
||||
public static final String TT_ENCODE_PATTERN = TT_KEY + "encode_pattern";
|
||||
@@ -79,6 +82,8 @@ public class NameConst {
|
||||
public static final String TT_LEVEL_MAINTAINER_LINK_DESC = TT_LEVEL_MAINTAINER + "link_desc";
|
||||
public static final String TT_LEVEL_MAINTAINER_EXPORT = TT_LEVEL_MAINTAINER + "export";
|
||||
public static final String TT_LEVEL_MAINTAINER_EXPORT_DESC = TT_LEVEL_MAINTAINER + "export_desc";
|
||||
public static final String TT_LEVEL_MAINTAINER_ERROR = TT_LEVEL_MAINTAINER + "error";
|
||||
public static final String TT_LEVEL_MAINTAINER_ERROR_DESC = TT_LEVEL_MAINTAINER + "error_desc";
|
||||
public static final String TT_CELL_CONTENTS = TT_KEY + "cell_contents";
|
||||
public static final String TT_CELL_EMPTY = TT_KEY + "cell_empty";
|
||||
public static final String TT_CELL_PORTABLE = TT_KEY + "cell_portable";
|
||||
@@ -101,6 +106,7 @@ public class NameConst {
|
||||
public static final String GUI_FLUID_PATTERN_TERMINAL = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL;
|
||||
public static final String GUI_FLUID_PATTERN_TERMINAL_EX = GUI_KEY + ITEM_PART_FLUID_PATTERN_TERMINAL_EX;
|
||||
public static final String GUI_LEVEL_MAINTAINER = GUI_KEY + BLOCK_LEVEL_MAINTAINER;
|
||||
public static final String GUI_LEVEL_TERMINAL = GUI_KEY + ITEM_PART_LEVEL_TERMINAL;
|
||||
public static final String GUI_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
||||
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
||||
public static final String GUI_FLUID_AUTO_FILLER = GUI_KEY + BLOCK_FLUID_AUTO_FILLER;
|
||||
|
||||
Reference in new issue
Block a user