mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-12 00:07:29 +00:00
31 files changed
+2275
-60
No files matched your search
+6
-6
@@ -1,11 +1,11 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-109-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev')
|
||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-116-GTNH:dev')
|
||||
compile('curse.maven:cofh-core-69162:2388751')
|
||||
compile('com.github.GTNewHorizons:ExtraCells2:2.5.20:dev') {transitive = false}
|
||||
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.8.5:dev")
|
||||
compile('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
|
||||
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.7:dev')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.27:dev')
|
||||
@@ -14,8 +14,8 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') { transitive = false }
|
||||
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') {transitive = false}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor {
|
||||
protected EntityPlayer player;
|
||||
|
||||
public GuiBaseFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te, FCBaseFluidMonitorContain c) {
|
||||
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
|
||||
player = inventoryPlayer.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "gui/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
if (s.isPlayerSide()) {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
|
||||
} else {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == craftingStatusBtn) {
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PAT_TERM_CRAFTING_STATUS);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,689 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
|
||||
import com.glodblock.github.client.me.FluidRepo;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemFluidDrop.newStack1;
|
||||
|
||||
public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost {
|
||||
|
||||
public static int craftingGridOffsetX;
|
||||
public static int craftingGridOffsetY;
|
||||
|
||||
private static String memoryText = "";
|
||||
private final FluidRepo repo;
|
||||
private final int offsetX = 9;
|
||||
private final int lowerTextureOffset = 0;
|
||||
private final boolean viewCell;
|
||||
private final ItemStack[] myCurrentViewCells = new ItemStack[5];
|
||||
public IConfigManager configSrc;
|
||||
public FCBaseFluidMonitorContain monitorableContainer;
|
||||
public GuiTabButton craftingStatusBtn;
|
||||
private GuiImgButton craftingStatusImgBtn;
|
||||
private FCGuiTextField searchField;
|
||||
private int perRow = 9;
|
||||
private int reservedSpace = 0;
|
||||
private boolean customSortOrder = true;
|
||||
private int rows = 0;
|
||||
private int maxRows = Integer.MAX_VALUE;
|
||||
private int standardSize;
|
||||
private GuiImgButton ViewBox;
|
||||
private GuiImgButton SortByBox;
|
||||
private GuiImgButton SortDirBox;
|
||||
private GuiImgButton searchBoxSettings;
|
||||
private GuiImgButton terminalStyleBox;
|
||||
private GuiImgButton searchStringSave;
|
||||
|
||||
public GuiFCBaseFluidMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) {
|
||||
|
||||
super(c);
|
||||
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new FluidRepo(scrollbar, this);
|
||||
|
||||
this.xSize = 195;
|
||||
this.ySize = 204;
|
||||
|
||||
this.standardSize = this.xSize;
|
||||
|
||||
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
|
||||
(this.monitorableContainer = (FCBaseFluidMonitorContain) this.inventorySlots).setGui(this);
|
||||
|
||||
this.viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEFluidStack> list) {
|
||||
for (final IAEFluidStack is : list) {
|
||||
IAEItemStack stack = AEItemStack.create(newStack1(is.getFluidStack()));
|
||||
stack.setStackSize(is.getStackSize());
|
||||
this.repo.postUpdate(stack);
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
|
||||
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
}
|
||||
|
||||
if (btn instanceof GuiImgButton) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if (iBtn.getSetting() != Settings.ACTIONS) {
|
||||
final Enum<?> cv = iBtn.getCurrentValue();
|
||||
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
|
||||
if (btn == this.terminalStyleBox) {
|
||||
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
|
||||
} else if (btn == this.searchBoxSettings) {
|
||||
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
|
||||
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
|
||||
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
|
||||
} else {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
iBtn.set(next);
|
||||
|
||||
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
|
||||
this.reinitalize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void reinitalize() {
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
|
||||
this.maxRows = this.getMaxRows();
|
||||
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL ? 9 : 9 + ((this.width - this.standardSize) / 18);
|
||||
|
||||
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
|
||||
|
||||
final int NEI = hasNEI ? 0 : 0;
|
||||
int top = hasNEI ? 22 : 0;
|
||||
|
||||
final int magicNumber = 114 + 1;
|
||||
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
|
||||
|
||||
this.rows = (int) Math.floor(extraSpace / 18.0);
|
||||
if (this.rows > this.maxRows) {
|
||||
top += (this.rows - this.maxRows) * 18 / 2;
|
||||
this.rows = this.maxRows;
|
||||
}
|
||||
|
||||
if (hasNEI) {
|
||||
this.rows--;
|
||||
}
|
||||
|
||||
if (this.rows < 3) {
|
||||
this.rows = 3;
|
||||
}
|
||||
|
||||
this.getMeSlots().clear();
|
||||
for (int y = 0; y < this.rows; y++) {
|
||||
for (int x = 0; x < this.perRow; x++) {
|
||||
this.getMeSlots().add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) {
|
||||
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
|
||||
} else {
|
||||
this.xSize = this.standardSize;
|
||||
}
|
||||
|
||||
super.initGui();
|
||||
// full size : 204
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
|
||||
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
|
||||
// this.guiTop = top;
|
||||
final int unusedSpace = this.height - this.ySize;
|
||||
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
|
||||
|
||||
int offset = this.guiTop + 8;
|
||||
|
||||
if (this.customSortOrder) {
|
||||
this.buttonList.add(this.SortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
// this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
|
||||
// offset += 20;
|
||||
|
||||
this.buttonList.add(this.SortDirBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting(Settings.SORT_DIRECTION)));
|
||||
offset += 20;
|
||||
|
||||
this.buttonList.add(this.searchBoxSettings = new GuiImgButton(this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
|
||||
offset += 20;
|
||||
|
||||
if (ModAndClassUtil.isSaveText) {
|
||||
this.buttonList.add(this.searchStringSave = new GuiImgButton(this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
this.buttonList.add(this.terminalStyleBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||
offset += 20;
|
||||
|
||||
this.searchField = new FCGuiTextField(this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.searchField.setMaxStringLength(25);
|
||||
this.searchField.setTextColor(0xFFFFFF);
|
||||
this.searchField.setVisible(true);
|
||||
if (ModAndClassUtil.isSearchStringTooltip)
|
||||
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
|
||||
|
||||
if (this.viewCell) {
|
||||
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
|
||||
this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
|
||||
} else {
|
||||
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
|
||||
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
|
||||
}
|
||||
}
|
||||
|
||||
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
||||
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
|
||||
|
||||
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
|
||||
setSearchString(memoryText, false);
|
||||
}
|
||||
if (this.isSubGui()) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
craftingGridOffsetX = Integer.MAX_VALUE;
|
||||
craftingGridOffsetY = Integer.MAX_VALUE;
|
||||
|
||||
for (final Object s : this.inventorySlots.inventorySlots) {
|
||||
if (s instanceof AppEngSlot) {
|
||||
if (((Slot) s).xDisplayPosition < 195) {
|
||||
this.repositionSlot((AppEngSlot) s);
|
||||
}
|
||||
}
|
||||
|
||||
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
|
||||
final Slot g = (Slot) s;
|
||||
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
|
||||
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
|
||||
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
craftingGridOffsetX -= 25;
|
||||
craftingGridOffsetY -= 6;
|
||||
}
|
||||
|
||||
public void setSearchString(String memoryText, boolean updateView) {
|
||||
this.searchField.setText(memoryText);
|
||||
this.repo.setSearchString(memoryText);
|
||||
if (updateView) {
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752);
|
||||
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
|
||||
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
|
||||
this.searchField.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
if (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
|
||||
setSearchString("", true);
|
||||
}
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (mouseButton == 3) {
|
||||
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
|
||||
if (slot.getHasStack()) {
|
||||
InventoryAction action = InventoryAction.valueOf("SET_PATTERN_VALUE");
|
||||
IAEItemStack stack = AEItemStack.create(slot.getStack());
|
||||
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slot instanceof SlotFake) {
|
||||
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
|
||||
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
|
||||
action = InventoryAction.MOVE_REGION;
|
||||
} else {
|
||||
action = InventoryAction.PICKUP_SINGLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot instanceof SlotPatternTerm) {
|
||||
if (mouseButton == 6) {
|
||||
return; // prevent weird double clicks..
|
||||
}
|
||||
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
} else if (slot instanceof SlotCraftingTerm) {
|
||||
if (mouseButton == 6) {
|
||||
return; // prevent weird double clicks..
|
||||
}
|
||||
|
||||
InventoryAction action;
|
||||
if (isShiftKeyDown()) {
|
||||
action = InventoryAction.CRAFT_SHIFT;
|
||||
} else {
|
||||
// Craft stack on right-click, craft single on left-click
|
||||
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
|
||||
}
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
|
||||
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
|
||||
IAEItemStack stack = null;
|
||||
if (slot instanceof SlotME) {
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
}
|
||||
|
||||
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
|
||||
|
||||
if (!(slot instanceof SlotME) && slot != null) {
|
||||
slotNum = slot.slotNumber;
|
||||
}
|
||||
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slot instanceof SlotDisconnected) {
|
||||
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryAction action = null;
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0: // pickup / set-down.
|
||||
{
|
||||
ItemStack heldStack = player.inventory.getItemStack();
|
||||
if (slot.getStack() == null && heldStack != null)
|
||||
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
|
||||
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
|
||||
action = InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if (action != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot instanceof SlotME) {
|
||||
InventoryAction action = null;
|
||||
IAEItemStack stack = null;
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null) {
|
||||
action = InventoryAction.AUTO_CRAFT;
|
||||
}
|
||||
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
if (stack.getItem() instanceof ItemFluidDrop) {
|
||||
stack = ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
|
||||
}
|
||||
if (stack != null && stack.isCraftable()) {
|
||||
action = InventoryAction.AUTO_CRAFT;
|
||||
} else if (player.capabilities.isCreativeMode) {
|
||||
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
|
||||
if (slotItem != null) {
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if (action == InventoryAction.AUTO_CRAFT) {
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
|
||||
} else if (action != null) {
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
memoryText = this.searchField.getText();
|
||||
}
|
||||
|
||||
public void bindTextureBack(final String file) {
|
||||
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
|
||||
this.mc.getTextureManager().bindTexture(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
|
||||
this.bindTextureBack(this.getBackground());
|
||||
final int x_width = 195;
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
|
||||
|
||||
if (this.viewCell) {
|
||||
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
|
||||
}
|
||||
|
||||
for (int x = 0; x < this.rows; x++) {
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset);
|
||||
|
||||
if (this.viewCell) {
|
||||
boolean update = false;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot(i).getStack()) {
|
||||
update = true;
|
||||
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot(i).getStack();
|
||||
}
|
||||
}
|
||||
|
||||
if (update) {
|
||||
this.repo.setViewCell(this.myCurrentViewCells);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.searchField != null) {
|
||||
this.searchField.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "gui/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPowered() {
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows() {
|
||||
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (character == ' ' && this.searchField.getText().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.searchField.textboxKeyTyped(character, key)) {
|
||||
this.repo.setSearchString(this.searchField.getText());
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
} else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
this.repo.setPower(this.monitorableContainer.isPowered());
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum<?> getSortBy() {
|
||||
return this.configSrc.getSetting(Settings.SORT_BY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum<?> getSortDir() {
|
||||
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum<?> getSortDisplay() {
|
||||
return this.configSrc.getSetting(Settings.VIEW_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
|
||||
if (this.SortByBox != null) {
|
||||
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
|
||||
}
|
||||
|
||||
if (this.SortDirBox != null) {
|
||||
this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
|
||||
}
|
||||
|
||||
if (this.ViewBox != null) {
|
||||
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
|
||||
}
|
||||
|
||||
this.repo.updateView();
|
||||
}
|
||||
|
||||
public int getReservedSpace() {
|
||||
return this.reservedSpace;
|
||||
}
|
||||
|
||||
public void setReservedSpace(final int reservedSpace) {
|
||||
this.reservedSpace = reservedSpace;
|
||||
}
|
||||
|
||||
public boolean isCustomSortOrder() {
|
||||
return this.customSortOrder;
|
||||
}
|
||||
|
||||
public void setCustomSortOrder(final boolean customSortOrder) {
|
||||
this.customSortOrder = customSortOrder;
|
||||
}
|
||||
|
||||
public int getStandardSize() {
|
||||
return this.standardSize;
|
||||
}
|
||||
|
||||
public void setStandardSize(final int standardSize) {
|
||||
this.standardSize = standardSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
|
||||
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
|
||||
}
|
||||
|
||||
public boolean isOverSearchField(int x, int y) {
|
||||
return searchField.isMouseIn(x, y);
|
||||
}
|
||||
|
||||
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
|
||||
|
||||
if (this.viewCell) {
|
||||
int rw = 33;
|
||||
int rh = 14 + myCurrentViewCells.length * 18;
|
||||
|
||||
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int rx = this.guiLeft + this.xSize;
|
||||
int ry = this.guiTop + 0;
|
||||
|
||||
rw += rx;
|
||||
rh += ry;
|
||||
tw += tx;
|
||||
th += ty;
|
||||
|
||||
// overflow || intersect
|
||||
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import appeng.helpers.Reflected;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketCraftRequest;
|
||||
@@ -74,8 +75,7 @@ public class GuiFluidCraftAmount extends AEBaseGui
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( target instanceof PartFluidPatternTerminal)
|
||||
{
|
||||
if (target instanceof PartFluidPatternTerminal) {
|
||||
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
@@ -83,16 +83,19 @@ public class GuiFluidCraftAmount extends AEBaseGui
|
||||
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
if( this.originalGui != null && myIcon != null )
|
||||
{
|
||||
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
if (target instanceof PartFluidTerminal) {
|
||||
myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
}
|
||||
|
||||
this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class );
|
||||
this.amountToCraft.setEnableBackgroundDrawing( false );
|
||||
this.amountToCraft.setMaxStringLength( 16 );
|
||||
this.amountToCraft.setTextColor( 0xFFFFFF );
|
||||
if (this.originalGui != null && myIcon != null) {
|
||||
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
|
||||
}
|
||||
|
||||
this.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible( true );
|
||||
this.amountToCraft.setFocused( true );
|
||||
this.amountToCraft.setText( "1" );
|
||||
|
||||
+6
@@ -5,6 +5,7 @@ import appeng.client.gui.implementations.GuiCraftingStatus;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
@@ -29,6 +30,9 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
|
||||
else if (host instanceof PartFluidTerminal) {
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
|
||||
}
|
||||
super.initGui();
|
||||
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
|
||||
}
|
||||
@@ -40,6 +44,8 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
else if (host instanceof PartFluidTerminal)
|
||||
InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidTerminal;
|
||||
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GuiFluidTerminal extends GuiBaseFluidTerminal {
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
public ContainerFluidTerminal container;
|
||||
|
||||
public GuiFluidTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new FCBaseFluidMonitorContain(inventoryPlayer, te));
|
||||
this.container = new ContainerFluidTerminal(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_146977_a(final Slot s) {
|
||||
if (drawSlot0(s))
|
||||
super.func_146977_a(s);
|
||||
}
|
||||
|
||||
|
||||
public boolean drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotME) {
|
||||
AEItemStack stack = AEItemStack.create(slot.getStack());
|
||||
if (stack == null) return true;
|
||||
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
|
||||
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
|
||||
IAEItemStack fake = stack.copy();
|
||||
fake.setStackSize(fluidStack.amount);
|
||||
stackSizeRenderer.setAeStack(fake);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void drawWidget(int posX, int posY, Fluid fluid) {
|
||||
Minecraft.getMinecraft().renderEngine
|
||||
.bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if (fluid != null && fluid.getIcon() != null) {
|
||||
GL11.glColor3f((fluid.getColor() >> 16 & 0xFF) / 255.0F, (fluid.getColor() >> 8 & 0xFF) / 255.0F, (fluid.getColor() & 0xFF) / 255.0F);
|
||||
drawTexturedModelRectFromIcon(posX, posY,
|
||||
fluid.getIcon(), 16, 16);
|
||||
}
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof SlotME && Util.FluidUtil.isFluidContainer(player.inventory.getItemStack())) {
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
ItemStack itemStack = this.player.inventory.getItemStack().copy();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
|
||||
if (!isShiftKeyDown()) {
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
|
||||
}
|
||||
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
|
||||
}
|
||||
|
||||
public void update(ItemStack itemStack) {
|
||||
this.player.inventory.setItemStack(itemStack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerFluidTerminal extends FCBaseFluidMonitorContain {
|
||||
public ContainerFluidTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
}
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketMEInventoryUpdate;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
private final IMEMonitor<IAEFluidStack> monitor;
|
||||
private final IItemList<IAEFluidStack> items = AEApi.instance().storage().createFluidList();
|
||||
private final IConfigManager clientCM;
|
||||
private final ITerminalHost host;
|
||||
@GuiSync(99)
|
||||
public boolean canAccessViewCells = false;
|
||||
@GuiSync(98)
|
||||
public boolean hasPower = false;
|
||||
private IConfigManagerHost gui;
|
||||
private IConfigManager serverCM;
|
||||
private IGridNode networkNode;
|
||||
|
||||
public FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
this(ip, monitorable, true);
|
||||
}
|
||||
|
||||
protected FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
|
||||
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null);
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager(this);
|
||||
|
||||
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
|
||||
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
if (Platform.isServer()) {
|
||||
this.serverCM = monitorable.getConfigManager();
|
||||
|
||||
this.monitor = monitorable.getFluidInventory();
|
||||
if (this.monitor != null) {
|
||||
this.monitor.addListener(this, null);
|
||||
|
||||
// this.setCellInventory( this.monitor );
|
||||
|
||||
if (monitorable instanceof IPortableCell) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IMEChest) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IGridHost) {
|
||||
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (node != null) {
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if (g != null) {
|
||||
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.monitor = null;
|
||||
}
|
||||
|
||||
this.canAccessViewCells = false;
|
||||
if (monitorable instanceof IViewCellStorage) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
this.cellView[y] = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.VIEW_CELL, ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer());
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
this.addSlotToContainer(this.cellView[y]);
|
||||
}
|
||||
}
|
||||
|
||||
if (bindInventory) {
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public IGridNode getNetworkNode() {
|
||||
return this.networkNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack() && Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
|
||||
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer()) {
|
||||
if (this.monitor != this.host.getFluidInventory()) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
for (final Settings set : this.serverCM.getSettings()) {
|
||||
final Enum<?> sideLocal = this.serverCM.getSetting(set);
|
||||
final Enum<?> sideRemote = this.clientCM.getSetting(set);
|
||||
|
||||
if (sideLocal != sideRemote) {
|
||||
this.clientCM.putSetting(set, sideLocal);
|
||||
for (final Object crafter : this.crafters) {
|
||||
try {
|
||||
NetworkHandler.instance.sendTo(new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
|
||||
|
||||
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
|
||||
|
||||
for (final IAEFluidStack is : this.items) {
|
||||
final IAEFluidStack send = monitorCache.findPrecise(is);
|
||||
if (send == null) {
|
||||
is.setStackSize(0);
|
||||
piu.appendFluid(is);
|
||||
} else {
|
||||
piu.appendFluid(send);
|
||||
}
|
||||
}
|
||||
|
||||
if (!piu.isEmpty()) {
|
||||
this.items.resetStatus();
|
||||
|
||||
for (final Object c : this.crafters) {
|
||||
if (c instanceof EntityPlayer) {
|
||||
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.updatePowerStatus();
|
||||
|
||||
final boolean oldAccessible = this.canAccessViewCells;
|
||||
this.canAccessViewCells =
|
||||
this.host instanceof WirelessTerminalGuiObject
|
||||
|| this.hasAccess(SecurityPermissions.BUILD, false);
|
||||
if (this.canAccessViewCells != oldAccessible) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
if (this.cellView[y] != null) {
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updatePowerStatus() {
|
||||
try {
|
||||
if (this.networkNode != null) {
|
||||
this.setPowered(this.networkNode.isActive());
|
||||
} else if (this.getPowerSource() instanceof IEnergyGrid) {
|
||||
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
|
||||
} else {
|
||||
this.setPowered(this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
|
||||
if (field.equals("canAccessViewCells")) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
if (this.cellView[y] != null) {
|
||||
this.cellView[y].setAllowEdit(this.canAccessViewCells);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.onUpdate(field, oldValue, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(final ICrafting c) {
|
||||
super.addCraftingToCrafters(c);
|
||||
this.queueInventory(c);
|
||||
}
|
||||
|
||||
private void queueInventory(final ICrafting c) {
|
||||
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
|
||||
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate(true);
|
||||
final IItemList<IAEFluidStack> monitorCache = this.monitor.getStorageList();
|
||||
|
||||
for (final IAEFluidStack send : monitorCache) {
|
||||
try {
|
||||
piu.appendFluid(send);
|
||||
} catch (final BufferOverflowException boe) {
|
||||
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
|
||||
|
||||
piu = new SPacketMEInventoryUpdate(true);
|
||||
piu.appendFluid(send);
|
||||
}
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(final EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
if (this.monitor != null) {
|
||||
this.monitor.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
if (Platform.isServer()) {
|
||||
return this.serverCM;
|
||||
}
|
||||
return this.clientCM;
|
||||
}
|
||||
|
||||
public ItemStack[] getViewCells() {
|
||||
final ItemStack[] list = new ItemStack[this.cellView.length];
|
||||
|
||||
for (int x = 0; x < this.cellView.length; x++) {
|
||||
list[x] = this.cellView[x].getStack();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public SlotRestrictedInput getCellViewSlot(final int index) {
|
||||
return this.cellView[index];
|
||||
}
|
||||
|
||||
public boolean isPowered() {
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
private void setPowered(final boolean isPowered) {
|
||||
this.hasPower = isPowered;
|
||||
}
|
||||
|
||||
private IConfigManagerHost getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public void setGui(@Nonnull final IConfigManagerHost gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
|
||||
for (final IAEFluidStack is : change) {
|
||||
this.items.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(ItemStack is) {
|
||||
if (is.stackSize <= 0) return;
|
||||
ItemStack itemStack = is.copy();
|
||||
int i = itemStack.getMaxStackSize();
|
||||
while (itemStack.stackSize > 0) {
|
||||
if (i > itemStack.stackSize) {
|
||||
if (!getPlayerInv().addItemStackToInventory(itemStack.copy())) {
|
||||
getPlayerInv().player.entityDropItem(itemStack.copy(), 0);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
itemStack.stackSize -= i;
|
||||
ItemStack item = itemStack.copy();
|
||||
item.stackSize = i;
|
||||
if (!getPlayerInv().addItemStackToInventory(item)) {
|
||||
getPlayerInv().player.entityDropItem(item, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(ItemStack itemStack, int stackSize) {
|
||||
if (itemStack.stackSize <= 0) return;
|
||||
ItemStack is = itemStack.copy();
|
||||
is.stackSize = stackSize;
|
||||
this.dropItem(is);
|
||||
}
|
||||
|
||||
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) {
|
||||
for (IAEFluidStack fluid : change) {
|
||||
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
|
||||
ItemStack out = fluidContainer.copy();
|
||||
out.stackSize = 1;
|
||||
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
|
||||
// add fluid to tanks
|
||||
if (nfluid.getStackSize() <= 0) continue;
|
||||
final IAEFluidStack toExtract = nfluid.copy();
|
||||
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
|
||||
if (fillStack.right == null || fillStack.left <= 0) continue;
|
||||
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
|
||||
IAEFluidStack tmp = this.host.getFluidInventory().extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
|
||||
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
|
||||
this.dropItem(fillStack.right);
|
||||
out.stackSize = fillStack.right.stackSize;
|
||||
if (fillStack.right.getItem() instanceof IFluidContainerItem) {
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
if ((int) (tmp.getStackSize() % fillStack.left) > 0) {
|
||||
((IFluidContainerItem) fillStack.right.getItem()).drain(fillStack.right, fillStack.left - (int) (tmp.getStackSize() % fillStack.left), true);
|
||||
this.dropItem(fillStack.right, 1);
|
||||
out.stackSize++;
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(fillStack.right)) {
|
||||
toExtract.setStackSize((long) fillStack.right.stackSize * fillStack.left);
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
}
|
||||
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
|
||||
// add fluid to ae network
|
||||
FluidStack fluidStack = Util.getFluidFromItem(fluidContainer);
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
|
||||
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
|
||||
final IAEFluidStack notInserted = this.host.getFluidInventory().injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
MutablePair<Integer, ItemStack> drainStack = Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack());
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
if (fluidStack.amount == notInserted.getStackSize()) continue;
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
|
||||
if (drainStack.left > aeFluidStack.getStackSize() && FluidContainerRegistry.isContainer(drainStack.right)) {
|
||||
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
|
||||
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
continue;
|
||||
}
|
||||
|
||||
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item
|
||||
out.stackSize = ((int) (notInserted.getStackSize()) / drainStack.left);
|
||||
if (drainStack.right.getItem() instanceof IFluidContainerItem) {
|
||||
if (notInserted.getStackSize() % drainStack.left > 0) {
|
||||
fluidStack.amount = (int) (notInserted.getStackSize() % drainStack.left);
|
||||
((IFluidContainerItem) drainStack.right.getItem()).fill(drainStack.right, fluidStack, true);
|
||||
this.dropItem(drainStack.right, 1);
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(drainStack.right)) {
|
||||
if (notInserted.getStackSize() % drainStack.left > 0) {
|
||||
aeFluidStack.setStackSize(aeFluidStack.getStackSize() % drainStack.left);
|
||||
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
out.stackSize++;
|
||||
}
|
||||
}
|
||||
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
|
||||
} else {
|
||||
out.stackSize = (int) (fluidContainer.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
|
||||
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
|
||||
if (slotIndex == -1) out.stackSize++;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (slotIndex == -1) {
|
||||
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
|
||||
if (player.inventory.getItemStack().stackSize > 0) {
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()), (EntityPlayerMP) player);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
for (final Object c : this.crafters) {
|
||||
if (c instanceof ICrafting) {
|
||||
final ICrafting cr = (ICrafting) c;
|
||||
this.queueInventory(cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
|
||||
if (this.getGui() != null) {
|
||||
this.getGui().updateSetting(manager, settingName, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* 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.client.me;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.util.FluidSorters;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class FluidRepo extends ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
|
||||
private final ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private String searchString = "";
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private String innerSearch = "";
|
||||
private String NEIWord = null;
|
||||
private boolean hasPower;
|
||||
|
||||
public FluidRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
super(src, sortSrc);
|
||||
this.src = src;
|
||||
this.sortSrc = sortSrc;
|
||||
}
|
||||
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.view.get(idx);
|
||||
}
|
||||
|
||||
public ItemStack getItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.dsp.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.dsp.get(idx);
|
||||
}
|
||||
|
||||
void setSearch(final String search) {
|
||||
this.searchString = search == null ? "" : search;
|
||||
}
|
||||
|
||||
public void postUpdate(final IAEItemStack is) {
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(is);
|
||||
IAEItemStack i = AEItemStack.create(is.getItemStack().setStackDisplayName(fluid.getFluid().getLocalizedName()));
|
||||
final IAEItemStack st = this.list.findPrecise(i);
|
||||
if (st != null) {
|
||||
st.reset();
|
||||
st.add(i);
|
||||
} else {
|
||||
this.list.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void setViewCell(final ItemStack[] list) {
|
||||
this.myPartitionList = ItemViewCell.createFilter(list);
|
||||
this.updateView();
|
||||
}
|
||||
|
||||
public void updateView() {
|
||||
this.view.clear();
|
||||
this.dsp.clear();
|
||||
|
||||
this.view.ensureCapacity(this.list.size());
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) {
|
||||
this.updateNEI(this.searchString);
|
||||
}
|
||||
|
||||
this.innerSearch = this.searchString;
|
||||
final boolean terminalSearchToolTips =
|
||||
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
|
||||
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
|
||||
|
||||
boolean searchMod = false;
|
||||
if (this.innerSearch.startsWith("@")) {
|
||||
searchMod = true;
|
||||
this.innerSearch = this.innerSearch.substring(1);
|
||||
}
|
||||
|
||||
Pattern m = null;
|
||||
try {
|
||||
m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable ignore) {
|
||||
try {
|
||||
m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE);
|
||||
} catch (final Throwable __) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean notDone = false;
|
||||
for (IAEItemStack is : this.list) {
|
||||
if (this.myPartitionList != null) {
|
||||
if (!this.myPartitionList.isListed(is)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE) {
|
||||
is = is.copy();
|
||||
is.setStackSize(0);
|
||||
}
|
||||
|
||||
if (viewMode == ViewItems.STORED && is.getStackSize() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String dspName = searchMod ? Util.getFluidModID(ItemFluidDrop.getAeFluidStack(is).getFluid()) : ItemFluidDrop.getAeFluidStack(is).getFluid().getLocalizedName();
|
||||
|
||||
if (m.matcher(dspName.toLowerCase()).find()) {
|
||||
this.view.add(is);
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) {
|
||||
* view.add( is ); notDone = false; } }
|
||||
*/
|
||||
}
|
||||
|
||||
final Enum SortBy = this.sortSrc.getSortBy();
|
||||
final Enum SortDir = this.sortSrc.getSortDir();
|
||||
|
||||
FluidSorters.setDirection((appeng.api.config.SortDir) SortDir);
|
||||
FluidSorters.init();
|
||||
|
||||
if (SortBy == SortOrder.MOD) {
|
||||
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_MOD);
|
||||
} else if (SortBy == SortOrder.AMOUNT) {
|
||||
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_SIZE);
|
||||
} else if (SortBy == SortOrder.INVTWEAKS) {
|
||||
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS);
|
||||
} else {
|
||||
Collections.sort(this.view, FluidSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNEI(final String filter) {
|
||||
try {
|
||||
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
|
||||
final Class c =
|
||||
ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
|
||||
final Field fldSearchField = c.getField("searchField");
|
||||
final Object searchField = fldSearchField.get(c);
|
||||
|
||||
final Method a = searchField.getClass().getMethod("setText", String.class);
|
||||
final Method b = searchField.getClass().getMethod("onTextChange", String.class);
|
||||
|
||||
this.NEIWord = filter;
|
||||
a.invoke(searchField, filter);
|
||||
b.invoke(searchField, "");
|
||||
}
|
||||
} catch (final Throwable ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.view.size();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.list.resetStatus();
|
||||
}
|
||||
|
||||
public boolean hasPower() {
|
||||
return this.hasPower;
|
||||
}
|
||||
|
||||
public void setPower(final boolean hasPower) {
|
||||
this.hasPower = hasPower;
|
||||
}
|
||||
|
||||
public int getRowSize() {
|
||||
return this.rowSize;
|
||||
}
|
||||
|
||||
public void setRowSize(final int rowSize) {
|
||||
this.rowSize = rowSize;
|
||||
}
|
||||
|
||||
public String getSearchString() {
|
||||
return this.searchString;
|
||||
}
|
||||
|
||||
public void setSearchString(@Nonnull final String searchString) {
|
||||
this.searchString = searchString;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public enum FCPartsTexture {
|
||||
|
||||
PartFluidTerminal_Bright("fluid_terminal_bright"), PartFluidTerminal_Dark("fluid_terminal_dark"), PartFluidTerminal_Colored("fluid_terminal_medium"),
|
||||
PartFluidPatternTerminal_Bright("pattern_terminal_bright"), PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
|
||||
PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"),
|
||||
PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"),
|
||||
@@ -19,7 +19,7 @@ public enum FCPartsTexture {
|
||||
private final String name;
|
||||
public net.minecraft.util.IIcon IIcon;
|
||||
|
||||
FCPartsTexture( final String name )
|
||||
FCPartsTexture(final String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,19 @@ public class ItemFluidDrop extends Item {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack newStack1(FluidStack fluid) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ItemAndBlockHolder.DROP, fluid.amount);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("Fluid", fluid.getFluid().getName());
|
||||
stack.setTagCompound(tag);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStack(ItemStack stack) {
|
||||
if (stack == null|| stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) {
|
||||
if (stack == null || stack.getItem() != ItemAndBlockHolder.DROP || !stack.hasTagCompound()) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidTerminal;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
|
||||
public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
public ItemPartFluidTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_TERMINAL);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PartFluidTerminal createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidTerminal(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(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
|
||||
}
|
||||
|
||||
public ItemPartFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister _iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PartFluidTerminal extends FCBasePart {
|
||||
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright;
|
||||
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Dark;
|
||||
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidTerminal_Colored;
|
||||
|
||||
public PartFluidTerminal(ItemStack is) {
|
||||
super(is, true);
|
||||
}
|
||||
|
||||
@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 boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
TileEntity te = this.getTile();
|
||||
BlockPos tePos = new BlockPos(te);
|
||||
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
|
||||
return super.onPartActivate(player, pos);
|
||||
}
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this) || Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), GuiType.FLUID_TERMINAL);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGui(final EntityPlayer p) {
|
||||
int x = (int) p.posX;
|
||||
int y = (int) p.posY;
|
||||
int z = (int) p.posZ;
|
||||
if (this.getHost().getTile() != null) {
|
||||
x = this.getTile().xCoord;
|
||||
y = this.getTile().yCoord;
|
||||
z = this.getTile().zCoord;
|
||||
}
|
||||
|
||||
if (GuiBridge.GUI_WIRELESS_TERM.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
|
||||
return GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
return GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -133,9 +133,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewFluid() {
|
||||
final long bytesFree = this.getFreeBytes();
|
||||
|
||||
return ( bytesFree > this.getBytesPerType() || ( bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0 ) ) && this.getRemainingFluidTypes() > 0;
|
||||
return this.getRemainingFluidCount() > 0 && getRemainingFluidTypes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,8 +148,10 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
final long bytesForItemCount = ( this.getStoredFluidCount() + this.getUnusedFluidCount() ) / 8 / 256;
|
||||
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount;
|
||||
long bytesForItemCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / (8 * 256);
|
||||
long tmp = this.getStoredFluidTypes() * this.getBytesPerType() + bytesForItemCount;
|
||||
if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,7 +178,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
final long remaining = this.getFreeBytes() * 8 * 256 + this.getUnusedFluidCount();
|
||||
final long remaining = (this.getTotalBytes() - (this.getTotalFluidTypes() * 8)) * 8 * 256 - this.getStoredFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,6 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.updateFluidCount( remainingItemSlots );
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -152,6 +152,18 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new ContainerFluidTerminal(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ITerminalHost inv) {
|
||||
return new GuiFluidTerminal(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
FLUID_PATTERN_TERMINAL(new PartGuiFactory<ITerminalHost>(ITerminalHost.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ITerminalHost inv) {
|
||||
|
||||
@@ -20,6 +20,7 @@ public class ChannelLoader implements Runnable {
|
||||
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.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketPatternValueSet.Handler(), CPacketPatternValueSet.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id++, Side.SERVER);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public class ItemAndBlockHolder {
|
||||
|
||||
public static ItemFluidDrop DROP = new ItemFluidDrop().register();
|
||||
public static ItemFluidEncodedPattern PATTERN = new ItemFluidEncodedPattern().register();
|
||||
public static ItemPartFluidTerminal FLUID_TERM = new ItemPartFluidTerminal().register();
|
||||
public static ItemPartFluidPatternTerminal FLUID_TERMINAL = new ItemPartFluidPatternTerminal().register();
|
||||
public static ItemPartFluidPatternTerminalEx FLUID_TERMINAL_EX = new ItemPartFluidPatternTerminalEx().register();
|
||||
public static ItemPartFluidInterface FLUID_INTERFACE = new ItemPartFluidInterface().register();
|
||||
|
||||
@@ -34,6 +34,7 @@ public class RecipeLoader implements Runnable {
|
||||
public final static ItemStack AE2_CORE_FOM = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43);
|
||||
public final static ItemStack PISTON = new ItemStack(Blocks.piston, 1);
|
||||
public final static ItemStack AE2_BLANK_PATTERN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 52);
|
||||
public final static ItemStack AE2_TERMINAL = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiPart"), 1, 380);
|
||||
public final static ItemStack BUCKET = new ItemStack(Items.bucket, 1);
|
||||
public final static ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1);
|
||||
|
||||
@@ -49,7 +50,8 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.addShapelessRecipe(FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(BUFFER.stack(), "ILI", "AGF", "IBI", 'I', "ingotIron", 'G', AE2_QUARTZ_GLASS, 'L', AE2_CELL_1K, 'A', AE2_CORE_ANN, 'F', AE2_CORE_FOM, 'B', BUCKET));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(LARGE_BUFFER.stack(), "BGB", "GEG", "BGB", 'B', BUFFER.stack(), 'G', AE2_QUARTZ_GLASS, 'E', AE2_PROCESS_ENG));
|
||||
GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN,PATTERN.stack());
|
||||
GameRegistry.addShapelessRecipe(AE2_BLANK_PATTERN, PATTERN.stack());
|
||||
GameRegistry.addShapelessRecipe(FLUID_TERM.stack(), AE2_TERMINAL, BUFFER);
|
||||
if (Config.fluidCells) {
|
||||
OreDictionary.registerOre("anyCertusCrystal", AE2_PURE_CERTUS);
|
||||
for (ItemStack it : OreDictionary.getOres("crystalCertusQuartz"))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.glodblock.github.nei;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
import com.glodblock.github.client.gui.GuiFCBaseFluidMonitor;
|
||||
import com.glodblock.github.client.gui.GuiFCBaseMonitor;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
@@ -10,6 +11,8 @@ public class NEIGuiHandler extends INEIGuiAdapter {
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
if (gui instanceof GuiFCBaseMonitor) {
|
||||
return ((GuiFCBaseMonitor) gui).hideItemPanelSlot(x, y, w, h);
|
||||
} else if (gui instanceof GuiFCBaseFluidMonitor) {
|
||||
return ((GuiFCBaseFluidMonitor) gui).hideItemPanelSlot(x, y, w, h);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.container.FCBaseFluidMonitorContain;
|
||||
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 net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CPacketFluidUpdate implements IMessage {
|
||||
|
||||
private Map<Integer, IAEFluidStack> list;
|
||||
private ItemStack itemStack;
|
||||
private int slotIndex;
|
||||
|
||||
public CPacketFluidUpdate() {
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack) {
|
||||
this.list = data;
|
||||
this.itemStack = itemStack;
|
||||
this.slotIndex = -1;
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
|
||||
this.list = data;
|
||||
}
|
||||
|
||||
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack, int slotIndex) {
|
||||
this.list = data;
|
||||
this.itemStack = itemStack;
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull)
|
||||
list.put(id, null);
|
||||
else {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
if (buf.readBoolean()) {
|
||||
this.itemStack = AEItemStack.loadItemStackFromPacket(buf).getItemStack();
|
||||
this.slotIndex = buf.readInt();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(list.size());
|
||||
try {
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
if (fs.getValue() == null)
|
||||
buf.writeBoolean(false);
|
||||
else {
|
||||
buf.writeBoolean(true);
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
if (this.itemStack != null) {
|
||||
buf.writeBoolean(true);
|
||||
AEItemStack.create(itemStack).writeToPacket(buf);
|
||||
buf.writeInt(this.slotIndex);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketFluidUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketFluidUpdate message, MessageContext ctx) {
|
||||
Container container = ctx.getServerHandler().playerEntity.openContainer;
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (container instanceof FCBaseFluidMonitorContain) {
|
||||
ItemStack item = player.inventory.getItemStack();
|
||||
((FCBaseFluidMonitorContain) container).postChange(new ArrayList<IAEFluidStack>(message.list.values()), message.itemStack == null ? item : message.itemStack, player, message.slotIndex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.gui.GuiFluidIO;
|
||||
import com.glodblock.github.client.gui.GuiFluidInterface;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLargeIngredientBuffer;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -20,12 +20,24 @@ import java.util.Map;
|
||||
public class SPacketFluidUpdate implements IMessage {
|
||||
|
||||
private Map<Integer, IAEFluidStack> list;
|
||||
private IAEItemStack itemStack;
|
||||
|
||||
public SPacketFluidUpdate() {
|
||||
}
|
||||
|
||||
public SPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
|
||||
this.list = data;
|
||||
this.itemStack = null;
|
||||
}
|
||||
|
||||
public SPacketFluidUpdate(Map<Integer, IAEFluidStack> data, IAEItemStack itemStack) {
|
||||
this.list = data;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
public SPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack) {
|
||||
this.list = data;
|
||||
this.itemStack = AEItemStack.create(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -33,7 +45,7 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i ++) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull)
|
||||
@@ -43,6 +55,9 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
if (buf.readBoolean()) {
|
||||
this.itemStack = AEItemStack.loadItemStackFromPacket(buf);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -61,6 +76,13 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
if (this.itemStack != null) {
|
||||
buf.writeBoolean(true);
|
||||
this.itemStack.writeToPacket(buf);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -86,8 +108,14 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
( (GuiFluidIO) gs ).update(e.getKey(), e.getValue());
|
||||
}
|
||||
} else if (gs instanceof GuiFluidInterface) {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
|
||||
( (GuiFluidInterface) gs ).update(e.getKey(), e.getValue());
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
|
||||
((GuiFluidInterface) gs).update(e.getKey(), e.getValue());
|
||||
}
|
||||
} else if (gs instanceof GuiFluidTerminal) {
|
||||
if (message.itemStack != null) {
|
||||
((GuiFluidTerminal) gs).update(message.itemStack.getItemStack());
|
||||
} else {
|
||||
((GuiFluidTerminal) gs).update(null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.GuiFCBaseFluidMonitor;
|
||||
import com.glodblock.github.client.gui.GuiFCBaseMonitor;
|
||||
import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -18,27 +21,39 @@ import java.util.List;
|
||||
|
||||
public class SPacketMEInventoryUpdate implements IMessage {
|
||||
|
||||
private List<IAEItemStack> list;
|
||||
private List<Object> list;
|
||||
private byte ref;
|
||||
private boolean isFluid = false;
|
||||
|
||||
public SPacketMEInventoryUpdate() {
|
||||
ref = 0;
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
public SPacketMEInventoryUpdate(Boolean isFluid) {
|
||||
ref = 0;
|
||||
list = new LinkedList<>();
|
||||
this.isFluid = isFluid;
|
||||
}
|
||||
|
||||
public SPacketMEInventoryUpdate(byte b) {
|
||||
this.ref = b;
|
||||
ref = b;
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
isFluid = buf.readBoolean();
|
||||
long amount = buf.readLong();
|
||||
ref = buf.readByte();
|
||||
list = new LinkedList<>();
|
||||
try {
|
||||
for (int i = 0; i < amount; i ++) {
|
||||
list.add(AEItemStack.loadItemStackFromPacket(buf));
|
||||
if (isFluid) {
|
||||
list.add(AEFluidStack.loadFluidStackFromPacket(buf));
|
||||
} else {
|
||||
list.add(AEItemStack.loadItemStackFromPacket(buf));
|
||||
}
|
||||
}
|
||||
} catch (IOException io) {
|
||||
io.printStackTrace();
|
||||
@@ -47,18 +62,28 @@ public class SPacketMEInventoryUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
if (isFluid) {
|
||||
buf.writeBoolean(true);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
buf.writeLong(list.size());
|
||||
buf.writeByte(ref);
|
||||
try {
|
||||
for (IAEItemStack itemStack : list) {
|
||||
itemStack.writeToPacket(buf);
|
||||
for (Object is : list) {
|
||||
if (is instanceof IAEItemStack) ((IAEItemStack) is).writeToPacket(buf);
|
||||
if (is instanceof IAEFluidStack) ((IAEFluidStack) is).writeToPacket(buf);
|
||||
}
|
||||
} catch (IOException io) {
|
||||
io.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void appendItem( final IAEItemStack is ) throws BufferOverflowException {
|
||||
public void appendItem(final IAEItemStack is) throws BufferOverflowException {
|
||||
list.add(is);
|
||||
}
|
||||
|
||||
public void appendFluid(final IAEFluidStack is) throws BufferOverflowException {
|
||||
list.add(is);
|
||||
}
|
||||
|
||||
@@ -71,12 +96,12 @@ public class SPacketMEInventoryUpdate implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(SPacketMEInventoryUpdate message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if( gs instanceof GuiFCBaseMonitor)
|
||||
{
|
||||
( (GuiFCBaseMonitor) gs ).postUpdate(message.list);
|
||||
}
|
||||
else if ( gs instanceof GuiFluidCraftConfirm) {
|
||||
( (GuiFluidCraftConfirm) gs ).postUpdate( message.list, message.ref );
|
||||
if (gs instanceof GuiFCBaseFluidMonitor) {
|
||||
((GuiFCBaseFluidMonitor) gs).postUpdate((List<IAEFluidStack>) (List<?>) message.list);
|
||||
} else if (gs instanceof GuiFCBaseMonitor) {
|
||||
((GuiFCBaseMonitor) gs).postUpdate((List<IAEItemStack>) (List<?>) message.list);
|
||||
} else if (gs instanceof GuiFluidCraftConfirm) {
|
||||
((GuiFluidCraftConfirm) gs).postUpdate((List<IAEItemStack>) (List<?>) message.list, message.ref);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class FluidSorters {
|
||||
private static SortDir Direction = SortDir.ASCENDING;
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_MOD = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
|
||||
final Fluid f1 = ItemFluidDrop.getAeFluidStack(o1).getFluid();
|
||||
final Fluid f2 = ItemFluidDrop.getAeFluidStack(o2).getFluid();
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return this.secondarySort(Util.getFluidModID(f2).compareToIgnoreCase(Util.getFluidModID(f1)), f1, f2);
|
||||
}
|
||||
return this.secondarySort(Util.getFluidModID(f1).compareToIgnoreCase(Util.getFluidModID(f2)), f2, f1);
|
||||
}
|
||||
|
||||
private int secondarySort(final int compareToIgnoreCase, final Fluid f1, final Fluid f2) {
|
||||
if (compareToIgnoreCase == 0) {
|
||||
return f2.getLocalizedName().compareToIgnoreCase(f1.getLocalizedName());
|
||||
}
|
||||
|
||||
return compareToIgnoreCase;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return Platform.getItemDisplayName(o1).compareToIgnoreCase(Platform.getItemDisplayName(o2));
|
||||
}
|
||||
return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1));
|
||||
}
|
||||
};
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return compareLong(o2.getStackSize(), o1.getStackSize());
|
||||
}
|
||||
return compareLong(o1.getStackSize(), o2.getStackSize());
|
||||
}
|
||||
};
|
||||
private static IInvTweaks api;
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_INV_TWEAKS = new Comparator<IAEItemStack>() {
|
||||
|
||||
@Override
|
||||
public int compare(final IAEItemStack o1, final IAEItemStack o2) {
|
||||
if (api == null) {
|
||||
return CONFIG_BASED_SORT_BY_NAME.compare(o1, o2);
|
||||
}
|
||||
|
||||
final int cmp = api.compareItems(o1.getItemStack(), o2.getItemStack());
|
||||
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return cmp;
|
||||
}
|
||||
return -cmp;
|
||||
}
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
if (api != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.InvTweaks)) {
|
||||
api = (IInvTweaks) IntegrationRegistry.INSTANCE.getInstance(IntegrationType.InvTweaks);
|
||||
} else {
|
||||
api = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareInt(final int a, final int b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int compareLong(final long a, final long b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int compareDouble(final double a, final double b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static SortDir getDirection() {
|
||||
return Direction;
|
||||
}
|
||||
|
||||
public static void setDirection(final SortDir direction) {
|
||||
Direction = direction;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public class NameConst {
|
||||
|
||||
public static final String ITEM_FLUID_DROP = "fluid_drop";
|
||||
public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern";
|
||||
public static final String ITEM_PART_FLUID_TERMINAL = "part_fluid_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";
|
||||
@@ -24,6 +25,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
|
||||
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_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";
|
||||
@@ -33,6 +35,7 @@ public class NameConst {
|
||||
public static final String RES_KEY = FluidCraft.MODID + ":";
|
||||
|
||||
public static final String GUI_KEY = FluidCraft.MODID + ".gui.";
|
||||
public static final String GUI_FLUID_TERMINAL = GUI_KEY + ITEM_PART_FLUID_TERMINAL;
|
||||
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_FLUID_PATTERN_ENCODER = GUI_KEY + BLOCK_FLUID_PATTERN_ENCODER;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
@@ -10,15 +11,13 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import net.minecraftforge.fluids.*;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
public final class Util {
|
||||
|
||||
public static EnumFacing from(ForgeDirection direction) {
|
||||
@@ -35,8 +34,10 @@ public final class Util {
|
||||
|
||||
public static ForgeDirection from(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case WEST: return ForgeDirection.EAST;
|
||||
case EAST: return ForgeDirection.WEST;
|
||||
case WEST:
|
||||
return ForgeDirection.EAST;
|
||||
case EAST:
|
||||
return ForgeDirection.WEST;
|
||||
default: {
|
||||
int o = direction.ordinal();
|
||||
return ForgeDirection.values()[o];
|
||||
@@ -44,6 +45,13 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
|
||||
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, SecurityPermissions permission, IGrid grid) {
|
||||
return grid == null || hasPermission(player, permission, (ISecurityGrid) grid.getCache(ISecurityGrid.class));
|
||||
}
|
||||
@@ -108,14 +116,23 @@ public final class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IAEFluidStack loadFluidStackFromNBT( final NBTTagCompound i )
|
||||
{
|
||||
public static String getFluidModID(Fluid fluid) {
|
||||
String name = FluidRegistry.getDefaultFluidName(fluid);
|
||||
try {
|
||||
return name.split(":")[0];
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) {
|
||||
//Fuck ae2
|
||||
final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1);
|
||||
final AEFluidStack fluid = AEFluidStack.create( t );
|
||||
fluid.setStackSize( i.getLong( "Cnt" ) );
|
||||
fluid.setCountRequestable( i.getLong( "Req" ) );
|
||||
fluid.setCraftable( i.getBoolean( "Craft" ) );
|
||||
final AEFluidStack fluid = AEFluidStack.create(t);
|
||||
fluid.setStackSize(i.getLong("Cnt"));
|
||||
fluid.setCountRequestable(i.getLong("Req"));
|
||||
fluid.setCraftable(i.getBoolean("Craft"));
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@@ -124,4 +141,156 @@ public final class Util {
|
||||
return fluid1.isFluidEqual(fluid2);
|
||||
}
|
||||
|
||||
public static class FluidUtil {
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
|
||||
return createAEFluidStack(new FluidStack(fluid,
|
||||
FluidContainerRegistry.BUCKET_VOLUME));
|
||||
}
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid, long amount) {
|
||||
return createAEFluidStack(fluid.getID(), amount);
|
||||
}
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(FluidStack fluid) {
|
||||
return AEApi.instance().storage().createFluidStack(fluid);
|
||||
}
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(int fluidId, long amount) {
|
||||
return createAEFluidStack(new FluidStack(FluidRegistry.getFluid(fluidId), 1)).setStackSize(
|
||||
amount);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack content = ((IFluidContainerItem) item)
|
||||
.getFluid(itemStack);
|
||||
return content == null || content.amount <= 0;
|
||||
}
|
||||
return FluidContainerRegistry.isEmptyContainer(itemStack);
|
||||
}
|
||||
|
||||
public static boolean isFilled(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack content = ((IFluidContainerItem) item)
|
||||
.getFluid(itemStack);
|
||||
return content != null && content.amount > 0;
|
||||
}
|
||||
return FluidContainerRegistry.isFilledContainer(itemStack);
|
||||
}
|
||||
|
||||
public static boolean isFluidContainer(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
Item item = itemStack.getItem();
|
||||
return item instanceof IFluidContainerItem
|
||||
|| FluidContainerRegistry.isContainer(itemStack);
|
||||
}
|
||||
|
||||
public static FluidStack getFluidFromContainer(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
|
||||
ItemStack container = itemStack.copy();
|
||||
Item item = container.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
return ((IFluidContainerItem) item).getFluid(container);
|
||||
} else {
|
||||
return FluidContainerRegistry.getFluidForFilledItem(container);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCapacity(ItemStack itemStack, Fluid fluid) {
|
||||
if (itemStack == null)
|
||||
return 0;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem fluidContainerItem = (IFluidContainerItem) item;
|
||||
int capacity = fluidContainerItem.getCapacity(itemStack);
|
||||
FluidStack existing = fluidContainerItem.getFluid(itemStack);
|
||||
if (existing != null) {
|
||||
if (!existing.getFluid().equals(fluid)) {
|
||||
return 0;
|
||||
}
|
||||
capacity -= existing.amount;
|
||||
}
|
||||
return capacity;
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
return FluidContainerRegistry.getContainerCapacity(new FluidStack(fluid, Integer.MAX_VALUE), itemStack);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ItemStack clearFluid(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
((IFluidContainerItem) item).drain(itemStack,
|
||||
((IFluidContainerItem) item).getFluid(itemStack).amount, true);
|
||||
return itemStack;
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
return FluidContainerRegistry.drainFluidContainer(itemStack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> drainStack(
|
||||
ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack drained = ((IFluidContainerItem) item).drain(itemStack,
|
||||
fluid.amount, true);
|
||||
int amountDrained = drained != null
|
||||
&& drained.getFluid() == fluid.getFluid() ? drained.amount
|
||||
: 0;
|
||||
return new MutablePair<Integer, ItemStack>(amountDrained, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
FluidStack content = FluidContainerRegistry
|
||||
.getFluidForFilledItem(itemStack);
|
||||
int amountDrained = content != null
|
||||
&& content.getFluid() == fluid.getFluid() ? content.amount
|
||||
: 0;
|
||||
return new MutablePair<Integer, ItemStack>(amountDrained,
|
||||
FluidContainerRegistry.drainFluidContainer(itemStack));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> fillStack(
|
||||
ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null || itemStack.stackSize != 1)
|
||||
return null;
|
||||
Item item = itemStack.getItem();
|
||||
//If its a fluid container item instance
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
//Call the fill method on it.
|
||||
int filled = ((IFluidContainerItem) item).fill(itemStack, fluid,
|
||||
true);
|
||||
|
||||
//Return the filled itemstack.
|
||||
return new MutablePair<Integer, ItemStack>(filled, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
//Fill it through the fluidcontainer registry.
|
||||
ItemStack filledContainer = FluidContainerRegistry
|
||||
.fillFluidContainer(fluid, itemStack);
|
||||
//get the filled fluidstack.
|
||||
FluidStack filled = FluidContainerRegistry
|
||||
.getFluidForFilledItem(filledContainer);
|
||||
//Return filled container and fill amount.
|
||||
return new MutablePair<Integer, ItemStack>(
|
||||
filled != null ? filled.amount : 0, filledContainer);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
item.fluid_drop.name=drop of %s
|
||||
item.fluid_encoded_pattern.name=Encode Pattern
|
||||
item.part_fluid_terminal.name=ME Fluid Terminal
|
||||
item.part_fluid_pattern_terminal.name=ME Fluid Pattern Terminal
|
||||
item.part_fluid_pattern_terminal_ex.name=ME Fluid Processing Pattern Terminal
|
||||
item.part_fluid_interface.name=ME Dual Interface
|
||||
@@ -29,6 +30,7 @@ tile.ingredient_buffer.name=Ingredient Buffer
|
||||
tile.large_ingredient_buffer.name=Large Ingredient Buffer
|
||||
tile.oc_pattern_editor.name=OC Pattern Editor
|
||||
|
||||
ae2fc.tooltip.fluid_terminal=uh So we don't need EC2 anymore?
|
||||
ae2fc.tooltip.invalid_fluid=Invalid fluid!
|
||||
ae2fc.tooltip.encode_pattern=Encode Patter
|
||||
ae2fc.tooltip.fluid_packet=Use a Fluid Packet Decoder to\nconvert this back into fluid.
|
||||
|
||||
@@ -29,6 +29,7 @@ tile.ingredient_buffer.name=原材料缓存仓
|
||||
tile.large_ingredient_buffer.name=大型原材料缓存仓
|
||||
tile.oc_pattern_editor.name=OC样板编辑器
|
||||
|
||||
ae2fc.tooltip.fluid_terminal=我们不再需要EC2了吗?
|
||||
ae2fc.tooltip.invalid_fluid=流体无效!
|
||||
ae2fc.tooltip.encode_pattern=编写样板
|
||||
ae2fc.tooltip.fluid_packet=使用ME流体封包解码器\n来将其转换回流体形式。
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 244 B |
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
Binary file not shown.
|
After Width: | Height: | Size: 203 B |
Binary file not shown.
|
After Width: | Height: | Size: 288 B |
Reference in new issue
Block a user