mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge pull request #78 from asdflj/master
add wireless interface terminal
This commit is contained in:
26 files changed
+1797
-58
No files matched your search
@@ -48,12 +48,14 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
|
||||
this.registerApp(2, "FORCE_PRIO", "DO_PRIO", "prio");
|
||||
this.registerApp(3, "NOT_PRIO", "DONT_PRIO", "not_prio");
|
||||
this.registerApp(4, "SUBMIT", "SUBMIT", "submit");
|
||||
this.registerApp(5, "EDIT", "YES", "edit");
|
||||
this.registerApp(6, "DISABLE", "DISABLE", "disable");
|
||||
this.registerApp(7, "ENABLE", "ENABLE", "enable");
|
||||
this.registerApp(10, "FLUID_TEM", "YES", "fluid_terminal_w");
|
||||
this.registerApp(11, "CRAFT_TEM", "YES", "craft_terminal_w");
|
||||
this.registerApp(12, "PATTERN_TEM", "YES", "pattern_terminal_w");
|
||||
this.registerApp(13, "ESSENTIA_TEM", "YES", "essentia_terminal_w");
|
||||
this.registerApp(14, "INTERFACE_TEM", "YES", "interface_terminal_w");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,743 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.render.BlockPosHighlighter;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCBaseMEGui;
|
||||
import com.glodblock.github.client.gui.container.ContainerInterfaceWireless;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketRenamer;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
|
||||
|
||||
protected int offsetY;
|
||||
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
|
||||
private static final int offsetX = 21;
|
||||
|
||||
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
|
||||
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
private final HashMap<ClientDCInternalInv, DimensionalCoordSide> blockPosHashMap = new HashMap<>();
|
||||
private final HashMap<GuiButton, ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
|
||||
private final ArrayList<String> names = new ArrayList<>();
|
||||
private final ArrayList<Object> lines = new ArrayList<>();
|
||||
private final Set<Object> matchedStacks = new HashSet<>();
|
||||
|
||||
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
|
||||
|
||||
protected static String searchFieldOutputsText = "";
|
||||
protected static String searchFieldInputsText = "";
|
||||
protected static String searchFieldNamesText = "";
|
||||
private final MEGuiTextField searchFieldOutputs;
|
||||
private final MEGuiTextField searchFieldInputs;
|
||||
private final MEGuiTextField searchFieldNames;
|
||||
private final GuiImgButton guiButtonHideFull;
|
||||
private final GuiImgButton guiButtonAssemblersOnly;
|
||||
private final GuiImgButton guiButtonBrokenRecipes;
|
||||
private GuiImgButton searchStringSave;
|
||||
private GuiImgButton terminalStyleBox;
|
||||
private boolean refreshList = false;
|
||||
protected static boolean onlyMolecularAssemblers = false;
|
||||
protected static boolean onlyBrokenRecipes = false;
|
||||
|
||||
// private final IConfigManager configSrc;
|
||||
private int rows = 3;
|
||||
|
||||
private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";
|
||||
|
||||
public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));
|
||||
|
||||
this.setScrollBar(new GuiScrollbar());
|
||||
this.xSize = 208;
|
||||
this.ySize = 255;
|
||||
|
||||
searchFieldInputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
|
||||
searchFieldOutputs = new MEGuiTextField(86, 12, ButtonToolTips.SearchFieldOutputs.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
|
||||
searchFieldNames = new MEGuiTextField(71, 12, ButtonToolTips.SearchFieldNames.getLocal()) {
|
||||
|
||||
@Override
|
||||
public void onTextChange(final String oldText) {
|
||||
refreshList();
|
||||
}
|
||||
};
|
||||
searchFieldNames.setFocused(true);
|
||||
|
||||
guiButtonAssemblersOnly = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonHideFull = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
guiButtonBrokenRecipes = new GuiImgButton(0, 0, Settings.ACTIONS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetY() {
|
||||
return this.offsetY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOffsetY(int y) {
|
||||
this.offsetY = y;
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(52).setLeft(189).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(0, this.lines.size() - this.rows, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.rows = calculateRowsCount();
|
||||
this.ySize = MAGIC_HEIGHT_NUMBER + this.rows * 18;
|
||||
final int unusedSpace = this.height - this.ySize;
|
||||
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
|
||||
this.offsetY = this.guiTop + 8;
|
||||
this.buttonList.add(
|
||||
this.terminalStyleBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.offsetY,
|
||||
Settings.TERMINAL_STYLE,
|
||||
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||
this.offsetY += 20;
|
||||
this.buttonList.add(
|
||||
this.searchStringSave = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.offsetY,
|
||||
Settings.SAVE_SEARCH,
|
||||
AEConfig.instance.settings.getSetting(Settings.SAVE_SEARCH)));
|
||||
this.offsetY += 20;
|
||||
|
||||
searchFieldInputs.x = guiLeft + Math.max(32, offsetX);
|
||||
searchFieldInputs.y = guiTop + 25;
|
||||
|
||||
searchFieldOutputs.x = guiLeft + Math.max(32, offsetX);
|
||||
searchFieldOutputs.y = guiTop + 38;
|
||||
|
||||
searchFieldNames.x = guiLeft + Math.max(32, offsetX) + 99;
|
||||
searchFieldNames.y = guiTop + 38;
|
||||
|
||||
guiButtonAssemblersOnly.xPosition = guiLeft + Math.max(32, offsetX) + 99;
|
||||
guiButtonAssemblersOnly.yPosition = guiTop + 20;
|
||||
|
||||
guiButtonHideFull.xPosition = guiButtonAssemblersOnly.xPosition + 18;
|
||||
guiButtonHideFull.yPosition = guiTop + 20;
|
||||
|
||||
guiButtonBrokenRecipes.xPosition = guiButtonHideFull.xPosition + 18;
|
||||
guiButtonBrokenRecipes.yPosition = guiTop + 20;
|
||||
|
||||
terminalStyleBox.xPosition = guiLeft - 18;
|
||||
terminalStyleBox.yPosition = guiTop + 8;
|
||||
|
||||
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
|
||||
setSearchString();
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
this.repositionSlots();
|
||||
this.initGuiDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
searchFieldOutputsText = this.searchFieldOutputs.getText();
|
||||
searchFieldInputsText = this.searchFieldInputs.getText();
|
||||
searchFieldNamesText = this.searchFieldNames.getText();
|
||||
}
|
||||
|
||||
public void setSearchString() {
|
||||
this.searchFieldOutputs.setText(searchFieldOutputsText);
|
||||
this.searchFieldInputs.setText(searchFieldInputsText);
|
||||
this.searchFieldNames.setText(searchFieldNamesText);
|
||||
}
|
||||
|
||||
protected void repositionSlots() {
|
||||
for (final Object obj : this.inventorySlots.inventorySlots) {
|
||||
if (obj instanceof AppEngSlot) {
|
||||
final AppEngSlot slot = (AppEngSlot) obj;
|
||||
slot.yDisplayPosition = this.ySize + slot.getY() - 78 - 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateRowsCount() {
|
||||
final int maxRows = this.getMaxRows();
|
||||
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
|
||||
final int NEIPadding = hasNEI ? 22 /* input */ + 18 /* top panel */ : 0;
|
||||
final int extraSpace = this.height - MAGIC_HEIGHT_NUMBER - NEIPadding;
|
||||
|
||||
return Math.max(3, Math.min(maxRows, extraSpace / 18));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
fontRendererObj.drawString(
|
||||
getGuiDisplayName(GuiText.InterfaceTerminal.getLocal()),
|
||||
8,
|
||||
6,
|
||||
GuiColors.InterfaceTerminalTitle.getColor());
|
||||
fontRendererObj.drawString(
|
||||
GuiText.inventory.getLocal(),
|
||||
GuiInterfaceTerminalWireless.offsetX + 2,
|
||||
this.ySize - 96,
|
||||
GuiColors.InterfaceTerminalInventory.getColor());
|
||||
|
||||
int offset = 51;
|
||||
final int ex = getScrollBar().getCurrentScroll();
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
|
||||
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z))) drawRect(
|
||||
z * 18 + 22,
|
||||
1 + offset,
|
||||
z * 18 + 22 + 16,
|
||||
1 + offset + 16,
|
||||
GuiColors.InterfaceTerminalMatch.getColor());
|
||||
}
|
||||
} else if (lineObj instanceof String) {
|
||||
String name = (String) lineObj;
|
||||
final int rows = this.byName.get(name).size();
|
||||
String postfix = "";
|
||||
|
||||
if (rows > 1) {
|
||||
postfix = " (" + rows + ')';
|
||||
}
|
||||
|
||||
while (name.length() > 2 && this.fontRendererObj.getStringWidth(name + postfix) > 158) {
|
||||
name = name.substring(0, name.length() - 1);
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawString(
|
||||
name + postfix,
|
||||
GuiInterfaceTerminalWireless.offsetX + 3,
|
||||
6 + offset,
|
||||
GuiColors.InterfaceTerminalName.getColor());
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
buttonList.clear();
|
||||
inventorySlots.inventorySlots.removeIf(slot -> slot instanceof SlotDisconnected);
|
||||
|
||||
guiButtonAssemblersOnly.set(
|
||||
onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
|
||||
guiButtonHideFull.set(
|
||||
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
|
||||
? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF
|
||||
: ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
|
||||
guiButtonBrokenRecipes.set(
|
||||
onlyBrokenRecipes ? ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF
|
||||
: ActionItems.TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON);
|
||||
|
||||
terminalStyleBox.set(AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE));
|
||||
|
||||
buttonList.add(guiButtonAssemblersOnly);
|
||||
buttonList.add(guiButtonHideFull);
|
||||
buttonList.add(guiButtonBrokenRecipes);
|
||||
|
||||
buttonList.add(terminalStyleBox);
|
||||
buttonList.add(searchStringSave);
|
||||
addSwitchGuiBtns();
|
||||
|
||||
int offset = 51;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.getInventory().getSizeInventory(); z++) {
|
||||
inventorySlots.inventorySlots.add(new SlotDisconnected(inv, z, z * 18 + 22, 1 + offset));
|
||||
}
|
||||
|
||||
GuiButton guiButton = new GuiImgButton(
|
||||
guiLeft + 4,
|
||||
guiTop + offset + 1,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.HIGHLIGHT_INTERFACE);
|
||||
GuiFCImgButton editButton = new GuiFCImgButton(guiLeft + 4, guiTop + offset + 1, "EDIT", "YES");
|
||||
guiButtonHashMap.put(guiButton, inv);
|
||||
guiButtonHashMap.put(editButton, inv);
|
||||
if (isShiftKeyDown()) {
|
||||
buttonList.add(editButton);
|
||||
} else {
|
||||
buttonList.add(guiButton);
|
||||
}
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
|
||||
handleTooltip(mouseX, mouseY, searchFieldInputs);
|
||||
handleTooltip(mouseX, mouseY, searchFieldOutputs);
|
||||
handleTooltip(mouseX, mouseY, searchFieldNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
searchFieldInputs.mouseClicked(xCoord, yCoord, btn);
|
||||
searchFieldOutputs.mouseClicked(xCoord, yCoord, btn);
|
||||
searchFieldNames.mouseClicked(xCoord, yCoord, btn);
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (guiButtonHashMap.containsKey(btn)) {
|
||||
DimensionalCoordSide blockPos = blockPosHashMap.get(guiButtonHashMap.get(btn));
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketRenamer(blockPos.x, blockPos.y, blockPos.z, blockPos.getDimension(), blockPos.side));
|
||||
} else {
|
||||
|
||||
WorldCoord blockPos2 = new WorldCoord(
|
||||
(int) mc.thePlayer.posX,
|
||||
(int) mc.thePlayer.posY,
|
||||
(int) mc.thePlayer.posZ);
|
||||
if (mc.theWorld.provider.dimensionId != blockPos.getDimension()) {
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceInOtherDim.getName(),
|
||||
blockPos.getDimension()));
|
||||
} else {
|
||||
BlockPosHighlighter.highlightBlock(
|
||||
blockPos,
|
||||
System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
|
||||
mc.thePlayer.addChatMessage(
|
||||
new ChatComponentTranslation(
|
||||
PlayerMessages.InterfaceHighlighted.getName(),
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z));
|
||||
}
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
} else if (btn == guiButtonHideFull) {
|
||||
AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal = !AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal;
|
||||
this.refreshList();
|
||||
} else if (btn == guiButtonAssemblersOnly) {
|
||||
onlyMolecularAssemblers = !onlyMolecularAssemblers;
|
||||
this.refreshList();
|
||||
} else if (btn == guiButtonBrokenRecipes) {
|
||||
onlyBrokenRecipes = !onlyBrokenRecipes;
|
||||
this.refreshList();
|
||||
} else if (ModAndClassUtil.isSaveText && btn == searchStringSave) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
final Enum<?> cv = iBtn.getCurrentValue();
|
||||
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
|
||||
AEConfig.instance.settings.putSetting(Settings.SAVE_SEARCH, next);
|
||||
this.searchStringSave.set(next);
|
||||
|
||||
} else if (btn instanceof GuiImgButton) {
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if (iBtn.getSetting() != Settings.ACTIONS) {
|
||||
final Enum cv = iBtn.getCurrentValue();
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
|
||||
if (btn == this.terminalStyleBox) {
|
||||
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
|
||||
|
||||
this.reinitialize();
|
||||
}
|
||||
|
||||
iBtn.set(next);
|
||||
}
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
private void reinitialize() {
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.bindTexture("guis/newinterfaceterminal.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, 53);
|
||||
|
||||
int offset = 51;
|
||||
final int ex = this.getScrollBar().getCurrentScroll();
|
||||
|
||||
for (int x = 0; x < this.rows; x++) {
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 53 + x * 18, 0, 52, this.xSize, 18);
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.rows && ex + x < this.lines.size(); x++) {
|
||||
|
||||
final Object lineObj = this.lines.get(ex + x);
|
||||
if (lineObj instanceof ClientDCInternalInv) {
|
||||
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
final int width = inv.getInventory().getSizeInventory() * 18;
|
||||
this.drawTexturedModalRect(offsetX + 20, offsetY + offset, 20, 173, width, 18);
|
||||
}
|
||||
|
||||
offset += 18;
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 50 + this.rows * 18, 0, 158, this.xSize, 99);
|
||||
|
||||
searchFieldInputs.drawTextBox();
|
||||
searchFieldOutputs.drawTextBox();
|
||||
searchFieldNames.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!checkHotbarKeys(key)) {
|
||||
if (character == ' ') {
|
||||
if ((searchFieldInputs.getText().isEmpty() && searchFieldInputs.isFocused())
|
||||
|| (searchFieldOutputs.getText().isEmpty() && searchFieldOutputs.isFocused())
|
||||
|| (searchFieldNames.getText().isEmpty() && searchFieldNames.isFocused()))
|
||||
return;
|
||||
} else if (character == '\t') {
|
||||
if (handleTab()) return;
|
||||
}
|
||||
if (searchFieldInputs.textboxKeyTyped(character, key) || searchFieldOutputs.textboxKeyTyped(character, key)
|
||||
|| searchFieldNames.textboxKeyTyped(character, key)) {
|
||||
refreshList();
|
||||
} else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleTab() {
|
||||
if (searchFieldInputs.isFocused()) {
|
||||
searchFieldInputs.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldNames.setFocused(true);
|
||||
else searchFieldOutputs.setFocused(true);
|
||||
return true;
|
||||
} else if (searchFieldOutputs.isFocused()) {
|
||||
searchFieldOutputs.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldInputs.setFocused(true);
|
||||
else searchFieldNames.setFocused(true);
|
||||
return true;
|
||||
} else if (searchFieldNames.isFocused()) {
|
||||
searchFieldNames.setFocused(false);
|
||||
if (isShiftKeyDown()) searchFieldOutputs.setFocused(true);
|
||||
else searchFieldInputs.setFocused(true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class DimensionalCoordSide extends DimensionalCoord {
|
||||
|
||||
private ForgeDirection side = ForgeDirection.UNKNOWN;
|
||||
|
||||
public DimensionalCoordSide(final int _x, final int _y, final int _z, final int _dim, ForgeDirection side) {
|
||||
super(_x, _y, _z, _dim);
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postUpdate(final NBTTagCompound in) {
|
||||
if (in.getBoolean("clear")) {
|
||||
this.byId.clear();
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
for (final Object oKey : in.func_150296_c()) {
|
||||
final String key = (String) oKey;
|
||||
if (key.startsWith("=")) {
|
||||
try {
|
||||
final long id = Long.parseLong(key.substring(1), Character.MAX_RADIX);
|
||||
final NBTTagCompound invData = in.getCompoundTag(key);
|
||||
final ClientDCInternalInv current = this
|
||||
.getById(id, invData.getLong("sortBy"), invData.getString("un"));
|
||||
int X = invData.getInteger("x");
|
||||
int Y = invData.getInteger("y");
|
||||
int Z = invData.getInteger("z");
|
||||
int dim = invData.getInteger("dim");
|
||||
ForgeDirection side = ForgeDirection.getOrientation(invData.getInteger("side"));
|
||||
blockPosHashMap.put(current, new DimensionalCoordSide(X, Y, Z, dim, side));
|
||||
|
||||
for (int x = 0; x < current.getInventory().getSizeInventory(); x++) {
|
||||
final String which = Integer.toString(x);
|
||||
if (invData.hasKey(which)) {
|
||||
current.getInventory().setInventorySlotContents(
|
||||
x,
|
||||
ItemStack.loadItemStackFromNBT(invData.getCompoundTag(which)));
|
||||
}
|
||||
}
|
||||
} catch (final NumberFormatException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.refreshList) {
|
||||
this.refreshList = false;
|
||||
// invalid caches on refresh
|
||||
this.cachedSearches.clear();
|
||||
this.refreshList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the list of interfaces.
|
||||
* <p>
|
||||
* Respects a search term if present (ignores case) and adding only matching patterns.
|
||||
*/
|
||||
private void refreshList() {
|
||||
this.byName.clear();
|
||||
this.buttonList.clear();
|
||||
this.matchedStacks.clear();
|
||||
|
||||
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
|
||||
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
|
||||
final String searchFieldNames = this.searchFieldNames.getText().toLowerCase();
|
||||
|
||||
final Set<Object> cachedSearch = this.getCacheForSearchTerm(
|
||||
"IN:" + searchFieldInputs
|
||||
+ "OUT:"
|
||||
+ searchFieldOutputs
|
||||
+ "NAME:"
|
||||
+ searchFieldNames
|
||||
+ AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal
|
||||
+ onlyMolecularAssemblers
|
||||
+ onlyBrokenRecipes);
|
||||
final boolean rebuild = cachedSearch.isEmpty();
|
||||
|
||||
for (final ClientDCInternalInv entry : this.byId.values()) {
|
||||
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
|
||||
if (!rebuild && !cachedSearch.contains(entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shortcut to skip any filter if search term is ""/empty
|
||||
boolean found = searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty();
|
||||
boolean interfaceHasFreeSlots = false;
|
||||
boolean interfaceHasBrokenRecipes = false;
|
||||
|
||||
// Search if the current inventory holds a pattern containing the search term.
|
||||
if (!found || AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || onlyBrokenRecipes) {
|
||||
for (final ItemStack itemStack : entry.getInventory()) {
|
||||
// If only Interfaces with empty slots should be shown, check that here
|
||||
if (itemStack == null) {
|
||||
interfaceHasFreeSlots = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (onlyBrokenRecipes && recipeIsBroken(itemStack)) {
|
||||
interfaceHasBrokenRecipes = true;
|
||||
}
|
||||
|
||||
if ((!searchFieldInputs.isEmpty() && itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0))
|
||||
|| (!searchFieldOutputs.isEmpty()
|
||||
&& itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1))) {
|
||||
found = true;
|
||||
matchedStacks.add(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((found && entry.getName().toLowerCase().contains(searchFieldNames))
|
||||
&& (!onlyMolecularAssemblers || entry.getUnlocalizedName().contains(MOLECULAR_ASSEMBLER))
|
||||
&& (!AEConfig.instance.showOnlyInterfacesWithFreeSlotsInInterfaceTerminal || interfaceHasFreeSlots)
|
||||
&& (!onlyBrokenRecipes || interfaceHasBrokenRecipes)) {
|
||||
this.byName.put(entry.getName(), entry);
|
||||
cachedSearch.add(entry);
|
||||
} else {
|
||||
cachedSearch.remove(entry);
|
||||
}
|
||||
}
|
||||
|
||||
this.names.clear();
|
||||
this.names.addAll(this.byName.keySet());
|
||||
|
||||
Collections.sort(this.names);
|
||||
|
||||
this.lines.clear();
|
||||
this.lines.ensureCapacity(this.names.size() + this.byId.size());
|
||||
|
||||
for (final String n : this.names) {
|
||||
this.lines.add(n);
|
||||
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
|
||||
Collections.sort(clientInventories);
|
||||
this.lines.addAll(clientInventories);
|
||||
}
|
||||
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private boolean itemStackMatchesSearchTerm(final ItemStack itemStack, final String searchTerm, int pass) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagCompound encodedValue = itemStack.getTagCompound();
|
||||
|
||||
if (encodedValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagList tags = encodedValue.getTagList(pass == 0 ? "in" : "out", 10);
|
||||
final boolean containsInvalidDisplayName = GuiText.UnknownItem.getLocal().toLowerCase().contains(searchTerm);
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
final NBTTagCompound tag = tags.getCompoundTagAt(i);
|
||||
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
|
||||
|
||||
if (parsedItemStack != null) {
|
||||
final String displayName = Platform
|
||||
.getItemDisplayName(AEApi.instance().storage().createItemStack(parsedItemStack)).toLowerCase();
|
||||
if (displayName.contains(searchTerm)) {
|
||||
return true;
|
||||
}
|
||||
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean recipeIsBroken(final ItemStack itemStack) {
|
||||
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final NBTTagCompound encodedValue = itemStack.getTagCompound();
|
||||
if (encodedValue == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final World w = CommonHelper.proxy.getWorld();
|
||||
if (w == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
new PatternHelper(itemStack, w);
|
||||
return false;
|
||||
} catch (final Throwable t) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve a cache for a with search term as keyword.
|
||||
* <p>
|
||||
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
|
||||
* the empty string.
|
||||
*
|
||||
* @param searchTerm the corresponding search
|
||||
* @return a Set matching a superset of the search term
|
||||
*/
|
||||
private Set<Object> getCacheForSearchTerm(final String searchTerm) {
|
||||
if (!this.cachedSearches.containsKey(searchTerm)) {
|
||||
this.cachedSearches.put(searchTerm, new HashSet<>());
|
||||
}
|
||||
|
||||
final Set<Object> cache = this.cachedSearches.get(searchTerm);
|
||||
|
||||
if (cache.isEmpty() && searchTerm.length() > 1) {
|
||||
cache.addAll(this.getCacheForSearchTerm(searchTerm.substring(0, searchTerm.length() - 1)));
|
||||
return cache;
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
private int getMaxRows() {
|
||||
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
|
||||
? AEConfig.instance.InterfaceTerminalSmallSize
|
||||
: Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(final long id, final long sortBy, final String unlocalizedName) {
|
||||
ClientDCInternalInv o = this.byId.get(id);
|
||||
|
||||
if (o == null) {
|
||||
this.byId.put(id, o = new ClientDCInternalInv(9, id, sortBy, unlocalizedName));
|
||||
this.refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
public boolean isOverTextField(final int mousex, final int mousey) {
|
||||
return searchFieldInputs.isMouseIn(mousex, mousey) || searchFieldOutputs.isMouseIn(mousex, mousey)
|
||||
|| searchFieldNames.isMouseIn(mousex, mousey);
|
||||
}
|
||||
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
|
||||
if (searchFieldInputs.isMouseIn(mousex, mousey)) {
|
||||
searchFieldInputs.setText(displayName);
|
||||
} else if (searchFieldOutputs.isMouseIn(mousex, mousey)) {
|
||||
searchFieldOutputs.setText(displayName);
|
||||
} else if (searchFieldNames.isMouseIn(mousex, mousey)) {
|
||||
searchFieldNames.setText(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.glodblock.github.client.gui.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
|
||||
protected GuiFCImgButton FluidTerminal;
|
||||
protected GuiFCImgButton CraftingTerminal;
|
||||
protected GuiFCImgButton PatternTerminal;
|
||||
protected GuiFCImgButton EssentiaTerminal;
|
||||
protected GuiFCImgButton InterfaceTerminal;
|
||||
protected List<GuiFCImgButton> termBtns = new ArrayList<>();
|
||||
protected boolean drawSwitchGuiBtn;
|
||||
|
||||
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
|
||||
super(container);
|
||||
if (inventoryPlayer.getCurrentItem() != null
|
||||
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
|
||||
this.drawSwitchGuiBtn = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
Util.MouseHandler.saveMousePos();
|
||||
}
|
||||
|
||||
protected void initGuiDone() {
|
||||
if (drawSwitchGuiBtn) {
|
||||
drawSwitchGuiBtns();
|
||||
Util.MouseHandler.loadMousePos();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int getOffsetY();
|
||||
|
||||
public abstract void setOffsetY(int y);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void drawSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
if (!termBtns.isEmpty()) {
|
||||
this.termBtns.clear();
|
||||
}
|
||||
if (!(this instanceof GuiFluidCraftingWireless)) {
|
||||
this.buttonList.add(
|
||||
this.CraftingTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"CRAFT_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.CraftingTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiFluidPatternWireless)) {
|
||||
this.buttonList.add(
|
||||
this.PatternTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"PATTERN_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.PatternTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiFluidPortableCell)) {
|
||||
this.buttonList.add(
|
||||
this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.getOffsetY(), "FLUID_TEM", "YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.FluidTerminal);
|
||||
}
|
||||
if (!(this instanceof GuiInterfaceTerminalWireless)) {
|
||||
this.buttonList.add(
|
||||
this.InterfaceTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"INTERFACE_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.InterfaceTerminal);
|
||||
}
|
||||
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
|
||||
this.buttonList.add(
|
||||
this.EssentiaTerminal = new GuiFCImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.getOffsetY(),
|
||||
"ESSENTIA_TEM",
|
||||
"YES"));
|
||||
this.setOffsetY(this.getOffsetY() + 20);
|
||||
termBtns.add(this.EssentiaTerminal);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addSwitchGuiBtns() {
|
||||
if (!drawSwitchGuiBtn) return;
|
||||
this.buttonList.addAll(termBtns);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
if (btn == this.FluidTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
} else if (btn == this.CraftingTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_CRAFTING_TERMINAL);
|
||||
} else if (btn == this.EssentiaTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
} else if (btn == this.PatternTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
} else if (btn == this.InterfaceTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
}
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
@@ -51,13 +50,11 @@ import codechicken.nei.util.TextHistory;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
|
||||
|
||||
public static int craftingGridOffsetX;
|
||||
@@ -87,15 +84,10 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
protected GuiImgButton searchBoxSettings;
|
||||
protected GuiImgButton terminalStyleBox;
|
||||
protected GuiImgButton searchStringSave;
|
||||
protected GuiFCImgButton FluidTerminal;
|
||||
protected GuiFCImgButton CraftingTerminal;
|
||||
protected GuiFCImgButton PatternTerminal;
|
||||
protected GuiFCImgButton EssentiaTerminal;
|
||||
protected boolean drawSwitchGuiBtn;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public FCGuiMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCContainerMonitor<T> c) {
|
||||
super(c);
|
||||
super(inventoryPlayer, c);
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.xSize = 195;
|
||||
@@ -104,9 +96,14 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
|
||||
(this.monitorableContainer = (FCContainerMonitor<T>) this.inventorySlots).setGui(this);
|
||||
this.viewCell = te instanceof IViewCellStorage;
|
||||
if (inventoryPlayer.getCurrentItem() != null
|
||||
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
|
||||
this.drawSwitchGuiBtn = true;
|
||||
}
|
||||
|
||||
public int getOffsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
public void setOffsetY(int y) {
|
||||
offsetY = y;
|
||||
}
|
||||
|
||||
public abstract void postUpdate(final List<T> list);
|
||||
@@ -124,17 +121,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
}
|
||||
if (btn instanceof GuiFCImgButton) {
|
||||
if (btn == this.FluidTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
} else if (btn == this.CraftingTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_CRAFTING_TERMINAL);
|
||||
} else if (btn == this.EssentiaTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
} else if (btn == this.PatternTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(this.mc.thePlayer, GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
}
|
||||
}
|
||||
if (btn instanceof GuiImgButton) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
@@ -161,6 +147,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
}
|
||||
}
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
protected void reInitalize() {
|
||||
@@ -343,31 +330,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
|
||||
craftingGridOffsetX -= 25;
|
||||
craftingGridOffsetY -= 6;
|
||||
if (drawSwitchGuiBtn) drawSwitchGuiBtns();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void drawSwitchGuiBtns() {
|
||||
if (!(this instanceof GuiFluidCraftingWireless)) {
|
||||
this.buttonList.add(
|
||||
this.CraftingTerminal = new GuiFCImgButton(this.guiLeft - 18, this.offsetY, "CRAFT_TEM", "YES"));
|
||||
this.offsetY += 20;
|
||||
}
|
||||
if (!(this instanceof GuiFluidPatternWireless)) {
|
||||
this.buttonList.add(
|
||||
this.PatternTerminal = new GuiFCImgButton(this.guiLeft - 18, this.offsetY, "PATTERN_TEM", "YES"));
|
||||
this.offsetY += 20;
|
||||
}
|
||||
if (!(this instanceof GuiFluidPortableCell)) {
|
||||
this.buttonList
|
||||
.add(this.FluidTerminal = new GuiFCImgButton(this.guiLeft - 18, this.offsetY, "FLUID_TEM", "YES"));
|
||||
this.offsetY += 20;
|
||||
}
|
||||
if (ModAndClassUtil.ThE && !(this instanceof GuiEssentiaTerminal)) {
|
||||
this.buttonList.add(
|
||||
this.EssentiaTerminal = new GuiFCImgButton(this.guiLeft - 18, this.offsetY, "ESSENTIA_TEM", "YES"));
|
||||
this.offsetY += 20;
|
||||
}
|
||||
initGuiDone();
|
||||
}
|
||||
|
||||
public void setSearchString(String memoryText, boolean updateView) {
|
||||
|
||||
+435
@@ -0,0 +1,435 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
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.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.p2p.PartP2PInterface;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import appeng.util.inv.WrapperInvSlot;
|
||||
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.item.IWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class ContainerInterfaceWireless extends AEBaseContainer {
|
||||
|
||||
/**
|
||||
* this stuff is all server side..
|
||||
*/
|
||||
private static long autoBase = Long.MIN_VALUE;
|
||||
|
||||
private final Multimap<IInterfaceHost, ContainerInterfaceWireless.InvTracker> diList = HashMultimap.create();
|
||||
private final Map<Long, ContainerInterfaceWireless.InvTracker> byId = new HashMap<Long, ContainerInterfaceWireless.InvTracker>();
|
||||
private final IWirelessInterfaceTerminal it;
|
||||
// private final Map<Long, InvTracker> byId = new HashMap<>();
|
||||
private IGrid grid;
|
||||
private NBTTagCompound data = new NBTTagCompound();
|
||||
private int ticks;
|
||||
private final int slot;
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
public ContainerInterfaceWireless(final InventoryPlayer ip, final IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
this.it = (IWirelessInterfaceTerminal) monitorable;
|
||||
final int slotIndex = monitorable.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
if (Platform.isServer()) {
|
||||
this.grid = monitorable.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
this.bindPlayerInventory(ip, 14, 0);
|
||||
}
|
||||
|
||||
private Set<IGridNode> getMachineNodes() {
|
||||
Set<IGridNode> union = new HashSet<>();
|
||||
this.grid.getMachines(TileFluidInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(TileInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartFluidInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartInterface.class).forEach(union::add);
|
||||
this.grid.getMachines(PartP2PInterface.class).forEach(union::add);
|
||||
return union;
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
this.ticks = Util
|
||||
.drainItemPower(this, this.getPlayerInv(), this.slot, this.ticks, this.getPowerMultiplier(), this.it);
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (this.grid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.getMachineNodes()) {
|
||||
ContainerInterfaceWireless.InterfaceCheck interfaceCheck = new ContainerInterfaceWireless.InterfaceCheck()
|
||||
.invoke(gn);
|
||||
total += interfaceCheck.getTotal();
|
||||
missing |= interfaceCheck.isMissing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (total != this.diList.size() || missing) {
|
||||
this.regenList(this.data);
|
||||
} else {
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : diList.values()) {
|
||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||
if (this.isDifferent(inv.server.getStackInSlot(inv.offset + x), inv.client.getStackInSlot(x))) {
|
||||
this.addItems(this.data, inv, x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.data.hasNoTags()) {
|
||||
try {
|
||||
NetworkHandler.instance
|
||||
.sendTo(new PacketCompressedNBT(this.data), (EntityPlayerMP) this.getPlayerInv().player);
|
||||
} catch (final IOException e) {
|
||||
// :P
|
||||
}
|
||||
|
||||
this.data = new NBTTagCompound();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(final EntityPlayerMP player, final InventoryAction action, final int slot, final long id) {
|
||||
final ContainerInterfaceWireless.InvTracker inv = this.byId.get(id);
|
||||
if (inv != null) {
|
||||
final ItemStack is = inv.server.getStackInSlot(slot + inv.offset);
|
||||
final boolean hasItemInHand = player.inventory.getItemStack() != null;
|
||||
|
||||
final InventoryAdaptor playerHand = new AdaptorPlayerHand(player);
|
||||
|
||||
final WrapperInvSlot slotInv = new ContainerInterfaceWireless.PatternInvSlot(inv.server);
|
||||
|
||||
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
|
||||
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
|
||||
|
||||
IInventory interfaceHandler = inv.server;
|
||||
boolean canInsert = true;
|
||||
|
||||
switch (action) {
|
||||
case PICKUP_OR_SET_DOWN:
|
||||
if (hasItemInHand) {
|
||||
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
|
||||
if (Platform.isSameItemPrecise(
|
||||
interfaceHandler.getStackInSlot(s),
|
||||
player.inventory.getItemStack())) {
|
||||
canInsert = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canInsert) {
|
||||
ItemStack inSlot = theSlot.getStackInSlot(0);
|
||||
if (inSlot == null) {
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
|
||||
} else {
|
||||
inSlot = inSlot.copy();
|
||||
final ItemStack inHand = player.inventory.getItemStack().copy();
|
||||
|
||||
theSlot.setInventorySlotContents(0, null);
|
||||
player.inventory.setItemStack(null);
|
||||
|
||||
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
|
||||
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
player.inventory.setItemStack(inSlot);
|
||||
} else {
|
||||
player.inventory.setItemStack(inHand);
|
||||
theSlot.setInventorySlotContents(0, inSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
|
||||
mySlot.setInventorySlotContents(0, playerHand.addItems(mySlot.getStackInSlot(0)));
|
||||
}
|
||||
|
||||
break;
|
||||
case SPLIT_OR_PLACE_SINGLE:
|
||||
if (hasItemInHand) {
|
||||
for (int s = 0; s < interfaceHandler.getSizeInventory(); s++) {
|
||||
if (Platform.isSameItemPrecise(
|
||||
interfaceHandler.getStackInSlot(s),
|
||||
player.inventory.getItemStack())) {
|
||||
canInsert = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (canInsert) {
|
||||
ItemStack extra = playerHand.removeItems(1, null, null);
|
||||
if (extra != null && !interfaceSlot.containsItems()) {
|
||||
extra = interfaceSlot.addItems(extra);
|
||||
}
|
||||
if (extra != null) {
|
||||
playerHand.addItems(extra);
|
||||
}
|
||||
}
|
||||
} else if (is != null) {
|
||||
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
|
||||
if (extra != null) {
|
||||
extra = playerHand.addItems(extra);
|
||||
}
|
||||
if (extra != null) {
|
||||
interfaceSlot.addItems(extra);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case SHIFT_CLICK:
|
||||
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
|
||||
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
|
||||
|
||||
break;
|
||||
case MOVE_REGION:
|
||||
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
|
||||
inv.server.setInventorySlotContents(
|
||||
x + inv.offset,
|
||||
mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
|
||||
}
|
||||
|
||||
break;
|
||||
case CREATIVE_DUPLICATE:
|
||||
if (player.capabilities.isCreativeMode && !hasItemInHand) {
|
||||
player.inventory.setItemStack(is == null ? null : is.copy());
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private void regenList(final NBTTagCompound data) {
|
||||
this.byId.clear();
|
||||
this.diList.clear();
|
||||
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host != null) {
|
||||
final IGridNode agn = host.getActionableNode();
|
||||
if (agn != null && agn.isActive()) {
|
||||
for (final IGridNode gn : this.getMachineNodes()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
if (gn.isActive() && dual.getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.YES) {
|
||||
for (int i = 0; i <= dual.getInstalledUpgrades(Upgrades.PATTERN_CAPACITY); ++i) {
|
||||
this.diList.put(
|
||||
ih,
|
||||
new ContainerInterfaceWireless.InvTracker(
|
||||
dual,
|
||||
dual.getPatterns(),
|
||||
dual.getTermName(),
|
||||
i * 9,
|
||||
9));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.setBoolean("clear", true);
|
||||
|
||||
for (final ContainerInterfaceWireless.InvTracker inv : this.diList.values()) {
|
||||
this.byId.put(inv.which, inv);
|
||||
this.addItems(data, inv, 0, inv.client.getSizeInventory());
|
||||
}
|
||||
}
|
||||
|
||||
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 void addItems(final NBTTagCompound data, final ContainerInterfaceWireless.InvTracker inv, final int offset,
|
||||
final int length) {
|
||||
final String name = '=' + Long.toString(inv.which, Character.MAX_RADIX);
|
||||
final NBTTagCompound tag = data.getCompoundTag(name);
|
||||
|
||||
if (tag.hasNoTags()) {
|
||||
tag.setLong("sortBy", inv.sortBy);
|
||||
tag.setString("un", inv.unlocalizedName);
|
||||
tag.setInteger("x", inv.X);
|
||||
tag.setInteger("y", inv.Y);
|
||||
tag.setInteger("z", inv.Z);
|
||||
tag.setInteger("dim", inv.dim);
|
||||
tag.setInteger("side", inv.side.ordinal());
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++) {
|
||||
final NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
|
||||
final ItemStack is = inv.server.getStackInSlot(x + offset + inv.offset);
|
||||
|
||||
// "update" client side.
|
||||
inv.client.setInventorySlotContents(offset + x, is == null ? null : is.copy());
|
||||
|
||||
if (is != null) {
|
||||
is.writeToNBT(itemNBT);
|
||||
}
|
||||
|
||||
tag.setTag(Integer.toString(x + offset), itemNBT);
|
||||
}
|
||||
|
||||
data.setTag(name, tag);
|
||||
}
|
||||
|
||||
private static class InvTracker {
|
||||
|
||||
private final long sortBy;
|
||||
private final long which = autoBase++;
|
||||
private final String unlocalizedName;
|
||||
private final IInventory client;
|
||||
private final IInventory server;
|
||||
private final int offset;
|
||||
private final int X;
|
||||
private final int Y;
|
||||
private final int Z;
|
||||
private final int dim;
|
||||
private final ForgeDirection side;
|
||||
|
||||
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName,
|
||||
int offset, int size) {
|
||||
this.server = patterns;
|
||||
this.client = new AppEngInternalInventory(null, size);
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = dual.getSortValue() + offset << 16;
|
||||
this.offset = offset;
|
||||
X = dual.getLocation().x;
|
||||
Y = dual.getLocation().y;
|
||||
Z = dual.getLocation().z;
|
||||
dim = dual.getLocation().getDimension();
|
||||
if (dual.getHost() instanceof AEBasePart) {
|
||||
side = ((AEBasePart) dual.getHost()).getSide();
|
||||
} else {
|
||||
side = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class PatternInvSlot extends WrapperInvSlot {
|
||||
|
||||
public PatternInvSlot(final IInventory inv) {
|
||||
super(inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack itemstack) {
|
||||
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
}
|
||||
|
||||
private class InterfaceCheck {
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
public InterfaceCheck() {}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public boolean isMissing() {
|
||||
return missing;
|
||||
}
|
||||
|
||||
public ContainerInterfaceWireless.InterfaceCheck invoke(IGridNode gn) {
|
||||
if (gn.isActive()) {
|
||||
final IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
if (ih.getInterfaceDuality().getConfigManager().getSetting(Settings.INTERFACE_TERMINAL) == YesNo.NO
|
||||
|| ih instanceof PartP2PInterface && ((PartP2PInterface) ih).isOutput()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
final Collection<ContainerInterfaceWireless.InvTracker> t = ContainerInterfaceWireless.this.diList
|
||||
.get(ih);
|
||||
|
||||
if (t.isEmpty()) {
|
||||
missing = true;
|
||||
} else {
|
||||
final DualityInterface dual = ih.getInterfaceDuality();
|
||||
for (ContainerInterfaceWireless.InvTracker it : t) {
|
||||
if (!it.unlocalizedName.equals(dual.getTermName())) {
|
||||
missing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
total += (ih.getInterfaceDuality().getInstalledUpgrades(Upgrades.PATTERN_CAPACITY) + 1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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 appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.util.Platform;
|
||||
|
||||
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.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessInterfaceTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessInterfaceTerminal> {
|
||||
|
||||
public ItemWirelessInterfaceTerminal() {
|
||||
super(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_INTERFACE_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessInterfaceTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_INTERFACE_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);
|
||||
if (gridNode != null) {
|
||||
return new WirelessInterfaceTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessCraftingTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
@@ -52,6 +53,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
guis.add(GuiType.WIRELESS_CRAFTING_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
guis.add(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
if (ModAndClassUtil.ThE) {
|
||||
guis.add(GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
}
|
||||
@@ -87,7 +89,12 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
if (gridNode != null) {
|
||||
GuiType gui = readMode(stack);
|
||||
final GuiType gui;
|
||||
if (Util.GuiHelper.decodeType(y).getLeft() == Util.GuiHelper.GuiType.ITEM && z > 0) {
|
||||
gui = getGuis().get(Util.GuiHelper.decodeType(y).getRight());
|
||||
} else {
|
||||
gui = readMode(stack);
|
||||
}
|
||||
if (gui == GuiType.WIRELESS_FLUID_PATTERN_TERMINAL) {
|
||||
return new WirelessPatternTerminalInventory(stack, x, gridNode, player);
|
||||
}
|
||||
@@ -97,6 +104,8 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
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 {
|
||||
this.setMode(GuiType.WIRELESS_FLUID_TERMINAL, stack); // set as default mode
|
||||
return new WirelessFluidTerminalInventory(stack, x, gridNode, player);
|
||||
@@ -161,7 +170,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
.setMode(guiType, player.inventory.getCurrentItem());
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
player.closeScreen();
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
|
||||
} else {
|
||||
InventoryHandler.openGui(
|
||||
@@ -169,13 +177,19 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
player.inventory.currentItem,
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
Util.GuiHelper.encodeType(
|
||||
guis.indexOf(GuiType.valueOf(guiType.toString())),
|
||||
Util.GuiHelper.GuiType.ITEM),
|
||||
1),
|
||||
ForgeDirection.UNKNOWN,
|
||||
guiType);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<GuiType> getGuis() {
|
||||
return guis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiType guiGuiType(ItemStack stack) {
|
||||
return readMode(stack);
|
||||
|
||||
@@ -37,6 +37,12 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
case "appeng.core.features.registries.ExternalStorageRegistry":
|
||||
tform = ExternalStorageRegistryTransformer.INSTANCE;
|
||||
break;
|
||||
case "appeng.core.sync.packets.PacketCompressedNBT":
|
||||
tform = PacketCompressedNBTTransformer.INSTANCE;
|
||||
break;
|
||||
case "appeng.client.gui.implementations.GuiRenamer":
|
||||
tform = GuiRenamerTransformer.INSTANCE;
|
||||
break;
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,13 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -28,14 +32,20 @@ import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
|
||||
import com.glodblock.github.client.gui.GuiInterfaceTerminalWireless;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.item.ItemWirelessInterfaceTerminal;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryCrafting;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.SetBackedMachineSet;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -188,4 +198,19 @@ public class CoreModHooks {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void clientPacketData(NBTTagCompound data) {
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiInterfaceTerminalWireless) {
|
||||
((GuiInterfaceTerminalWireless) gs).postUpdate(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reopenInterfaceTerminal() {
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack c = p.getCurrentEquippedItem();
|
||||
if (c.getItem() instanceof ItemWirelessInterfaceTerminal || c.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.WIRELESS_INTERFACE_TERMINAL, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class GuiRenamerTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final GuiRenamerTransformer INSTANCE = new GuiRenamerTransformer();
|
||||
|
||||
private GuiRenamerTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new GuiRenamerTransformer.TransformGuiRenamer(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformGuiRenamer extends ClassVisitor {
|
||||
|
||||
TransformGuiRenamer(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("keyTyped")) {
|
||||
return new GuiRenamerTransformer.TransformKeyTyped(
|
||||
api,
|
||||
super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformKeyTyped extends MethodVisitor {
|
||||
|
||||
TransformKeyTyped(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
super.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
if (owner.equals("net/minecraft/client/entity/EntityClientPlayerMP") && name.equals("closeScreen")) {
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"reopenInterfaceTerminal",
|
||||
"()V",
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class PacketCompressedNBTTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final PacketCompressedNBTTransformer INSTANCE = new PacketCompressedNBTTransformer();
|
||||
|
||||
private PacketCompressedNBTTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformPacketCompressedNBT(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformPacketCompressedNBT extends ClassVisitor {
|
||||
|
||||
TransformPacketCompressedNBT(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if (name.equals("clientPacketData")) {
|
||||
return new TransformClientPacketData(api, super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformClientPacketData extends MethodVisitor {
|
||||
|
||||
TransformClientPacketData(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInsn(int opcode) {
|
||||
super.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
super.visitFieldInsn(
|
||||
Opcodes.GETFIELD,
|
||||
"appeng/core/sync/packets/PacketCompressedNBT",
|
||||
"in",
|
||||
"Lnet/minecraft/nbt/NBTTagCompound;");
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"clientPacketData",
|
||||
"(Lnet/minecraft/nbt/NBTTagCompound;)V",
|
||||
false);
|
||||
super.visitInsn(opcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,6 +247,18 @@ public enum GuiType {
|
||||
return new GuiFluidPatternWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
WIRELESS_INTERFACE_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerInterfaceWireless(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiInterfaceTerminalWireless(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
WIRELESS_CRAFTING_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
public interface IWirelessInterfaceTerminal extends IWirelessTerminal {
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.glodblock.github.inventory.item;
|
||||
|
||||
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 appeng.api.config.*;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
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 WirelessInterfaceTerminalInventory implements IWirelessInterfaceTerminal {
|
||||
|
||||
private final ItemStack target;
|
||||
private final IAEItemPowerStorage ips;
|
||||
private final int inventorySlot;
|
||||
private final IGridNode grid;
|
||||
|
||||
public WirelessInterfaceTerminalInventory(ItemStack is, int slot, IGridNode gridNode, EntityPlayer player) {
|
||||
this.ips = (ToolWirelessTerminal) is.getItem();
|
||||
this.grid = gridNode;
|
||||
this.target = is;
|
||||
this.inventorySlot = slot;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@ public class ChannelLoader implements Runnable {
|
||||
.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);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
|
||||
@@ -35,6 +35,8 @@ public class ItemAndBlockHolder {
|
||||
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
|
||||
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
|
||||
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
|
||||
public static ItemWirelessInterfaceTerminal WIRELESS_INTERFACE_TERM = new ItemWirelessInterfaceTerminal()
|
||||
.register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
|
||||
|
||||
@@ -142,6 +142,7 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack());
|
||||
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);
|
||||
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);
|
||||
@@ -462,10 +463,11 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_PATTERN_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_FLUID_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_ULTRA_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminalRecipe(WIRELESS_INTERFACE_TERM.stack()));
|
||||
}
|
||||
|
||||
ItemStack[] term = { AE2_WIRELESS_TERMINAL, WIRELESS_FLUID_TERM.stack(), WIRELESS_PATTERN_TERM.stack(),
|
||||
THE_WIRELESS_TERM, WCT_WIRELESS_TERM };
|
||||
WIRELESS_INTERFACE_TERM.stack(), THE_WIRELESS_TERM, WCT_WIRELESS_TERM };
|
||||
GameRegistry.addShapelessRecipe(
|
||||
WIRELESS_ULTRA_TERM.stack(),
|
||||
Arrays.stream(term).filter(Objects::nonNull).toArray());
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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 appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
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 CPacketRenamer implements IMessage {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int dim;
|
||||
private ForgeDirection side;
|
||||
|
||||
public CPacketRenamer() {}
|
||||
|
||||
public CPacketRenamer(int x, int y, int z, int dim, ForgeDirection side) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.dim = dim;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.dim = buf.readInt();
|
||||
this.side = ForgeDirection.getOrientation(buf.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeInt(this.dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketRenamer, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketRenamer message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim).getTileEntity(message.x, message.y, message.z);
|
||||
if (tile != null) {
|
||||
Platform.openGUI(player, tile, message.side, GuiBridge.GUI_RENAMER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
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_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";
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -52,6 +53,25 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static class MouseHandler {
|
||||
|
||||
private static int mouse_x = 0;
|
||||
private static int mouse_y = 0;
|
||||
|
||||
public static void saveMousePos() {
|
||||
mouse_x = Mouse.getX();
|
||||
mouse_y = Mouse.getY();
|
||||
}
|
||||
|
||||
public static void loadMousePos() {
|
||||
if (mouse_x != 0 && mouse_y != 0) {
|
||||
Mouse.setCursorPosition(mouse_x, mouse_y);
|
||||
mouse_y = 0;
|
||||
mouse_x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int drainItemPower(AEBaseContainer c, InventoryPlayer ip, int slot, int ticks, double pm,
|
||||
IFluidPortableCell wt) {
|
||||
final ItemStack currentItem = slot < 0 ? ip.getCurrentItem() : ip.getStackInSlot(slot);
|
||||
|
||||
@@ -13,10 +13,12 @@ item.part_fluid_conversion_monitor.name=ME Fluid Conversion Monitor
|
||||
item.portable_fluid_cell.name=Portable Fluid Cell
|
||||
item.wireless_fluid_terminal.name=Wireless Fluid Terminal
|
||||
item.wireless_fluid_pattern_terminal.name=Wireless Fluid Pattern Terminal
|
||||
item.wireless_interface_terminal.name=Wireless Interface Terminal
|
||||
item.wireless_ultra_terminal.WIRELESS_CRAFTING_TERMINAL.name=Universal Wireless Terminal - Crafting
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL.name=Universal Wireless Terminal - Pattern
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_TERMINAL.name=Universal Wireless Terminal - Fluid
|
||||
item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=Universal Wireless Terminal - Essentia
|
||||
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=Universal Wireless Terminal - Interface
|
||||
item.fluid_packet.name=Fluid Packet
|
||||
item.fluid_storage.1.name=%s1k%s ME Fluid Storage Cell
|
||||
item.fluid_storage.4.name=%s4k%s ME Fluid Storage Cell
|
||||
@@ -78,6 +80,7 @@ ae2fc.tooltip.ultra_terminal.WIRELESS_CRAFTING_TERMINAL=Mode: Crafting Terminal
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL=Mode: Pattern Terminal
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_TERMINAL=Mode: Fluid Terminal
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_ESSENTIA_TERMINAL=Mode: Essentia Terminal
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_INTERFACE_TERMINAL=Mode: Interface Terminal
|
||||
ae2fc.tooltip.ultra_terminal=Right click + sneaking to switch mode.
|
||||
|
||||
ae2fc.tooltip.cell_contents=Contains Fluid:
|
||||
@@ -95,13 +98,10 @@ ae2fc.tooltip.not_combine.hint=Disabled
|
||||
ae2fc.tooltip.combine=Merge the same items
|
||||
ae2fc.tooltip.combine.hint=Enabled
|
||||
ae2fc.tooltip.fluid_terminal_w=Fluid Terminal
|
||||
ae2fc.tooltip.fluid_terminal_w.hint=Switch to Fluid Terminal
|
||||
ae2fc.tooltip.craft_terminal_w=Crafting Terminal
|
||||
ae2fc.tooltip.craft_terminal_w.hint=Switch to Crafting Terminal
|
||||
ae2fc.tooltip.pattern_terminal_w=Pattern Terminal
|
||||
ae2fc.tooltip.pattern_terminal_w.hint=Switch to Pattern Terminal
|
||||
ae2fc.tooltip.essentia_terminal_w=Essentia Terminal
|
||||
ae2fc.tooltip.essentia_terminal_w.hint=Switch to Essentia Terminal
|
||||
ae2fc.tooltip.interface_terminal_w=Interface Terminal
|
||||
ae2fc.tooltip.wireless.installed=Installed Card:
|
||||
|
||||
ae2fc.tooltip.not_prio=Allow fluids to be placed first
|
||||
@@ -111,6 +111,7 @@ ae2fc.tooltip.prio.hint=Disabled
|
||||
ae2fc.tooltip.submit=Submit
|
||||
ae2fc.tooltip.enable=Enabled
|
||||
ae2fc.tooltip.disable=Disabled
|
||||
ae2fc.tooltip.edit=Edit
|
||||
|
||||
ae2fc.gui.part_fluid_pattern_terminal=Fluid Pattern Terminal
|
||||
ae2fc.gui.part_fluid_pattern_terminal_ex=Fluid Processing Pattern Terminal
|
||||
|
||||
@@ -13,6 +13,12 @@ item.part_fluid_conversion_monitor.name=ME流体交换监控器
|
||||
item.portable_fluid_cell.name=便携流体单元
|
||||
item.wireless_fluid_terminal.name=无线流体终端
|
||||
item.wireless_fluid_pattern_terminal.name=无线样板终端
|
||||
item.wireless_interface_terminal.name=无线接口终端
|
||||
item.wireless_ultra_terminal.WIRELESS_CRAFTING_TERMINAL.name=无线ME通用终端 - 合成
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL.name=无线ME通用终端 - 样板
|
||||
item.wireless_ultra_terminal.WIRELESS_FLUID_TERMINAL.name=无线ME通用终端 - 流体
|
||||
item.wireless_ultra_terminal.WIRELESS_ESSENTIA_TERMINAL.name=无线ME通用终端 - 源质
|
||||
item.wireless_ultra_terminal.WIRELESS_INTERFACE_TERMINAL.name=无线ME通用终端 - 接口
|
||||
item.fluid_packet.name=流体封包
|
||||
item.fluid_storage.1.name=%s1k%s-ME流体存储元件
|
||||
item.fluid_storage.4.name=%s4k%s-ME流体存储元件
|
||||
@@ -70,6 +76,12 @@ ae2fc.tooltip.level_maintainer.batch_size=§6单次合成数量§r
|
||||
ae2fc.tooltip.level_maintainer.batch_size.hint=当发出合成请求时,请求器发送单次合成数量的多少。更多的单次合成数量将提高储存物品的速度,但需要更多的合成存储空间。
|
||||
ae2fc.tooltip.level_maintainer.request_size=§6缓存量§r
|
||||
ae2fc.tooltip.level_maintainer.request_size.hint=数量定义了在请求器开始请求新合成之前应该保留多少物品。
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_CRAFTING_TERMINAL=模式: 合成
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_PATTERN_TERMINAL=模式: 样板
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_FLUID_TERMINAL=模式: 流体
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_ESSENTIA_TERMINAL=模式: 源质
|
||||
ae2fc.tooltip.ultra_terminal.WIRELESS_INTERFACE_TERMINAL=模式: 接口
|
||||
ae2fc.tooltip.ultra_terminal=Shift右击切换模式。
|
||||
|
||||
ae2fc.tooltip.cell_contents=内含流体:
|
||||
ae2fc.tooltip.cell_empty=空存储
|
||||
@@ -85,6 +97,11 @@ ae2fc.tooltip.not_combine=合并输出相同物品
|
||||
ae2fc.tooltip.not_combine.hint=禁用
|
||||
ae2fc.tooltip.combine=合并输出相同物品
|
||||
ae2fc.tooltip.combine.hint=启用
|
||||
ae2fc.tooltip.fluid_terminal_w=流体终端
|
||||
ae2fc.tooltip.craft_terminal_w=合成终端
|
||||
ae2fc.tooltip.pattern_terminal_w=样板终端
|
||||
ae2fc.tooltip.essentia_terminal_w=源质终端
|
||||
ae2fc.tooltip.interface_terminal_w=接口终端
|
||||
ae2fc.tooltip.wireless.installed=已安装的卡:
|
||||
|
||||
ae2fc.tooltip.not_prio=优先放置流体
|
||||
@@ -94,6 +111,7 @@ ae2fc.tooltip.prio.hint=禁用
|
||||
ae2fc.tooltip.submit=提交
|
||||
ae2fc.tooltip.enable=启用
|
||||
ae2fc.tooltip.disable=禁用
|
||||
ae2fc.tooltip.edit=编辑
|
||||
|
||||
ae2fc.gui.part_fluid_pattern_terminal=ME流体样板终端
|
||||
ae2fc.gui.part_fluid_pattern_terminal_ex=ME增广流体样板终端
|
||||
@@ -121,3 +139,6 @@ ae2fc.gui.fluid_auto_filler=ME流体自动装填器
|
||||
error.unknown=未知流体
|
||||
|
||||
itemGroup.ae2fc=AE2流体合成套件重置
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 634 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Reference in new issue
Block a user