mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-22 05:02:21 +00:00
Update buildscript, apply spotless (#175)
This commit is contained in:
1 parent
08d0ef617f
commit
a40ee7424f
1220 files changed
+95126
-109823
No files matched your search
@@ -16,7 +16,6 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketPatternValueSet;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
@@ -29,8 +28,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GuiPatternValueAmount extends AEBaseGui
|
||||
{
|
||||
public class GuiPatternValueAmount extends AEBaseGui {
|
||||
|
||||
private GuiTextField amountToSet;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
@@ -51,118 +49,105 @@ public class GuiPatternValueAmount extends AEBaseGui
|
||||
private final int originalAmount;
|
||||
|
||||
@Reflected
|
||||
public GuiPatternValueAmount( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( new ContainerPatternValueAmount( inventoryPlayer, te ) );
|
||||
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerPatternValueAmount(inventoryPlayer, te));
|
||||
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
if( gui != null && gui.theSlot != null && gui.theSlot.getHasStack() )
|
||||
{
|
||||
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
|
||||
Slot slot = gui.theSlot;
|
||||
originalAmount = slot.getStack().stackSize;
|
||||
valueIndex = slot.slotNumber;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
valueIndex = -1;
|
||||
originalAmount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
|
||||
|
||||
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
|
||||
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
|
||||
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
|
||||
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
|
||||
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
|
||||
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
|
||||
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
|
||||
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
|
||||
|
||||
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
|
||||
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
|
||||
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
|
||||
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
|
||||
|
||||
this.buttonList.add( this.set = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
|
||||
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
|
||||
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
|
||||
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
|
||||
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
|
||||
|
||||
this.buttonList.add(
|
||||
this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
|
||||
ItemStack myIcon = null;
|
||||
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
|
||||
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( target instanceof PartPatternTerminal )
|
||||
{
|
||||
for( final ItemStack stack : parts.patternTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
for (final ItemStack stack : parts.patternTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if( target instanceof PartPatternTerminalEx )
|
||||
{
|
||||
for( final ItemStack stack : parts.patternTerminalEx().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
if (target instanceof PartPatternTerminalEx) {
|
||||
for (final ItemStack stack : parts.patternTerminalEx().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
if( this.originalGui != null && myIcon != null )
|
||||
{
|
||||
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
if (this.originalGui != null && myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
|
||||
}
|
||||
|
||||
this.amountToSet = new GuiTextField( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT );
|
||||
this.amountToSet.setEnableBackgroundDrawing( false );
|
||||
this.amountToSet.setMaxStringLength( 16 );
|
||||
this.amountToSet.setTextColor( GuiColors.CraftAmountToCraft.getColor() );
|
||||
this.amountToSet.setVisible( true );
|
||||
this.amountToSet.setFocused( true );
|
||||
this.amountToSet.setText( String.valueOf( originalAmount ) );
|
||||
this.amountToSet.setSelectionPos( 0 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, GuiColors.CraftAmountSelectAmount.getColor() );
|
||||
this.amountToSet = new GuiTextField(
|
||||
this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
|
||||
this.amountToSet.setEnableBackgroundDrawing(false);
|
||||
this.amountToSet.setMaxStringLength(16);
|
||||
this.amountToSet.setTextColor(GuiColors.CraftAmountToCraft.getColor());
|
||||
this.amountToSet.setVisible(true);
|
||||
this.amountToSet.setFocused(true);
|
||||
this.amountToSet.setText(String.valueOf(originalAmount));
|
||||
this.amountToSet.setSelectionPos(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(
|
||||
GuiText.SelectAmount.getLocal(), 8, 6, GuiColors.CraftAmountSelectAmount.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.set.displayString = GuiText.Set.getLocal();
|
||||
this.set.enabled = valueIndex >= 0;
|
||||
|
||||
this.bindTexture( "guis/craftAmt.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
this.bindTexture("guis/craftAmt.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
String out = this.amountToSet.getText();
|
||||
|
||||
double resultD = Calculator.conversion( out );
|
||||
double resultD = Calculator.conversion(out);
|
||||
int resultI;
|
||||
|
||||
if( resultD <= 0 || Double.isNaN( resultD ) )
|
||||
{
|
||||
if (resultD <= 0 || Double.isNaN(resultD)) {
|
||||
resultI = 0;
|
||||
} else
|
||||
{
|
||||
resultI = (int) ArithHelper.round( resultD, 0 );
|
||||
} else {
|
||||
resultI = (int) ArithHelper.round(resultD, 0);
|
||||
}
|
||||
|
||||
this.set.enabled = resultI > 0;
|
||||
} catch( final NumberFormatException e )
|
||||
{
|
||||
} catch (final NumberFormatException e) {
|
||||
this.set.enabled = false;
|
||||
}
|
||||
|
||||
@@ -170,102 +155,84 @@ public class GuiPatternValueAmount extends AEBaseGui
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key )
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( key == 28 )
|
||||
{
|
||||
this.actionPerformed( this.set );
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.set);
|
||||
}
|
||||
this.amountToSet.textboxKeyTyped( character, key );
|
||||
super.keyTyped( character, key );
|
||||
this.amountToSet.textboxKeyTyped(character, key);
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
|
||||
if( btn == this.set && btn.enabled )
|
||||
{
|
||||
double resultD = Calculator.conversion( this.amountToSet.getText() );
|
||||
if (btn == this.set && btn.enabled) {
|
||||
double resultD = Calculator.conversion(this.amountToSet.getText());
|
||||
int resultI;
|
||||
|
||||
if( resultD <= 0 || Double.isNaN( resultD ) )
|
||||
{
|
||||
if (resultD <= 0 || Double.isNaN(resultD)) {
|
||||
resultI = 1;
|
||||
} else
|
||||
{
|
||||
resultI = (int) ArithHelper.round( resultD, 0 );
|
||||
} else {
|
||||
resultI = (int) ArithHelper.round(resultD, 0);
|
||||
}
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketPatternValueSet( originalGui.ordinal(), resultI, valueIndex ) );
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
|
||||
}
|
||||
} catch( final NumberFormatException e )
|
||||
{
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.amountToSet.setText( "1" );
|
||||
this.amountToSet.setText("1");
|
||||
}
|
||||
|
||||
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 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 int i )
|
||||
{
|
||||
try
|
||||
{
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToSet.getText();
|
||||
|
||||
double resultD = Calculator.conversion( out );
|
||||
double resultD = Calculator.conversion(out);
|
||||
int resultI;
|
||||
|
||||
if( resultD <= 0 || Double.isNaN( resultD ) )
|
||||
{
|
||||
if (resultD <= 0 || Double.isNaN(resultD)) {
|
||||
resultI = 0;
|
||||
} else
|
||||
{
|
||||
resultI = (int) ArithHelper.round( resultD, 0 );
|
||||
} else {
|
||||
resultI = (int) ArithHelper.round(resultD, 0);
|
||||
}
|
||||
|
||||
if( resultI == 1 && i > 1 )
|
||||
{
|
||||
if (resultI == 1 && i > 1) {
|
||||
resultI = 0;
|
||||
}
|
||||
|
||||
resultI += i;
|
||||
if( resultI < 1 )
|
||||
{
|
||||
if (resultI < 1) {
|
||||
resultI = 1;
|
||||
}
|
||||
|
||||
out = Integer.toString( resultI );
|
||||
out = Integer.toString(resultI);
|
||||
|
||||
this.amountToSet.setText( out );
|
||||
} catch( final NumberFormatException e )
|
||||
{
|
||||
this.amountToSet.setText(out);
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user