All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.

This commit is contained in:
Sebastian Hartte
2020-06-06 21:16:05 +02:00
parent bb453b0d35
commit ff042a394b
209 changed files with 4527 additions and 4479 deletions
@@ -2,34 +2,26 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.PlayerInventory;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPriority;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
import appeng.fluids.container.ContainerFluidFormationPlane;
import appeng.fluids.parts.PartFluidFormationPlane;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
public class GuiFluidFormationPlane extends GuiUpgradeable
public class GuiFluidFormationPlane extends GuiUpgradeable<ContainerFluidFormationPlane>
{
private final PartFluidFormationPlane plane;
private GuiTabButton priority;
public GuiFluidFormationPlane( PlayerInventory PlayerInventory, PartFluidFormationPlane te )
public GuiFluidFormationPlane(ContainerFluidFormationPlane container, PlayerInventory playerInventory, ITextComponent title)
{
super( new ContainerFluidFormationPlane( PlayerInventory, te ) );
super(container, playerInventory, title);
this.ySize = 251;
this.plane = te;
}
@Override
@@ -40,8 +32,7 @@ public class GuiFluidFormationPlane extends GuiUpgradeable
final int xo = 8;
final int yo = 23 + 6;
final IAEFluidTank config = this.plane.getConfig();
final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.container;
final IAEFluidTank config = container.getFluidConfigInventory();
for( int y = 0; y < 7; y++ )
{
@@ -63,7 +54,11 @@ public class GuiFluidFormationPlane extends GuiUpgradeable
@Override
protected void addButtons()
{
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer ) );
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
@Override
@@ -72,16 +67,6 @@ public class GuiFluidFormationPlane extends GuiUpgradeable
return "guis/storagebus.png";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
}
@Override
protected GuiText getName()
{
@@ -19,16 +19,15 @@
package appeng.fluids.client.gui;
import net.minecraft.entity.player.PlayerInventory;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
import appeng.fluids.container.ContainerFluidIO;
import appeng.fluids.parts.PartFluidImportBus;
import appeng.fluids.parts.PartSharedFluidBus;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
/**
@@ -36,14 +35,12 @@ import appeng.fluids.util.IAEFluidTank;
* @version rv5 - 1/05/2018
* @since rv5 1/05/2018
*/
public class GuiFluidIO extends GuiUpgradeable
public class GuiFluidIO extends GuiUpgradeable<ContainerFluidIO>
{
private final PartSharedFluidBus bus;
public GuiFluidIO( PlayerInventory PlayerInventory, PartSharedFluidBus te )
public GuiFluidIO(ContainerFluidIO container, PlayerInventory playerInventory, ITextComponent title)
{
super( new ContainerFluidIO( PlayerInventory, te ) );
this.bus = te;
super(container, playerInventory, title);
}
@Override
@@ -51,8 +48,7 @@ public class GuiFluidIO extends GuiUpgradeable
{
super.init();
final ContainerFluidIO container = (ContainerFluidIO) this.container;
final IAEFluidTank inv = this.bus.getConfig();
final IAEFluidTank inv = this.container.getFluidConfigInventory();
final int y = 40;
final int x = 80;
@@ -19,37 +19,27 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.PlayerInventory;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPriority;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.client.gui.widgets.GuiFluidTank;
import appeng.fluids.container.ContainerFluidInterface;
import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiFluidInterface extends GuiUpgradeable
public class GuiFluidInterface extends GuiUpgradeable<ContainerFluidInterface>
{
public final static int ID_BUTTON_TANK = 222;
private final IFluidInterfaceHost host;
private GuiTabButton priority;
public GuiFluidInterface( final PlayerInventory ip, final IFluidInterfaceHost te )
public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory playerInventory, ITextComponent title)
{
super( new ContainerFluidInterface( ip, te ) );
super(container, playerInventory, title);
this.ySize = 231;
this.host = te;
}
@Override
@@ -57,19 +47,18 @@ public class GuiFluidInterface extends GuiUpgradeable
{
super.init();
final IAEFluidTank configFluids = this.host.getDualityFluidInterface().getConfig();
final IAEFluidTank fluidTank = this.host.getDualityFluidInterface().getTanks();
final IAEFluidTank configFluids = this.container.getFluidConfigInventory();
final IAEFluidTank fluidTank = this.container.getTanks();
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
{
final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, this.getGuiLeft() + 35 + 18 * i, this
final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, this.getGuiLeft() + 35 + 18 * i, this
.getGuiTop() + 53, 16, 68 );
this.addButton( guiTank );
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
}
this.priority = new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer );
this.addButton( this.priority );
this.addButton( new GuiTabButton( this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
}
@Override
@@ -87,21 +76,14 @@ public class GuiFluidInterface extends GuiUpgradeable
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks)
{
this.bindTexture( "guis/interfacefluid.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize, 0 /* FIXME ZINDEX */ );
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
@Override
@@ -2,9 +2,9 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.util.InputMappings;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.RedstoneMode;
@@ -13,33 +13,20 @@ import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
import appeng.fluids.container.ContainerFluidLevelEmitter;
import appeng.fluids.parts.PartFluidLevelEmitter;
import net.minecraft.util.text.ITextComponent;
public class GuiFluidLevelEmitter extends GuiUpgradeable
public class GuiFluidLevelEmitter extends GuiUpgradeable<ContainerFluidLevelEmitter>
{
private final PartFluidLevelEmitter levelEmitter;
private GuiNumberBox level;
private GuiButton plus1;
private GuiButton plus10;
private GuiButton plus100;
private GuiButton plus1000;
private GuiButton minus1;
private GuiButton minus10;
private GuiButton minus100;
private GuiButton minus1000;
public GuiFluidLevelEmitter( final PlayerInventory PlayerInventory, final PartFluidLevelEmitter te )
{
super( new ContainerFluidLevelEmitter( PlayerInventory, te ) );
this.levelEmitter = te;
public GuiFluidLevelEmitter(ContainerFluidLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
}
@Override
@@ -53,41 +40,41 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable
this.level.setTextColor( 0xFFFFFF );
this.level.setVisible( true );
this.level.changeFocus( true );
( (ContainerFluidLevelEmitter) this.inventorySlots ).setTextField( this.level );
container.setTextField( this.level );
final int y = 40;
final int x = 80 + 44;
this.guiSlots.add( new GuiFluidSlot( this.levelEmitter.getConfig(), 0, 0, x, y ) );
this.guiSlots.add( new GuiFluidSlot( this.container.getFluidConfigInventory(), 0, 0, x, y ) );
}
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, this::actionPerformed );
final int a = AEConfig.instance().levelByMillyBuckets( 0 );
final int b = AEConfig.instance().levelByMillyBuckets( 1 );
final int c = AEConfig.instance().levelByMillyBuckets( 2 );
final int d = AEConfig.instance().levelByMillyBuckets( 3 );
this.addButton( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
this.addButton( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
this.addButton( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
this.addButton( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a) ) );
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b) ) );
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c) ) );
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d) ) );
this.addButton( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
this.addButton( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
this.addButton( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
this.addButton( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
this.addButton( new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a) ) );
this.addButton( new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b) ) );
this.addButton( new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c) ) );
this.addButton( new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d) ) );
this.addButton( this.redstoneMode );
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks)
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.level.drawTextBox();
super.drawBG( offsetX, offsetY, mouseX, mouseY, partialTicks);
this.level.render(mouseX, mouseY, partialTicks);
}
@Override
@@ -113,20 +100,6 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable
{
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
}
}
private void addQty( final long i )
{
try
@@ -166,51 +139,66 @@ public class GuiFluidLevelEmitter extends GuiUpgradeable
// nope..
this.level.setText( "0" );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character ) ) && this.level.textboxKeyTyped( character, key ) )
public boolean charTyped(char character, int keyCode) {
if (level.charTyped(character, keyCode)) {
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
try
{
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
if( Fixed )
{
this.level.setText( Out );
}
if( Out.isEmpty() )
{
Out = "0";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
Out = Out.substring( 1 );
Fixed = true;
}
else
if( Fixed )
{
super.keyTyped( character, key );
this.level.setText( Out );
}
if( Out.isEmpty() )
{
Out = "0";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
return true;
}
return super.charTyped(character, keyCode);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
{
if( !this.checkHotbarKeys( InputMappings.getInputByCode(keyCode, scanCode) ) )
{
if( ( keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14 ) && this.level.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
{
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
if( Fixed )
{
this.level.setText( Out );
}
if( Out.isEmpty() )
{
Out = "0";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
return true;
}
}
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
}
}
@@ -21,9 +21,7 @@ package appeng.fluids.client.gui;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import appeng.container.implementations.ContainerPriority;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.AccessRestriction;
@@ -46,6 +44,7 @@ import appeng.fluids.client.gui.widgets.GuiOptionalFluidSlot;
import appeng.fluids.container.ContainerFluidStorageBus;
import appeng.fluids.parts.PartFluidStorageBus;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.util.text.ITextComponent;
/**
@@ -53,20 +52,14 @@ import appeng.fluids.util.IAEFluidTank;
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class GuiFluidStorageBus extends GuiUpgradeable
public class GuiFluidStorageBus extends GuiUpgradeable<ContainerFluidStorageBus>
{
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
private final PartFluidStorageBus bus;
public GuiFluidStorageBus( PlayerInventory PlayerInventory, PartFluidStorageBus te )
{
super( new ContainerFluidStorageBus( PlayerInventory, te ) );
public GuiFluidStorageBus(ContainerFluidStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 251;
this.bus = te;
}
@Override
@@ -77,8 +70,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable
final int xo = 8;
final int yo = 23 + 6;
final IAEFluidTank config = this.bus.getConfig();
final ContainerFluidStorageBus container = (ContainerFluidStorageBus) this.inventorySlots;
final IAEFluidTank config = this.container.getFluidConfigInventory();
for( int y = 0; y < 7; y++ )
{
@@ -100,19 +92,17 @@ public class GuiFluidStorageBus extends GuiUpgradeable
@Override
protected void addButtons()
{
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE, btn -> clear() ) );
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH, btn -> partition() ) );
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE, btn -> toggleReadWriteMode() );
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, btn -> toggleStorageFilter() );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
this.addButton( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
addButton( this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) ) );
this.addButton( this.storageFilter );
this.addButton( this.fuzzyMode );
this.addButton( this.rwMode );
this.addButton( this.partition );
this.addButton( this.clear );
}
@Override
@@ -143,40 +133,26 @@ public class GuiFluidStorageBus extends GuiUpgradeable
return "guis/storagebus.png";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
private void partition() {
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
}
final boolean backwards = Mouse.isButtonDown( 1 );
private void clear() {
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
}
try
{
if( btn == this.partition )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
}
else if( btn == this.clear )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
}
else if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
else if( btn == this.rwMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
}
else if( btn == this.storageFilter )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
}
catch( final IOException e )
{
AELog.debug( e );
}
private void openPriorityGui() {
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
private void toggleReadWriteMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
}
private void toggleStorageFilter() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
@Override
@@ -19,27 +19,9 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Slot;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEFluidStack;
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;
@@ -58,6 +40,21 @@ import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import net.minecraft.client.gui.widget.button.Button;
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.TextFormatting;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.client.gui.GuiUtils;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
/**
@@ -65,44 +62,33 @@ import appeng.util.Platform;
* @version rv6 - 12/05/2018
* @since rv6 12/05/2018
*/
public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfigManagerHost
public class GuiFluidTerminal extends AEBaseMEGui<ContainerFluidTerminal> implements ISortSource, IConfigManagerHost
{
private final List<SlotFluidME> meFluidSlots = new LinkedList<>();
private final FluidRepo repo;
private final IConfigManager configSrc;
private final ContainerFluidTerminal container;
private final int offsetX = 9;
private int rows = 6;
private int perRow = 9;
protected ITerminalHost terminal;
private MEGuiTextField searchField;
private GuiImgButton sortByBox;
private GuiImgButton sortDirBox;
public GuiFluidTerminal( final PlayerInventory PlayerInventory, final ITerminalHost te )
{
this( PlayerInventory, te, new ContainerFluidTerminal( PlayerInventory, te ) );
}
public GuiFluidTerminal( PlayerInventory PlayerInventory, final ITerminalHost te, final ContainerFluidTerminal c )
{
super( c );
this.terminal = te;
public GuiFluidTerminal(ContainerFluidTerminal container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
this.xSize = 185;
this.ySize = 222;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.repo = new FluidRepo( scrollbar, this );
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
( this.container = (ContainerFluidTerminal) this.inventorySlots ).setGui( this );
this.configSrc = container.getConfigManager();
this.container.setGui( this );
}
@Override
public void init()
{
this.minecraft.player.openContainer = this.inventorySlots;
this.guiLeft = ( this.width - this.xSize ) / 2;
this.guiTop = ( this.height - this.ySize ) / 2;
@@ -115,11 +101,11 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
int offset = this.guiTop;
this.addButton( this.sortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
this.sortByBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ), this::actionPerformed ) );
offset += 20;
this.addButton( this.sortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting( Settings.SORT_DIRECTION ) ) );
this.sortDirBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting( Settings.SORT_DIRECTION ), this::actionPerformed ) );
for( int y = 0; y < this.rows; y++ )
{
@@ -127,7 +113,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
{
SlotFluidME slot = new SlotFluidME( new InternalFluidSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
this.getMeFluidSlots().add( slot );
this.inventorySlots.inventorySlots.add( slot );
this.container.inventorySlots.add( slot );
}
}
this.setScrollBar();
@@ -141,30 +127,30 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY, float partialTicks)
{
this.bindTexture( this.getBackground() );
final int x_width = 197;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
GuiUtils.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18, 0 /* FIXME ZINDEX */ );
for( int x = 0; x < 6; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
GuiUtils.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18, 0 /* FIXME ZINDEX */ );
}
this.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77 );
GuiUtils.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77, 0 /* FIXME ZINDEX */ );
if( this.searchField != null )
{
this.searchField.drawTextBox();
this.searchField.render(mouseX, mouseY, partialTicks);
}
}
@Override
public void updateScreen()
public void tick()
{
this.repo.setPower( this.container.isPowered() );
super.updateScreen();
super.tick();
}
@Override
@@ -172,7 +158,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
{
final Slot slot = this.getSlot( mouseX, mouseY );
if( slot != null && slot instanceof IMEFluidSlot && slot.isEnabled() )
if( slot instanceof IMEFluidSlot && slot.isEnabled() )
{
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
@@ -181,18 +167,19 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
final IAEFluidStack fluidStack = fluidSlot.getAEFluidStack();
final String formattedAmount = NumberFormat.getNumberInstance( Locale.US ).format( fluidStack.getStackSize() / 1000.0 ) + " B";
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
.getIndexedModList()
.get( Platform.getModId( fluidStack ) )
.getName();
// FIXME: Move getting the mod name to platform
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + ModList.get()
.getModContainerById( Platform.getModId( fluidStack ) )
.map(mc -> mc.getModInfo().getDisplayName())
.orElse(null);
final List<String> list = new ArrayList<>();
list.add( fluidStack.getFluidStack().getLocalizedName() );
list.add( fluidStack.getFluidStack().getDisplayName().getFormattedText() );
list.add( formattedAmount );
list.add( modName );
this.drawHoveringText( list, mouseX, mouseY );
this.renderTooltip( list, mouseX, mouseY );
return;
}
@@ -200,12 +187,11 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
super.renderHoveredToolTip( mouseX, mouseY );
}
@Override
protected void actionPerformed( GuiButton btn ) throws IOException
protected void actionPerformed( Button btn )
{
if( btn instanceof GuiImgButton )
{
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = minecraft.mouseHelper.isRightDown();
final GuiImgButton iBtn = (GuiImgButton) btn;
if( iBtn.getSetting() != Settings.ACTIONS )
@@ -213,14 +199,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
try
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
iBtn.set( next );
}
@@ -259,42 +238,55 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
public boolean charTyped(char character, int keyCode) {
if (character == ' ' && this.searchField.getText().isEmpty())
{
if( character == ' ' && this.searchField.getText().isEmpty() )
{
return;
}
// Swallow spaces if the text field is still empty
return true;
}
if( this.searchField.textboxKeyTyped( character, key ) )
if (this.searchField.charTyped(character, keyCode)) {
this.repo.setSearchString( this.searchField.getText() );
this.repo.updateView();
this.setScrollBar();
return true;
}
return super.charTyped(character, keyCode);
}
@Override
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_)
{
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
if( !this.checkHotbarKeys(input) )
{
if( this.searchField.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
{
this.repo.setSearchString( this.searchField.getText() );
this.repo.updateView();
this.setScrollBar();
}
else
{
super.keyTyped( character, key );
return true;
}
}
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
public boolean mouseClicked( final double xCoord, final double yCoord, final int btn )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
{
this.searchField.setText( "" );
this.repo.setSearchString( "" );
this.repo.updateView();
this.setScrollBar();
if (this.searchField.mouseClicked( xCoord, yCoord, btn )) {
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
this.searchField.setText("");
this.repo.setSearchString("");
this.repo.updateView();
this.setScrollBar();
}
return true;
}
super.mouseClicked( xCoord, yCoord, btn );
return super.mouseClicked( xCoord, yCoord, btn );
}
public void postUpdate( final List<IAEFluidStack> list )
@@ -24,6 +24,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiFluidSlot extends GuiCustomSlot
@@ -49,7 +50,7 @@ public class GuiFluidSlot extends GuiCustomSlot
final Fluid fluid = fs.getFluid();
final FluidAttributes attributes = fluid.getAttributes();
mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture() );
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fs.getFluidStack()) );
// Set color for dynamic fluids
// Convert int color to RGB
@@ -58,7 +59,7 @@ public class GuiFluidSlot extends GuiCustomSlot
final float blue = ( attributes.getColor() & 255 ) / 255.0F;
RenderSystem.color3f( red, green, blue );
this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() );
blit(xPos(), yPos(), this.getBlitOffset(), getWidth(), getHeight(), sprite);
}
}
@@ -19,36 +19,36 @@
package appeng.fluids.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.util.AEColor;
import appeng.client.gui.widgets.ITooltip;
import appeng.fluids.util.IAEFluidTank;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.fluid.Fluid;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidAttributes;
@OnlyIn( Dist.CLIENT )
public class GuiFluidTank extends GuiButton implements ITooltip
public class GuiFluidTank extends Widget implements ITooltip
{
private final IAEFluidTank tank;
private final int slot;
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
public GuiFluidTank(IAEFluidTank tank, int slot, int x, int y, int w, int h)
{
super( id, x, y, w, h, "" );
super( x, y, w, h, "" );
this.tank = tank;
this.slot = slot;
}
@Override
public void drawButton( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks )
{
public void renderButton(int mouseX, int mouseY, float partialTicks) {
if( this.visible )
{
RenderSystem.disableBlend();
@@ -56,27 +56,31 @@ public class GuiFluidTank extends GuiButton implements ITooltip
fill( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
final IAEFluidStack fluidStack = this.tank.getFluidInSlot( this.slot );
if( fluidStack != null && fluidStack.getStackSize() > 0 )
{
Fluid fluid = fluidStack.getFluid();
FluidAttributes attributes = fluid.getAttributes();
float red = ( attributes.getColor() >> 16 & 255 ) / 255.0F;
float green = ( attributes.getColor() >> 8 & 255 ) / 255.0F;
float blue = ( attributes.getColor() & 255 ) / 255.0F;
RenderSystem.color3f( red, green, blue );
Minecraft mc = Minecraft.getInstance();
mc.getTextureManager().bindTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE );
final TextureAtlasSprite sprite = mc.getAtlasSpriteGetter( AtlasTexture.LOCATION_BLOCKS_TEXTURE ).apply( attributes.getStillTexture(fluidStack.getFluidStack()) );
float red = ( fluid.getFluid().getColor() >> 16 & 255 ) / 255.0F;
float green = ( fluid.getFluid().getColor() >> 8 & 255 ) / 255.0F;
float blue = ( fluid.getFluid().getColor() & 255 ) / 255.0F;
RenderSystem.color4f( red, green, blue );
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() );
final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) );
final int scaledHeight = (int) ( this.height * ( (float) fluidStack.getStackSize() / this.tank.getTankCapacity(this.slot) ) );
int iconHeightRemainder = scaledHeight % 16;
if( iconHeightRemainder > 0 )
{
this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder );
blit(this.x, this.y + this.height - iconHeightRemainder, getBlitOffset(), 16, iconHeightRemainder, sprite );
}
for( int i = 0; i < scaledHeight / 16; i++ )
{
this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
blit( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, getBlitOffset(), 16, 16, sprite );
}
}
@@ -89,7 +93,7 @@ public class GuiFluidTank extends GuiButton implements ITooltip
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
{
String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() );
String desc = fluid.getFluid().getAttributes().getDisplayName( fluid.getFluidStack() ).getFormattedText();
String amountToText = fluid.getStackSize() + "mB";
return desc + "\n" + amountToText;
@@ -2,11 +2,11 @@
package appeng.fluids.client.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.slot.IOptionalSlotHost;
import appeng.fluids.util.IAEFluidTank;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiOptionalFluidSlot extends GuiFluidSlot
@@ -57,7 +57,7 @@ public class GuiOptionalFluidSlot extends GuiFluidSlot
{
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 0.4F );
}
this.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
this.getHeight() + 2 );
GuiUtils.drawTexturedModalRect( guileft + this.xPos() - 1, guitop + this.yPos() - 1, this.srcX - 1, this.srcY - 1, this.getWidth() + 2,
this.getHeight() + 2, 0 /* FIXME ZINDEX */ );
}
}