reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -1,12 +1,6 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiText;
@@ -18,73 +12,64 @@ 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.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiFluidFormationPlane extends GuiUpgradeable
{
private final PartFluidFormationPlane plane;
private GuiTabButton priority;
public class GuiFluidFormationPlane extends GuiUpgradeable {
private final PartFluidFormationPlane plane;
private GuiTabButton priority;
public GuiFluidFormationPlane( InventoryPlayer inventoryPlayer, PartFluidFormationPlane te )
{
super( new ContainerFluidFormationPlane( inventoryPlayer, te ) );
this.ySize = 251;
this.plane = te;
}
public GuiFluidFormationPlane(InventoryPlayer inventoryPlayer, PartFluidFormationPlane te) {
super(new ContainerFluidFormationPlane(inventoryPlayer, te));
this.ySize = 251;
this.plane = te;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
final int xo = 8;
final int yo = 23 + 6;
final int xo = 8;
final int yo = 23 + 6;
final IAEFluidTank config = this.plane.getConfig();
final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.inventorySlots;
final IAEFluidTank config = this.plane.getConfig();
final ContainerFluidFormationPlane container = (ContainerFluidFormationPlane) this.inventorySlots;
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 GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
}
else
{
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
}
}
}
}
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 GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18));
} else {
this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y));
}
}
}
}
@Override
protected void addButtons()
{
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
}
@Override
protected void addButtons() {
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
}
@Override
protected String getBackground()
{
return "guis/storagebus.png";
}
@Override
protected String getBackground() {
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 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()
{
return GuiText.FluidFormationPlane;
}
@Override
protected GuiText getName() {
return GuiText.FluidFormationPlane;
}
}
@@ -19,8 +19,6 @@
package appeng.fluids.client.gui;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import appeng.fluids.client.gui.widgets.GuiFluidSlot;
@@ -29,6 +27,7 @@ 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.InventoryPlayer;
/**
@@ -36,41 +35,37 @@ import appeng.fluids.util.IAEFluidTank;
* @version rv5 - 1/05/2018
* @since rv5 1/05/2018
*/
public class GuiFluidIO extends GuiUpgradeable
{
private final PartSharedFluidBus bus;
public class GuiFluidIO extends GuiUpgradeable {
private final PartSharedFluidBus bus;
public GuiFluidIO( InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
{
super( new ContainerFluidIO( inventoryPlayer, te ) );
this.bus = te;
}
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) {
super(new ContainerFluidIO(inventoryPlayer, te));
this.bus = te;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
final ContainerFluidIO container = (ContainerFluidIO) this.inventorySlots;
final IAEFluidTank inv = this.bus.getConfig();
final int y = 40;
final int x = 80;
final ContainerFluidIO container = (ContainerFluidIO) this.inventorySlots;
final IAEFluidTank inv = this.bus.getConfig();
final int y = 40;
final int x = 80;
this.guiSlots.add( new GuiFluidSlot( inv, 0, 0, x, y ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 1, 1, 1, x, y, -1, 0 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 2, 2, 1, x, y, 1, 0 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 3, 3, 1, x, y, 0, -1 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 4, 4, 1, x, y, 0, 1 ) );
this.guiSlots.add(new GuiFluidSlot(inv, 0, 0, x, y));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 1, 1, 1, x, y, -1, 0));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 2, 2, 1, x, y, 1, 0));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 3, 3, 1, x, y, 0, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 4, 4, 1, x, y, 0, 1));
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 5, 5, 2, x, y, -1, -1 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 6, 6, 2, x, y, 1, -1 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 7, 7, 2, x, y, -1, 1 ) );
this.guiSlots.add( new GuiOptionalFluidSlot( inv, container, 8, 8, 2, x, y, 1, 1 ) );
}
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 5, 5, 2, x, y, -1, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 6, 6, 2, x, y, 1, -1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 7, 7, 2, x, y, -1, 1));
this.guiSlots.add(new GuiOptionalFluidSlot(inv, container, 8, 8, 2, x, y, 1, 1));
}
@Override
protected GuiText getName()
{
return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
}
@Override
protected GuiText getName() {
return this.bc instanceof PartFluidImportBus ? GuiText.ImportBusFluids : GuiText.ExportBusFluids;
}
}
@@ -19,15 +19,9 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import appeng.api.util.IConfigManager;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.util.IConfigManagerHost;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
@@ -39,102 +33,92 @@ import appeng.fluids.container.ContainerFluidInterface;
import appeng.fluids.helper.DualityFluidInterface;
import appeng.fluids.helper.IFluidInterfaceHost;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.IConfigManagerHost;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerHost
{
public final static int ID_BUTTON_TANK = 222;
public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerHost {
public final static int ID_BUTTON_TANK = 222;
private final IFluidInterfaceHost host;
private final ContainerFluidInterface container;
private GuiTabButton priority;
private final IFluidInterfaceHost host;
private final ContainerFluidInterface container;
private GuiTabButton priority;
public GuiFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
{
super( new ContainerFluidInterface( ip, te ) );
this.ySize = 231;
this.host = te;
( this.container = (ContainerFluidInterface) this.inventorySlots ).setGui( this );
public GuiFluidInterface(final InventoryPlayer ip, final IFluidInterfaceHost te) {
super(new ContainerFluidInterface(ip, te));
this.ySize = 231;
this.host = te;
(this.container = (ContainerFluidInterface) this.inventorySlots).setGui(this);
}
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
final IAEFluidTank configFluids = this.host.getDualityFluidInterface().getConfig();
final IAEFluidTank fluidTank = this.host.getDualityFluidInterface().getTanks();
final IAEFluidTank configFluids = this.host.getDualityFluidInterface().getConfig();
final IAEFluidTank fluidTank = this.host.getDualityFluidInterface().getTanks();
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
{
this.guiSlots.add( new GuiFluidTank( fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, 36 + 18 * i, 57, 16, 64 ) );
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
}
for (int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i) {
this.guiSlots.add(new GuiFluidTank(fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, 36 + 18 * i, 57, 16, 64));
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.itemRender );
this.buttonList.add( this.priority );
}
this.priority = new GuiTabButton(this.getGuiLeft() + 154, this.getGuiTop(), 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender);
this.buttonList.add(this.priority);
}
@Override
protected void addButtons()
{
}
@Override
protected void addButtons() {
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.FluidInterface.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752 );
this.fontRenderer.drawString( GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.FluidInterface.getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.Config.getLocal(), 35, 6 + 11 + 7, 4210752);
this.fontRenderer.drawString(GuiText.StoredFluids.getLocal(), 35, 6 + 112 + 7, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( "guis/interfacefluid.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture("guis/interfacefluid.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
if( btn == this.priority )
{
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
}
}
if (btn == this.priority) {
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PRIORITY));
}
}
@Override
protected void mouseClicked( int xCoord, int yCoord, int btn ) throws IOException
{
for( GuiCustomSlot slot : this.guiSlots )
{
if( slot instanceof GuiFluidTank )
{
if( this.isPointInRegion( slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord ) && slot.canClick( this.mc.player ) )
{
this.container.setTargetStack( ( (GuiFluidTank) slot ).getFluidStack() );
slot.slotClicked( this.mc.player.inventory.getItemStack(), btn );
return;
}
}
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void mouseClicked(int xCoord, int yCoord, int btn) throws IOException {
for (GuiCustomSlot slot : this.guiSlots) {
if (slot instanceof GuiFluidTank) {
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord) && slot.canClick(this.mc.player)) {
this.container.setTargetStack(((GuiFluidTank) slot).getFluidStack());
slot.slotClicked(this.mc.player.inventory.getItemStack(), btn);
return;
}
}
}
super.mouseClicked(xCoord, yCoord, btn);
}
@Override
protected boolean drawUpgrades()
{
return false;
}
@Override
protected boolean drawUpgrades() {
return false;
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {
}
}
}
@@ -1,12 +1,6 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.implementations.GuiUpgradeable;
@@ -20,204 +14,176 @@ 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.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import java.io.IOException;
public class GuiFluidLevelEmitter extends GuiUpgradeable
{
private final PartFluidLevelEmitter levelEmitter;
private GuiNumberBox level;
public class GuiFluidLevelEmitter extends GuiUpgradeable {
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;
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 InventoryPlayer inventoryPlayer, final PartFluidLevelEmitter te )
{
super( new ContainerFluidLevelEmitter( inventoryPlayer, te ) );
this.levelEmitter = te;
}
public GuiFluidLevelEmitter(final InventoryPlayer inventoryPlayer, final PartFluidLevelEmitter te) {
super(new ContainerFluidLevelEmitter(inventoryPlayer, te));
this.levelEmitter = te;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
this.level = new GuiNumberBox( this.fontRenderer, this.guiLeft + 24, this.guiTop + 43, 79, this.fontRenderer.FONT_HEIGHT, Long.class );
this.level.setEnableBackgroundDrawing( false );
this.level.setMaxStringLength( 16 );
this.level.setTextColor( 0xFFFFFF );
this.level.setVisible( true );
this.level.setFocused( true );
( (ContainerFluidLevelEmitter) this.inventorySlots ).setTextField( this.level );
this.level = new GuiNumberBox(this.fontRenderer, this.guiLeft + 24, this.guiTop + 43, 79, this.fontRenderer.FONT_HEIGHT, Long.class);
this.level.setEnableBackgroundDrawing(false);
this.level.setMaxStringLength(16);
this.level.setTextColor(0xFFFFFF);
this.level.setVisible(true);
this.level.setFocused(true);
((ContainerFluidLevelEmitter) this.inventorySlots).setTextField(this.level);
final int y = 40;
final int x = 80 + 44;
this.guiSlots.add( new GuiFluidSlot( this.levelEmitter.getConfig(), 0, 0, x, y ) );
}
final int y = 40;
final int x = 80 + 44;
this.guiSlots.add(new GuiFluidSlot(this.levelEmitter.getConfig(), 0, 0, x, y));
}
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
@Override
protected void addButtons() {
this.redstoneMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL);
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 );
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.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d));
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d));
this.buttonList.add( this.redstoneMode );
}
this.buttonList.add(this.redstoneMode);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
super.drawBG( offsetX, offsetY, mouseX, mouseY );
this.level.drawTextBox();
}
@Override
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
super.drawBG(offsetX, offsetY, mouseX, mouseY);
this.level.drawTextBox();
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
if( isPointInRegion( 24, 43,89,this.fontRenderer.FONT_HEIGHT,mouseX,mouseY ) ) drawTooltip( mouseX - guiLeft - 7, mouseY - guiTop + 25, "Amount in millibuckets" );
super.drawFG( offsetX, offsetY, mouseX, mouseY );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
if (isPointInRegion(24, 43, 89, this.fontRenderer.FONT_HEIGHT, mouseX, mouseY))
drawTooltip(mouseX - guiLeft - 7, mouseY - guiTop + 25, "Amount in millibuckets");
super.drawFG(offsetX, offsetY, mouseX, mouseY);
}
@Override
protected boolean drawUpgrades()
{
return false;
}
@Override
protected boolean drawUpgrades() {
return false;
}
@Override
protected String getBackground()
{
return "guis/lvlemitter.png";
}
@Override
protected String getBackground() {
return "guis/lvlemitter.png";
}
@Override
protected GuiText getName()
{
return GuiText.FluidLevelEmitter;
}
@Override
protected GuiText getName() {
return GuiText.FluidLevelEmitter;
}
@Override
protected void handleButtonVisibility()
{
}
@Override
protected void handleButtonVisibility() {
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@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;
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 ) );
}
}
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty( final long i )
{
try
{
String Out = this.level.getText();
private void addQty(final long i) {
try {
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if( Fixed )
{
this.level.setText( Out );
}
if (Fixed) {
this.level.setText(Out);
}
if( Out.isEmpty() )
{
Out = "0";
}
if (Out.isEmpty()) {
Out = "0";
}
long result = Long.parseLong( Out );
result += i;
if( result < 0 )
{
result = 0;
}
long result = Long.parseLong(Out);
result += i;
if (result < 0) {
result = 0;
}
this.level.setText( Out = Long.toString( result ) );
this.level.setText(Out = Long.toString(result));
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
}
catch( final NumberFormatException e )
{
// nope..
this.level.setText( "0" );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out));
} catch (final NumberFormatException e) {
// 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 ) )
{
try
{
String Out = this.level.getText();
@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)) {
try {
String Out = this.level.getText();
boolean Fixed = false;
while( Out.startsWith( "0" ) && Out.length() > 1 )
{
Out = Out.substring( 1 );
Fixed = true;
}
boolean Fixed = false;
while (Out.startsWith("0") && Out.length() > 1) {
Out = Out.substring(1);
Fixed = true;
}
if( Fixed )
{
this.level.setText( Out );
}
if (Fixed) {
this.level.setText(Out);
}
if( Out.isEmpty() )
{
Out = "0";
}
if (Out.isEmpty()) {
Out = "0";
}
NetworkHandler.instance().sendToServer( new PacketValueConfig( "FluidLevelEmitter.Value", Out ) );
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
}
}
}
NetworkHandler.instance().sendToServer(new PacketValueConfig("FluidLevelEmitter.Value", Out));
} catch (final IOException e) {
AELog.debug(e);
}
} else {
super.keyTyped(character, key);
}
}
}
}
@@ -19,18 +19,7 @@
package appeng.fluids.client.gui;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
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.api.config.*;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
@@ -46,6 +35,11 @@ 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.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
import java.io.IOException;
/**
@@ -53,135 +47,107 @@ import appeng.fluids.util.IAEFluidTank;
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class GuiFluidStorageBus extends GuiUpgradeable
{
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
private final PartFluidStorageBus bus;
public class GuiFluidStorageBus extends GuiUpgradeable {
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
private final PartFluidStorageBus bus;
public GuiFluidStorageBus( InventoryPlayer inventoryPlayer, PartFluidStorageBus te )
{
super( new ContainerFluidStorageBus( inventoryPlayer, te ) );
this.ySize = 251;
this.bus = te;
}
public GuiFluidStorageBus(InventoryPlayer inventoryPlayer, PartFluidStorageBus te) {
super(new ContainerFluidStorageBus(inventoryPlayer, te));
this.ySize = 251;
this.bus = te;
}
@Override
public void initGui()
{
super.initGui();
@Override
public void initGui() {
super.initGui();
final int xo = 8;
final int yo = 23 + 6;
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.bus.getConfig();
final ContainerFluidStorageBus container = (ContainerFluidStorageBus) this.inventorySlots;
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 GuiFluidSlot( config, idx, idx, xo + x * 18, yo + y * 18 ) );
}
else
{
this.guiSlots.add( new GuiOptionalFluidSlot( config, container, idx, idx, y - 2, xo, yo, x, y ) );
}
}
}
}
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 GuiFluidSlot(config, idx, idx, xo + x * 18, yo + y * 18));
} else {
this.guiSlots.add(new GuiOptionalFluidSlot(config, container, idx, idx, y - 2, xo, yo, x, y));
}
}
}
}
@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 );
@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);
this.buttonList.add( this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender ) );
this.buttonList.add(this.priority = new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRender));
this.buttonList.add( this.storageFilter );
this.buttonList.add( this.fuzzyMode );
this.buttonList.add( this.rwMode );
this.buttonList.add( this.partition );
this.buttonList.add( this.clear );
}
this.buttonList.add(this.storageFilter);
this.buttonList.add(this.fuzzyMode);
this.buttonList.add(this.rwMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( this.getName().getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName(this.getName().getLocal()), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
if( this.fuzzyMode != null )
{
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
}
if (this.fuzzyMode != null) {
this.fuzzyMode.set(this.cvb.getFuzzyMode());
}
if( this.storageFilter != null )
{
this.storageFilter.set( ( (ContainerFluidStorageBus) this.cvb ).getStorageFilter() );
}
if (this.storageFilter != null) {
this.storageFilter.set(((ContainerFluidStorageBus) this.cvb).getStorageFilter());
}
if( this.rwMode != null )
{
this.rwMode.set( ( (ContainerFluidStorageBus) this.cvb ).getReadWriteMode() );
}
}
if (this.rwMode != null) {
this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode());
}
}
@Override
protected String getBackground()
{
return "guis/storagebus.png";
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
super.actionPerformed( btn );
@Override
protected void actionPerformed(final GuiButton btn) throws IOException {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
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 );
}
}
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);
}
}
@Override
protected GuiText getName()
{
return GuiText.StorageBusFluids;
}
@Override
protected GuiText getName() {
return GuiText.StorageBusFluids;
}
}
@@ -19,22 +19,6 @@
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.InventoryPlayer;
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;
@@ -58,6 +42,20 @@ import appeng.fluids.container.slots.IMEFluidSlot;
import appeng.helpers.InventoryAction;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Slot;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
/**
@@ -65,302 +63,255 @@ import appeng.util.Platform;
* @version rv6 - 12/05/2018
* @since rv6 12/05/2018
*/
public class GuiFluidTerminal extends AEBaseMEGui 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;
public class GuiFluidTerminal extends AEBaseMEGui 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 final int rows = 6;
private final int perRow = 9;
protected ITerminalHost terminal;
protected ITerminalHost terminal;
private MEGuiTextField searchField;
private GuiImgButton sortByBox;
private GuiImgButton sortDirBox;
private MEGuiTextField searchField;
private GuiImgButton sortByBox;
private GuiImgButton sortDirBox;
public GuiFluidTerminal( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
this( inventoryPlayer, te, new ContainerFluidTerminal( inventoryPlayer, te ) );
}
public GuiFluidTerminal(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
this(inventoryPlayer, te, new ContainerFluidTerminal(inventoryPlayer, te));
}
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidTerminal c )
{
super( c );
this.terminal = te;
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 );
}
public GuiFluidTerminal(InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidTerminal c) {
super(c);
this.terminal = te;
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);
}
@Override
public void initGui()
{
this.mc.player.openContainer = this.inventorySlots;
this.guiLeft = ( this.width - this.xSize ) / 2;
this.guiTop = ( this.height - this.ySize ) / 2;
@Override
public void initGui() {
this.mc.player.openContainer = this.inventorySlots;
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.searchField = new MEGuiTextField( this.fontRenderer, 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.setSelectionColor( 0xFF99FF99 );
this.searchField.setVisible( true );
this.searchField = new MEGuiTextField(this.fontRenderer, 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.setSelectionColor(0xFF99FF99);
this.searchField.setVisible(true);
int offset = this.guiTop;
int offset = this.guiTop;
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.sortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
this.buttonList.add( this.sortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting( Settings.SORT_DIRECTION ) ) );
this.buttonList.add(this.sortDirBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting(Settings.SORT_DIRECTION)));
for( int y = 0; y < this.rows; y++ )
{
for( int x = 0; x < this.perRow; x++ )
{
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.setScrollBar();
}
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
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.setScrollBar();
}
@Override
public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.fontRenderer.drawString( this.getGuiDisplayName( "Fluid Terminal" ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.fontRenderer.drawString(this.getGuiDisplayName("Fluid Terminal"), 8, 6, 4210752);
this.fontRenderer.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
{
this.bindTexture( this.getBackground() );
final int x_width = 197;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
this.bindTexture(this.getBackground());
final int x_width = 197;
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
for( int x = 0; x < 6; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
}
for (int x = 0; x < 6; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect( offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77 );
this.drawTexturedModalRect(offsetX, offsetY + 16 + 6 * 18, 0, 106 - 18 - 18, x_width, 99 + 77);
if( this.searchField != null )
{
this.searchField.drawTextBox();
}
}
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
@Override
public void updateScreen()
{
this.repo.setPower( this.container.isPowered() );
super.updateScreen();
}
@Override
public void updateScreen() {
this.repo.setPower(this.container.isPowered());
super.updateScreen();
}
@Override
protected void renderHoveredToolTip( int mouseX, int mouseY )
{
final Slot slot = this.getSlot( mouseX, mouseY );
@Override
protected void renderHoveredToolTip(int mouseX, int mouseY) {
final Slot slot = this.getSlot(mouseX, mouseY);
if( slot != null && slot instanceof IMEFluidSlot && slot.isEnabled() )
{
final IMEFluidSlot fluidSlot = (IMEFluidSlot) slot;
if (slot != null && 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";
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 = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
.getIndexedModList()
.get( Platform.getModId( fluidStack ) )
.getName();
final String modName = "" + TextFormatting.BLUE + TextFormatting.ITALIC + Loader.instance()
.getIndexedModList()
.get(Platform.getModId(fluidStack))
.getName();
final List<String> list = new ArrayList<>();
final List<String> list = new ArrayList<>();
list.add( fluidStack.getFluidStack().getLocalizedName() );
list.add( formattedAmount );
list.add( modName );
list.add(fluidStack.getFluidStack().getLocalizedName());
list.add(formattedAmount);
list.add(modName);
this.drawHoveringText( list, mouseX, mouseY );
this.drawHoveringText(list, mouseX, mouseY);
return;
}
}
super.renderHoveredToolTip( mouseX, mouseY );
}
return;
}
}
super.renderHoveredToolTip(mouseX, mouseY);
}
@Override
protected void actionPerformed( GuiButton btn ) throws IOException
{
if( btn instanceof GuiImgButton )
{
final boolean backwards = Mouse.isButtonDown( 1 );
final GuiImgButton iBtn = (GuiImgButton) btn;
@Override
protected void actionPerformed(GuiButton btn) throws IOException {
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 (iBtn.getSetting() != Settings.ACTIONS) {
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 );
}
try {
NetworkHandler.instance().sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
iBtn.set( next );
}
}
}
iBtn.set(next);
}
}
}
@Override
protected void handleMouseClick( Slot slot, int slotIdx, int mouseButton, ClickType clickType )
{
if( slot instanceof SlotFluidME )
{
final SlotFluidME meSlot = (SlotFluidME) slot;
@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 PacketInventoryAction( 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 PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) );
}
}
return;
}
super.handleMouseClick( slot, slotIdx, mouseButton, clickType );
}
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 PacketInventoryAction(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 PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot.slotNumber, 0));
}
}
return;
}
super.handleMouseClick(slot, slotIdx, mouseButton, clickType);
}
@Override
protected void keyTyped( final char character, final int key ) throws IOException
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchField.getText().isEmpty() )
{
return;
}
@Override
protected void keyTyped(final char character, final int key) throws IOException {
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 );
}
}
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
} else {
super.keyTyped(character, key);
}
}
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException {
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 (btn == 1 && this.searchField.isMouseIn(xCoord, yCoord)) {
this.searchField.setText("");
this.repo.setSearchString("");
this.repo.updateView();
this.setScrollBar();
}
super.mouseClicked( xCoord, yCoord, btn );
}
super.mouseClicked(xCoord, yCoord, btn);
}
public void postUpdate( final List<IAEFluidStack> list )
{
for( final IAEFluidStack is : list )
{
this.repo.postUpdate( is );
}
public void postUpdate(final List<IAEFluidStack> list) {
for (final IAEFluidStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
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 ) );
}
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
public Enum getSortBy()
{
return this.configSrc.getSetting( Settings.SORT_BY );
}
@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 getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum getSortDisplay()
{
return this.configSrc.getSetting( Settings.VIEW_MODE );
}
@Override
public Enum getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
if( this.sortByBox != null )
{
this.sortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, 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.sortDirBox != null) {
this.sortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
this.repo.updateView();
}
this.repo.updateView();
}
protected List<SlotFluidME> getMeFluidSlots()
{
return this.meFluidSlots;
}
protected List<SlotFluidME> getMeFluidSlots() {
return this.meFluidSlots;
}
@Override
protected boolean isPowered()
{
return this.repo.hasPower();
}
@Override
protected boolean isPowered() {
return this.repo.hasPower();
}
protected String getBackground()
{
return "guis/terminal.png";
}
protected String getBackground() {
return "guis/terminal.png";
}
}
@@ -1,10 +1,13 @@
package appeng.fluids.client.gui.widgets;
import java.util.Collections;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.container.slot.IJEITargetSlot;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -16,98 +19,78 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketFluidSlot;
import appeng.fluids.util.AEFluidStack;
import appeng.fluids.util.IAEFluidTank;
import java.util.Collections;
public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot
{
private final IAEFluidTank fluids;
private final int slot;
public class GuiFluidSlot extends GuiCustomSlot implements IJEITargetSlot {
private final IAEFluidTank fluids;
private final int slot;
public GuiFluidSlot( final IAEFluidTank fluids, final int slot, final int id, final int x, final int y )
{
super( id, x, y );
this.fluids = fluids;
this.slot = slot;
}
public GuiFluidSlot(final IAEFluidTank fluids, final int slot, final int id, final int x, final int y) {
super(id, x, y);
this.fluids = fluids;
this.slot = slot;
}
@Override
public void drawContent( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks )
{
final IAEFluidStack fs = this.getFluidStack();
if( fs != null )
{
GlStateManager.disableLighting();
GlStateManager.disableBlend();
final Fluid fluid = fs.getFluid();
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getStill().toString() );
@Override
public void drawContent(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) {
final IAEFluidStack fs = this.getFluidStack();
if (fs != null) {
GlStateManager.disableLighting();
GlStateManager.disableBlend();
final Fluid fluid = fs.getFluid();
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite(fluid.getStill().toString());
// Set color for dynamic fluids
// Convert int color to RGB
final float red = ( fluid.getColor() >> 16 & 255 ) / 255.0F;
final float green = ( fluid.getColor() >> 8 & 255 ) / 255.0F;
final float blue = ( fluid.getColor() & 255 ) / 255.0F;
GlStateManager.color( red, green, blue );
// Set color for dynamic fluids
// Convert int color to RGB
final float red = (fluid.getColor() >> 16 & 255) / 255.0F;
final float green = (fluid.getColor() >> 8 & 255) / 255.0F;
final float blue = (fluid.getColor() & 255) / 255.0F;
GlStateManager.color(red, green, blue);
this.drawTexturedModalRect( this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight() );
}
}
this.drawTexturedModalRect(this.xPos(), this.yPos(), sprite, this.getWidth(), this.getHeight());
}
}
@Override
public boolean canClick( final EntityPlayer player )
{
final ItemStack mouseStack = player.inventory.getItemStack();
return mouseStack.isEmpty() || mouseStack.hasCapability( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null );
}
@Override
public boolean canClick(final EntityPlayer player) {
final ItemStack mouseStack = player.inventory.getItemStack();
return mouseStack.isEmpty() || mouseStack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
}
@Override
public void slotClicked( final ItemStack clickStack, int mouseButton )
{
if( clickStack.isEmpty() || mouseButton == 1 )
{
this.setFluidStack( null );
}
else if( mouseButton == 0 )
{
final FluidStack fluid = FluidUtil.getFluidContained( clickStack );
if( fluid != null )
{
this.setFluidStack( AEFluidStack.fromFluidStack( fluid ) );
}
}
}
@Override
public void slotClicked(final ItemStack clickStack, int mouseButton) {
if (clickStack.isEmpty() || mouseButton == 1) {
this.setFluidStack(null);
} else if (mouseButton == 0) {
final FluidStack fluid = FluidUtil.getFluidContained(clickStack);
if (fluid != null) {
this.setFluidStack(AEFluidStack.fromFluidStack(fluid));
}
}
}
@Override
public String getMessage()
{
final IAEFluidStack fluid = this.getFluidStack();
if( fluid != null )
{
return fluid.getFluidStack().getLocalizedName();
}
return null;
}
@Override
public String getMessage() {
final IAEFluidStack fluid = this.getFluidStack();
if (fluid != null) {
return fluid.getFluidStack().getLocalizedName();
}
return null;
}
@Override
public boolean isVisible()
{
return true;
}
@Override
public boolean isVisible() {
return true;
}
public IAEFluidStack getFluidStack()
{
return this.fluids.getFluidInSlot( this.slot );
}
public IAEFluidStack getFluidStack() {
return this.fluids.getFluidInSlot(this.slot);
}
public void setFluidStack( final IAEFluidStack stack )
{
this.fluids.setFluidInSlot( this.slot, stack );
NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.getId(), this.getFluidStack() ) ) );
}
public void setFluidStack(final IAEFluidStack stack) {
this.fluids.setFluidInSlot(this.slot, stack);
NetworkHandler.instance().sendToServer(new PacketFluidSlot(Collections.singletonMap(this.getId(), this.getFluidStack())));
}
}
@@ -19,9 +19,12 @@
package appeng.fluids.client.gui.widgets;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.client.gui.widgets.ITooltip;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.fluids.util.IAEFluidTank;
import appeng.helpers.InventoryAction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
@@ -31,127 +34,104 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.widgets.ITooltip;
import appeng.fluids.util.IAEFluidTank;
@SideOnly(Side.CLIENT)
public class GuiFluidTank extends GuiCustomSlot implements ITooltip {
private final IAEFluidTank tank;
private final int slot;
private final int width;
private final int height;
@SideOnly( Side.CLIENT )
public class GuiFluidTank extends GuiCustomSlot implements ITooltip
{
private final IAEFluidTank tank;
private final int slot;
private final int width;
private final int height;
public GuiFluidTank(IAEFluidTank tank, int slot, int id, int x, int y, int w, int h) {
super(id, x, y);
this.tank = tank;
this.slot = slot;
this.width = w;
this.height = h;
}
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
{
super( id, x, y );
this.tank = tank;
this.slot = slot;
this.width = w;
this.height = h;
}
@Override
public void drawContent(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
final IAEFluidStack fs = this.getFluidStack();
if (fs != null) {
GlStateManager.disableBlend();
GlStateManager.disableLighting();
@Override
public void drawContent( Minecraft mc, int mouseX, int mouseY, float partialTicks )
{
final IAEFluidStack fs = this.getFluidStack();
if( fs != null )
{
GlStateManager.disableBlend();
GlStateManager.disableLighting();
//drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
//drawRect( 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) {
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
{
mc.getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
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;
GlStateManager.color(red, green, blue);
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;
GlStateManager.color( 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()));
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() );
final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) );
int iconHeightRemainder = scaledHeight % 16;
if (iconHeightRemainder > 0) {
this.drawTexturedModalRect(this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder, sprite, 16, iconHeightRemainder);
}
for (int i = 0; i < scaledHeight / 16; i++) {
this.drawTexturedModalRect(this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder - (i + 1) * 16, sprite, 16, 16);
}
}
}
}
int iconHeightRemainder = scaledHeight % 16;
if( iconHeightRemainder > 0 )
{
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder, sprite, 16, iconHeightRemainder );
}
for( int i = 0; i < scaledHeight / 16; i++ )
{
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
}
}
}
}
@Override
public String getMessage() {
final IAEFluidStack fluid = this.tank.getFluidInSlot(this.slot);
if (fluid != null && fluid.getStackSize() > 0) {
String desc = fluid.getFluid().getLocalizedName(fluid.getFluidStack());
String amountToText = fluid.getStackSize() + "mB";
@Override
public String getMessage()
{
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
if( fluid != null && fluid.getStackSize() > 0 )
{
String desc = fluid.getFluid().getLocalizedName( fluid.getFluidStack() );
String amountToText = fluid.getStackSize() + "mB";
return desc + "\n" + amountToText;
}
return null;
}
return desc + "\n" + amountToText;
}
return null;
}
@Override
public int xPos() {
return this.x - 1;
}
@Override
public int xPos()
{
return this.x - 1;
}
@Override
public int yPos() {
return this.y - 4;
}
@Override
public int yPos()
{
return this.y - 4;
}
@Override
public int getWidth() {
return this.width;
}
@Override
public int getWidth()
{
return this.width;
}
@Override
public int getHeight() {
return this.height + 4;
}
@Override
public int getHeight()
{
return this.height + 4;
}
@Override
public boolean isVisible() {
return true;
}
@Override
public boolean isVisible()
{
return true;
}
public IAEFluidStack getFluidStack() {
return this.tank.getFluidInSlot(this.slot);
}
public IAEFluidStack getFluidStack()
{
return this.tank.getFluidInSlot( this.slot );
}
@Override
public void slotClicked(ItemStack clickStack, final int mouseButton) {
@Override
public void slotClicked( ItemStack clickStack, final int mouseButton )
{
if (getFluidStack() != null) {
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.FILL_ITEM, slot, 0));
} else {
NetworkHandler.instance().sendToServer(new PacketInventoryAction(InventoryAction.EMPTY_ITEM, slot, 0));
}
if( getFluidStack() != null )
{
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot, 0 ) );
}
else
{
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot, 0 ) );
}
}
}
}
@@ -1,63 +1,51 @@
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 net.minecraft.client.renderer.GlStateManager;
public class GuiOptionalFluidSlot extends GuiFluidSlot
{
private final IOptionalSlotHost containerBus;
private final int groupNum;
private final int srcX;
private final int srcY;
public class GuiOptionalFluidSlot extends GuiFluidSlot {
private final IOptionalSlotHost containerBus;
private final int groupNum;
private final int srcX;
private final int srcY;
public GuiOptionalFluidSlot( IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs )
{
super( fluids, slot, id, x + xoffs * 18, y + yoffs * 18 );
this.containerBus = containerBus;
this.groupNum = groupNum;
this.srcX = x;
this.srcY = y;
}
public GuiOptionalFluidSlot(IAEFluidTank fluids, final IOptionalSlotHost containerBus, int slot, int id, int groupNum, int x, int y, int xoffs, int yoffs) {
super(fluids, slot, id, x + xoffs * 18, y + yoffs * 18);
this.containerBus = containerBus;
this.groupNum = groupNum;
this.srcX = x;
this.srcY = y;
}
@Override
public boolean isSlotEnabled()
{
if( this.containerBus == null )
{
return false;
}
return this.containerBus.isSlotEnabled( this.groupNum );
}
@Override
public boolean isSlotEnabled() {
if (this.containerBus == null) {
return false;
}
return this.containerBus.isSlotEnabled(this.groupNum);
}
@Override
public IAEFluidStack getFluidStack()
{
if( !this.isSlotEnabled() && super.getFluidStack() != null )
{
this.setFluidStack( null );
}
return super.getFluidStack();
}
@Override
public IAEFluidStack getFluidStack() {
if (!this.isSlotEnabled() && super.getFluidStack() != null) {
this.setFluidStack(null);
}
return super.getFluidStack();
}
@Override
public void drawBackground( int guileft, int guitop )
{
GlStateManager.enableBlend();
if( this.isSlotEnabled() )
{
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
}
else
{
GlStateManager.color( 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 );
}
@Override
public void drawBackground(int guileft, int guitop) {
GlStateManager.enableBlend();
if (this.isSlotEnabled()) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
} else {
GlStateManager.color(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);
}
}
@@ -19,18 +19,17 @@
package appeng.fluids.client.render;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.AEConfig;
import appeng.util.ISlimReadableNumberConverter;
import appeng.util.IWideReadableNumberConverter;
import appeng.util.ReadableNumberConverter;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
/**
@@ -40,95 +39,81 @@ import appeng.util.ReadableNumberConverter;
* @version rv6
* @since rv6
*/
public class FluidStackSizeRenderer
{
public class FluidStackSizeRenderer {
private static final String[] NUMBER_FORMATS = new String[] { "#.000", "#.00", "#.0", "#" };
private static final String[] NUMBER_FORMATS = new String[]{"#.000", "#.00", "#.0", "#"};
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE;
private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE;
public void renderStackSize( FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos )
{
if( aeStack != null )
{
final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
final int offset = AEConfig.instance().useTerminalUseLargeFont() ? 0 : -1;
public void renderStackSize(FontRenderer fontRenderer, IAEFluidStack aeStack, int xPos, int yPos) {
if (aeStack != null) {
final float scaleFactor = AEConfig.instance().useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
final int offset = AEConfig.instance().useTerminalUseLargeFont() ? 0 : -1;
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
fontRenderer.setUnicodeFlag( false );
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
fontRenderer.setUnicodeFlag(false);
if( aeStack.getStackSize() > 0 )
{
final String stackSize = this.getToBeRenderedStackSize( aeStack.getStackSize() );
if (aeStack.getStackSize() > 0) {
final String stackSize = this.getToBeRenderedStackSize(aeStack.getStackSize());
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableBlend();
GlStateManager.pushMatrix();
GlStateManager.scale( scaleFactor, scaleFactor, scaleFactor );
final int X = (int) ( ( (float) xPos + offset + 16.0f - fontRenderer.getStringWidth( stackSize ) * scaleFactor ) * inverseScaleFactor );
final int Y = (int) ( ( (float) yPos + offset + 16.0f - 7.0f * scaleFactor ) * inverseScaleFactor );
fontRenderer.drawStringWithShadow( stackSize, X, Y, 16777215 );
GlStateManager.popMatrix();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableBlend();
GlStateManager.pushMatrix();
GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor);
final int X = (int) (((float) xPos + offset + 16.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor) * inverseScaleFactor);
final int Y = (int) (((float) yPos + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215);
GlStateManager.popMatrix();
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.enableBlend();
}
fontRenderer.setUnicodeFlag( unicodeFlag );
}
}
fontRenderer.setUnicodeFlag(unicodeFlag);
}
}
private String getToBeRenderedStackSize( final long originalSize )
{
// Handle any value below 100 (large font) or 1000 (small font) Buckets with a custom formatter,
// otherwise pass it to the normal number converter
if( originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont() )
{
return this.getSlimRenderedStacksize( originalSize );
}
else if( originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont() )
{
return this.getWideRenderedStacksize( originalSize );
}
private String getToBeRenderedStackSize(final long originalSize) {
// Handle any value below 100 (large font) or 1000 (small font) Buckets with a custom formatter,
// otherwise pass it to the normal number converter
if (originalSize < 1000 * 100 && AEConfig.instance().useTerminalUseLargeFont()) {
return this.getSlimRenderedStacksize(originalSize);
} else if (originalSize < 1000 * 1000 && !AEConfig.instance().useTerminalUseLargeFont()) {
return this.getWideRenderedStacksize(originalSize);
}
if( AEConfig.instance().useTerminalUseLargeFont() )
{
return SLIM_CONVERTER.toSlimReadableForm( originalSize / 1000 );
}
else
{
return WIDE_CONVERTER.toWideReadableForm( originalSize / 1000 );
}
}
if (AEConfig.instance().useTerminalUseLargeFont()) {
return SLIM_CONVERTER.toSlimReadableForm(originalSize / 1000);
} else {
return WIDE_CONVERTER.toWideReadableForm(originalSize / 1000);
}
}
private String getSlimRenderedStacksize( final long originalSize )
{
final int log = 1 + (int) Math.floor( Math.log10( originalSize ) ) / 2;
private String getSlimRenderedStacksize(final long originalSize) {
final int log = 1 + (int) Math.floor(Math.log10(originalSize)) / 2;
return this.getRenderedFluidStackSize( originalSize, log );
}
return this.getRenderedFluidStackSize(originalSize, log);
}
private String getWideRenderedStacksize( final long originalSize )
{
final int log = (int) Math.floor( Math.log10( originalSize ) ) / 2;
private String getWideRenderedStacksize(final long originalSize) {
final int log = (int) Math.floor(Math.log10(originalSize)) / 2;
return this.getRenderedFluidStackSize( originalSize, log );
}
return this.getRenderedFluidStackSize(originalSize, log);
}
private String getRenderedFluidStackSize( final long originalSize, final int log )
{
final int index = Math.max( 0, Math.min( 3, log ) );
private String getRenderedFluidStackSize(final long originalSize, final int log) {
final int index = Math.max(0, Math.min(3, log));
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator( '.' );
final DecimalFormat format = new DecimalFormat( NUMBER_FORMATS[index] );
format.setDecimalFormatSymbols( symbols );
format.setRoundingMode( RoundingMode.DOWN );
final DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
final DecimalFormat format = new DecimalFormat(NUMBER_FORMATS[index]);
format.setDecimalFormatSymbols(symbols);
format.setRoundingMode(RoundingMode.DOWN);
return format.format( originalSize / 1000d );
}
return format.format(originalSize / 1000d);
}
}