Dissolved the top-level fluid package (for now) and grouped Fluid classes with their item counterparts to facilitate easier refactoring later.

This commit is contained in:
Sebastian Hartte
2020-09-10 14:20:57 +02:00
parent 81cc0b804d
commit 7315a60429
62 changed files with 174 additions and 189 deletions
@@ -0,0 +1,65 @@
package appeng.client.gui.implementations;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidFormationPlaneContainer;
import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.util.fluid.IAEFluidTank;
public class FluidFormationPlaneScreen extends UpgradeableScreen<FluidFormationPlaneContainer> {
public FluidFormationPlaneScreen(FluidFormationPlaneContainer container, PlayerInventory playerInventory,
ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 251;
}
@Override
public void init() {
super.init();
final int xo = 8;
final int yo = 23 + 6;
final IAEFluidTank config = container.getFluidConfigInventory();
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
final int idx = y * 9 + x;
if (y < 2) {
this.guiSlots.add(new FluidSlotWidget(config, idx, idx, xo + x * 18, yo + y * 18));
} else {
this.guiSlots.add(new OptionalFluidSlotWidget(config, container, idx, idx, y - 2, xo, yo, x, y));
}
}
}
}
@Override
protected void addButtons() {
this.addButton(new TabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.text(),
this.itemRenderer, btn -> openPriorityGui()));
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
@Override
protected GuiText getName() {
return GuiText.FluidFormationPlane;
}
}
@@ -0,0 +1,67 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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 appeng.client.gui.implementations;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.container.implementations.FluidIOContainer;
import appeng.core.localization.GuiText;
import appeng.parts.automation.FluidImportBusPart;
import appeng.util.fluid.IAEFluidTank;
/**
* @author BrockWS
* @version rv5 - 1/05/2018
* @since rv5 1/05/2018
*/
public class FluidIOScreen extends UpgradeableScreen<FluidIOContainer> {
public FluidIOScreen(FluidIOContainer container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
}
@Override
public void init() {
super.init();
final IAEFluidTank inv = this.container.getFluidConfigInventory();
final int y = 40;
final int x = 80;
this.guiSlots.add(new FluidSlotWidget(inv, 0, 0, x, y));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 1, 1, 1, x, y, -1, 0));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 2, 2, 1, x, y, 1, 0));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 3, 3, 1, x, y, 0, -1));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 4, 4, 1, x, y, 0, 1));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 5, 5, 2, x, y, -1, -1));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 6, 6, 2, x, y, 1, -1));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 7, 7, 2, x, y, -1, 1));
this.guiSlots.add(new OptionalFluidSlotWidget(inv, container, 8, 8, 2, x, y, 1, 1));
}
@Override
protected GuiText getName() {
return this.bc instanceof FluidImportBusPart ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
}
}
@@ -0,0 +1,91 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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 appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.FluidTankWidget;
import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidInterfaceContainer;
import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.DualityFluidInterface;
import appeng.util.fluid.IAEFluidTank;
public class FluidInterfaceScreen extends UpgradeableScreen<FluidInterfaceContainer> {
public FluidInterfaceScreen(FluidInterfaceContainer container, PlayerInventory playerInventory,
ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 231;
}
@Override
public void init() {
super.init();
final IAEFluidTank configFluids = this.container.getFluidConfigInventory();
final IAEFluidTank fluidTank = this.container.getTanks();
for (int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i) {
final FluidTankWidget guiTank = new FluidTankWidget(fluidTank, i, this.getGuiLeft() + 35 + 18 * i,
this.getGuiTop() + 53, 16, 68);
this.addButton(guiTank);
this.guiSlots.add(new FluidSlotWidget(configFluids, i, i, 35 + 18 * i, 35));
}
this.addButton(new TabButton(this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.text(),
this.itemRenderer, btn -> openPriorityGui()));
}
@Override
protected void addButtons() {
}
@Override
public void drawFG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY) {
this.font.drawString(matrixStack, this.getGuiDisplayName(GuiText.FluidInterface.text()).getString(), 8, 6,
4210752);
this.font.drawString(matrixStack, GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752);
this.font.drawString(matrixStack, GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752);
this.font.drawString(matrixStack, GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) {
this.bindTexture("guis/interfacefluid.png");
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ );
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
}
@Override
protected boolean drawUpgrades() {
return false;
}
}
@@ -0,0 +1,89 @@
package appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.NumberEntryType;
import appeng.client.gui.implementations.NumberEntryWidget;
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.ServerSettingToggleButton;
import appeng.container.implementations.FluidLevelEmitterContainer;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitterContainer> {
private NumberEntryWidget level;
public FluidLevelEmitterScreen(FluidLevelEmitterContainer container, PlayerInventory playerInventory,
ITextComponent title) {
super(container, playerInventory, title);
}
@Override
public void init() {
super.init();
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_FLUID_VOLUME,
this::onLevelChange);
this.level.setTextFieldBounds(25, 44, 75);
container.setTextField(this.level);
this.level.addButtons(children::add, this::addButton);
final int y = 40;
final int x = 80 + 57;
this.guiSlots.add(new FluidSlotWidget(this.container.getFluidConfigInventory(), 0, 0, x, y));
}
@Override
protected void addButtons() {
this.redstoneMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28,
Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
this.addButton(this.redstoneMode);
}
@Override
public void drawBG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY, float partialTicks) {
super.drawBG(matrixStack, offsetX, offsetY, mouseX, mouseY, partialTicks);
this.level.render(matrixStack, mouseX, mouseY, partialTicks);
}
@Override
public void drawFG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawFG(matrixStack, offsetX, offsetY, mouseX, mouseY);
this.font.drawString(matrixStack, GuiText.FluidLevelEmitterUnit.getLocal(), 110, 44, COLOR_DARK_GRAY);
}
@Override
protected boolean drawUpgrades() {
return false;
}
@Override
protected String getBackground() {
return "guis/lvlemitter.png";
}
@Override
protected GuiText getName() {
return GuiText.FluidLevelEmitter;
}
@Override
protected void handleButtonVisibility() {
}
private void onLevelChange(long level) {
NetworkHandler.instance().sendToServer(new ConfigValuePacket("FluidLevelEmitter.Value", String.valueOf(level)));
}
}
@@ -0,0 +1,141 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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 appeng.client.gui.implementations;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.client.gui.implementations.UpgradeableScreen;
import appeng.client.gui.widgets.ActionButton;
import appeng.client.gui.widgets.FluidSlotWidget;
import appeng.client.gui.widgets.OptionalFluidSlotWidget;
import appeng.client.gui.widgets.ServerSettingToggleButton;
import appeng.client.gui.widgets.SettingToggleButton;
import appeng.client.gui.widgets.TabButton;
import appeng.container.implementations.FluidStorageBusContainer;
import appeng.container.implementations.PriorityContainer;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.util.fluid.IAEFluidTank;
/**
* @author BrockWS
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class FluidStorageBusScreen extends UpgradeableScreen<FluidStorageBusContainer> {
private SettingToggleButton<AccessRestriction> rwMode;
private SettingToggleButton<StorageFilter> storageFilter;
public FluidStorageBusScreen(FluidStorageBusContainer container, PlayerInventory playerInventory,
ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 251;
}
@Override
public void init() {
super.init();
final int xo = 8;
final int yo = 23 + 6;
final IAEFluidTank config = this.container.getFluidConfigInventory();
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
final int idx = y * 9 + x;
if (y < 2) {
this.guiSlots.add(new FluidSlotWidget(config, idx, idx, xo + x * 18, yo + y * 18));
} else {
this.guiSlots.add(new OptionalFluidSlotWidget(config, container, idx, idx, y - 2, xo, yo, x, y));
}
}
}
}
@Override
protected void addButtons() {
addButton(new ActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear()));
addButton(new ActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition()));
this.rwMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS,
AccessRestriction.READ_WRITE);
this.storageFilter = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68,
Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.fuzzyMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE,
FuzzyMode.IGNORE_ALL);
addButton(this.addButton(new TabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.text(),
this.itemRenderer, btn -> openPriorityGui())));
this.addButton(this.storageFilter);
this.addButton(this.fuzzyMode);
this.addButton(this.rwMode);
}
@Override
public void drawFG(MatrixStack matrixStack, final int offsetX, final int offsetY, final int mouseX,
final int mouseY) {
this.font.drawString(matrixStack, this.getGuiDisplayName(this.getName().text()).getString(), 8, 6, 4210752);
this.font.drawString(matrixStack, GuiText.inventory.text().getString(), 8, this.ySize - 96 + 3, 4210752);
if (this.fuzzyMode != null) {
this.fuzzyMode.set(this.cvb.getFuzzyMode());
}
if (this.storageFilter != null) {
this.storageFilter.set(((FluidStorageBusContainer) this.cvb).getStorageFilter());
}
if (this.rwMode != null) {
this.rwMode.set(((FluidStorageBusContainer) this.cvb).getReadWriteMode());
}
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
private void partition() {
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Partition"));
}
private void clear() {
NetworkHandler.instance().sendToServer(new ConfigValuePacket("StorageBus.Action", "Clear"));
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer(new SwitchGuisPacket(PriorityContainer.TYPE));
}
@Override
protected GuiText getName() {
return GuiText.StorageBusFluids;
}
}
@@ -0,0 +1,341 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2018, 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 appeng.client.gui.implementations;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import com.mojang.blaze3d.matrix.MatrixStack;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.IConfigManager;
import appeng.client.ActionKey;
import appeng.client.gui.AEBaseMEScreen;
import appeng.client.gui.widgets.AETextField;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.Scrollbar;
import appeng.client.gui.widgets.SettingToggleButton;
import appeng.client.me.FluidRepo;
import appeng.client.me.InternalFluidSlotME;
import appeng.client.me.SlotFluidME;
import appeng.container.implementations.FluidTerminalContainer;
import appeng.container.slot.IMEFluidSlot;
import appeng.core.AELog;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.InventoryActionPacket;
import appeng.helpers.InventoryAction;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
/**
* @author BrockWS
* @version rv6 - 12/05/2018
* @since rv6 12/05/2018
*/
public class FluidTerminalScreen extends AEBaseMEScreen<FluidTerminalContainer>
implements ISortSource, IConfigManagerHost {
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
private final FluidRepo repo;
private final IConfigManager configSrc;
private static final int GRID_OFFSET_X = 9;
private static final int GRID_OFFSET_Y = 18;
private static final int ROWS = 6;
private static final int COLS = 9;
private AETextField searchField;
private SettingToggleButton<SortOrder> sortByBox;
private SettingToggleButton<SortDir> sortDirBox;
public FluidTerminalScreen(FluidTerminalContainer container, PlayerInventory playerInventory,
ITextComponent title) {
super(container, playerInventory, title);
this.xSize = 185;
this.ySize = 222;
final Scrollbar scrollbar = new Scrollbar();
this.setScrollBar(scrollbar);
this.repo = new FluidRepo(scrollbar, this);
this.configSrc = container.getConfigManager();
this.container.setGui(this);
}
@Override
public void init() {
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.searchField = new AETextField(this.font, this.guiLeft + 80, this.guiTop + 4, 90, 12);
this.searchField.setEnableBackgroundDrawing(false);
this.searchField.setMaxStringLength(25);
this.searchField.setTextColor(0xFFFFFF);
this.searchField.setSelectionColor(0xFF99FF99);
this.searchField.setVisible(true);
int offset = this.guiTop;
this.sortByBox = this.addButton(new SettingToggleButton<>(this.guiLeft - 18, offset, Settings.SORT_BY,
getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting));
offset += 20;
this.sortDirBox = this.addButton(new SettingToggleButton<>(this.guiLeft - 18, offset, Settings.SORT_DIRECTION,
getSortDir(), this::toggleServerSetting));
for (int y = 0; y < ROWS; y++) {
for (int x = 0; x < COLS; x++) {
SlotFluidME slot = new SlotFluidME(new InternalFluidSlotME(this.repo, x + y * COLS,
GRID_OFFSET_X + x * 18, GRID_OFFSET_Y + y * 18));
this.getMeFluidSlots().add(slot);
this.container.inventorySlots.add(slot);
}
}
this.setScrollBar();
}
@Override
public void drawFG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY) {
this.font.drawString(matrixStack, "Fluid Terminal", 8, 6, 4210752);
this.font.drawString(matrixStack, GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG(MatrixStack matrixStack, int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks) {
this.bindTexture(this.getBackground());
final int x_width = 197;
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18, getBlitOffset());
for (int x = 0; x < 6; x++) {
GuiUtils.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, getBlitOffset());
}
GuiUtils.drawTexturedModalRect(offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77,
getBlitOffset());
if (this.searchField != null) {
this.searchField.render(matrixStack, mouseX, mouseY, partialTicks);
}
}
@Override
public void tick() {
this.repo.setPower(this.container.isPowered());
super.tick();
}
@Override
protected void func_230459_a_(MatrixStack matrixStack, int mouseX, int mouseY) {
final Slot slot = this.getSlot(mouseX, mouseY);
if (slot instanceof IMEFluidSlot && slot.isEnabled()) {
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
if (fluidSlot.getAEFluidStack() != null && fluidSlot.shouldRenderAsFluid()) {
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
.format(fluidStack.getStackSize() / 1000.0) + " B";
final String modName = Platform.getModName(Platform.getModId(fluidStack));
final List<ITextComponent> list = new ArrayList<>();
list.add(fluidStack.getFluidStack().getDisplayName());
list.add(new StringTextComponent(formattedAmount));
list.add(new StringTextComponent(modName));
this.renderTooltip(matrixStack, list, mouseX, mouseY);
return;
}
}
super.func_230459_a_(matrixStack, mouseX, mouseY);
}
private <S extends Enum<S>> void toggleServerSetting(SettingToggleButton<S> btn, boolean backwards) {
S next = btn.getNextValue(backwards);
NetworkHandler.instance().sendToServer(new ConfigValuePacket(btn.getSetting().name(), next.name()));
btn.set(next);
}
@Override
protected void handleMouseClick(Slot slot, int slotIdx, int mouseButton, ClickType clickType) {
if (slot instanceof SlotFluidME) {
final SlotFluidME meSlot = (SlotFluidME) slot;
if (clickType == ClickType.PICKUP) {
// TODO: Allow more options
if (mouseButton == 0 && meSlot.getHasStack()) {
this.container.setTargetStack(meSlot.getAEFluidStack());
AELog.debug("mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
NetworkHandler.instance()
.sendToServer(new InventoryActionPacket(InventoryAction.FILL_ITEM, slot.slotNumber, 0));
} else {
this.container.setTargetStack(meSlot.getAEFluidStack());
if (meSlot.getAEFluidStack() != null) {
AELog.debug("mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize());
}
NetworkHandler.instance()
.sendToServer(new InventoryActionPacket(InventoryAction.EMPTY_ITEM, slot.slotNumber, 0));
}
}
return;
}
super.handleMouseClick(slot, slotIdx, mouseButton, clickType);
}
@Override
public boolean charTyped(char character, int p_charTyped_2_) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return true;
}
if (this.searchField.isFocused() && this.searchField.charTyped(character, p_charTyped_2_)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
return true;
}
return false;
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input)) {
if (AppEng.proxy.isActionKey(ActionKey.TOGGLE_FOCUS, input)) {
this.searchField.setFocused2(!this.searchField.isFocused());
return true;
}
if (this.searchField.isFocused()) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
this.searchField.setFocused2(false);
return true;
}
if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
}
// We need to swallow key presses if the field is focused because typing 'e'
// would otherwise close
// the screen
return true;
}
}
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
}
@Override
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
return true;
}
// Right-clicking on the search field should clear it
if (this.searchField.isMouseOver(xCoord, yCoord) && btn == 1) {
this.searchField.setText("");
this.repo.setSearchString("");
this.repo.updateView();
this.setScrollBar();
return true;
}
return super.mouseClicked(xCoord, yCoord, btn);
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(ROWS * 18 - 2);
this.getScrollBar().setRange(0, (this.repo.size() + COLS - 1) / COLS - ROWS, ROWS / 6);
}
@Override
public SortOrder getSortBy() {
return (SortOrder) this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public SortDir getSortDir() {
return (SortDir) this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public ViewItems getSortDisplay() {
return (ViewItems) this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting(IConfigManager manager, Settings settingName, Enum<?> newValue) {
if (this.sortByBox != null) {
this.sortByBox.set(getSortBy());
}
if (this.sortDirBox != null) {
this.sortDirBox.set(getSortDir());
}
this.repo.updateView();
}
protected List<SlotFluidME> getMeFluidSlots() {
return this.meFluidSlots;
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
protected String getBackground() {
return "guis/terminal.png";
}
}