minor cleanup

This commit is contained in:
PrototypeTrousers
2022-09-05 15:08:04 -03:00
parent a9c891f69a
commit efb9ab512a
6 changed files with 105 additions and 98 deletions
@@ -28,6 +28,7 @@ import java.util.List;
import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; import appeng.parts.reporting.PartExpandedProcessingPatternTerminal;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@@ -127,7 +128,7 @@ public class GuiCraftConfirm extends AEBaseGui
this.buttonList.add( this.start ); this.buttonList.add( this.start );
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU
.getLocal() + ": " + GuiText.Automatic ); .getLocal() + ": " + GuiText.Automatic );
this.selectCPU.enabled = false; this.selectCPU.enabled = false;
this.buttonList.add( this.selectCPU ); this.buttonList.add( this.selectCPU );
@@ -227,7 +228,7 @@ public class GuiCraftConfirm extends AEBaseGui
else else
{ {
dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors
.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; .getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
} }
final int offset = ( 219 - this.fontRenderer.getStringWidth( dsp ) ) / 2; final int offset = ( 219 - this.fontRenderer.getStringWidth( dsp ) ) / 2;
@@ -294,7 +295,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.FromStorage.getLocal() + ": " + str; str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str ); final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart ) if( this.tooltip == z - viewStart )
{ {
@@ -320,7 +321,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.Missing.getLocal() + ": " + str; str = GuiText.Missing.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str ); final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart ) if( this.tooltip == z - viewStart )
{ {
@@ -346,7 +347,7 @@ public class GuiCraftConfirm extends AEBaseGui
str = GuiText.ToCraft.getLocal() + ": " + str; str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.fontRenderer.getStringWidth( str ); final int w = 4 + this.fontRenderer.getStringWidth( str );
this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), this.fontRenderer.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ),
( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
if( this.tooltip == z - viewStart ) if( this.tooltip == z - viewStart )
{ {
@@ -416,7 +417,7 @@ public class GuiCraftConfirm extends AEBaseGui
public void postUpdate( final List<IAEItemStack> list, final byte ref ) public void postUpdate( final List<IAEItemStack> list, final byte ref )
{ {
switch( ref ) switch ( ref )
{ {
case 0: case 0:
for( final IAEItemStack l : list ) for( final IAEItemStack l : list )
@@ -513,7 +514,7 @@ public class GuiCraftConfirm extends AEBaseGui
private void deleteVisualStack( final IAEItemStack l ) private void deleteVisualStack( final IAEItemStack l )
{ {
final Iterator<IAEItemStack> i = this.visual.iterator(); final Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() ) while ( i.hasNext() )
{ {
final IAEItemStack o = i.next(); final IAEItemStack o = i.next();
if( o.equals( l ) ) if( o.equals( l ) )
@@ -544,7 +545,7 @@ public class GuiCraftConfirm extends AEBaseGui
{ {
if( !this.checkHotbarKeys( key ) ) if( !this.checkHotbarKeys( key ) )
{ {
if( key == 28 ) if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
{ {
this.actionPerformed( this.start ); this.actionPerformed( this.start );
} }
@@ -21,6 +21,7 @@ package appeng.client.gui.implementations;
import java.io.IOException; import java.io.IOException;
import appeng.items.contents.QuartzKnifeObj;
import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
@@ -30,7 +31,6 @@ import appeng.core.AELog;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.bootstrap.contents.QuartzKnifeObj;
public class GuiQuartzKnife extends AEBaseGui public class GuiQuartzKnife extends AEBaseGui
@@ -8,101 +8,107 @@ import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig; import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.ICustomNameObject; import appeng.helpers.ICustomNameObject;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import org.lwjgl.input.Keyboard;
import java.io.IOException; import java.io.IOException;
public class GuiRenamer extends AEBaseGui { public class GuiRenamer extends AEBaseGui
private MEGuiTextField textField; {
private GuiButton confirmButton; private MEGuiTextField textField;
private GuiButton confirmButton;
public GuiRenamer(InventoryPlayer ip, ICustomNameObject obj) { public GuiRenamer( InventoryPlayer ip, ICustomNameObject obj )
super(new ContainerRenamer(ip, obj)); {
this.xSize = 256; super( new ContainerRenamer( ip, obj ) );
this.xSize = 256;
}
this.textField = new MEGuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 230, 12) { @Override
@Override public void initGui()
public void onTextChange(final String oldText) { {
final String text = getText(); super.initGui();
if (!text.equals(oldText)) { this.textField = new MEGuiTextField( this.fontRenderer, this.guiLeft + 9, this.guiTop + 33, 229, 12 );
((ContainerRenamer) inventorySlots).setCustomName(text);
}
}
};
this.textField.setEnableBackgroundDrawing(false);
this.textField.setMaxStringLength(32);
}
@Override this.textField.setEnableBackgroundDrawing( false );
public void initGui() { this.textField.setMaxStringLength( 32 );
super.initGui();
this.textField.x = this.guiLeft + 12; this.textField.setFocused( true );
this.textField.y = this.guiTop + 35;
this.textField.setFocused(true);
this.buttonList.add(this.confirmButton = new GuiButton(0, this.guiLeft + 238, this.guiTop + 33, 12, 12, "↵")); this.buttonList.add( this.confirmButton = new GuiButton( 0, this.guiLeft + 238, this.guiTop + 33, 12, 12, "↵" ) );
((ContainerRenamer) this.inventorySlots).setTextField(this.textField); ( (ContainerRenamer) this.inventorySlots ).setTextField( this.textField );
} }
@Override @Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY )
this.fontRenderer.drawString(this.getGuiDisplayName(GuiText.Renamer.getLocal()), 12, 8, 4210752); {
} this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.Renamer.getLocal() ), 12, 8, 4210752 );
}
@Override @Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { public void drawBG( int offsetX, int offsetY, int mouseX, int mouseY )
this.bindTexture("guis/renamer.png"); {
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize); this.bindTexture( "guis/renamer.png" );
this.textField.drawTextBox(); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
} this.textField.drawTextBox();
}
@Override @Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) throws IOException{ protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
this.textField.mouseClicked(xCoord, yCoord, btn); {
super.mouseClicked(xCoord, yCoord, btn); if( this.textField.isMouseIn( xCoord, yCoord ) )
} {
if( btn == 1 )
{
this.textField.setText( "" );
}
this.textField.mouseClicked( xCoord, yCoord, btn );
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override @Override
protected void keyTyped(final char character, final int key) throws IOException { protected void keyTyped( final char character, final int key ) throws IOException
if (key == 28) { // Enter {
try { if( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER )
NetworkHandler.instance().sendToServer( { // Enter
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText())); try
} catch (IOException e) { {
AELog.debug(e); NetworkHandler.instance().sendToServer(
} new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
this.mc.player.closeScreen(); }
} else if (!this.textField.textboxKeyTyped(character, key)) { catch( IOException e )
super.keyTyped(character, key); {
} AELog.debug( e );
} }
this.mc.player.closeScreen();
}
else if( !this.textField.textboxKeyTyped( character, key ) )
{
super.keyTyped( character, key );
}
}
@Override @Override
protected void actionPerformed(final GuiButton btn) throws IOException { protected void actionPerformed( final GuiButton btn ) throws IOException
super.actionPerformed(btn); {
super.actionPerformed( btn );
if(btn == this.confirmButton) { if( btn == this.confirmButton )
try { {
NetworkHandler.instance().sendToServer( try
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText())); {
this.mc.player.closeScreen(); NetworkHandler.instance().sendToServer(
} catch (IOException e) { new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
AELog.debug(e); this.mc.player.closeScreen();
} }
} catch( IOException e )
} {
AELog.debug( e );
public boolean isOverTextField(final int mousex, final int mousey) { }
return textField.isMouseIn(mousex, mousey); }
} }
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
textField.setText(displayName);
}
} }
@@ -21,6 +21,7 @@ package appeng.container.implementations;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import appeng.items.contents.QuartzKnifeObj;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -33,7 +34,6 @@ import appeng.api.AEApi;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotOutput; import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.bootstrap.contents.QuartzKnifeObj;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform; import appeng.util.Platform;
@@ -122,12 +122,12 @@ public class ContainerQuartzKnife extends AEBaseContainer
if( ContainerQuartzKnife.this.myName.length() > 0 ) if( ContainerQuartzKnife.this.myName.length() > 0 )
{ {
return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map( namePressStack -> return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map( namePressStack ->
{ {
final NBTTagCompound compound = Platform.openNbtData( namePressStack ); final NBTTagCompound compound = Platform.openNbtData( namePressStack );
compound.setString( "InscribeName", ContainerQuartzKnife.this.myName ); compound.setString( "InscribeName", ContainerQuartzKnife.this.myName );
return namePressStack; return namePressStack;
} ).orElse( ItemStack.EMPTY ); } ).orElse( ItemStack.EMPTY );
} }
} }
return ItemStack.EMPTY; return ItemStack.EMPTY;
@@ -19,6 +19,7 @@
package appeng.container.implementations; package appeng.container.implementations;
import appeng.items.contents.NetworkToolViewer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -45,7 +46,6 @@ import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.OptionalSlotFakeTypeOnly; import appeng.container.slot.OptionalSlotFakeTypeOnly;
import appeng.container.slot.SlotFakeTypeOnly; import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.bootstrap.contents.NetworkToolViewer;
import appeng.items.tools.ToolNetworkTool; import appeng.items.tools.ToolNetworkTool;
import appeng.parts.automation.PartExportBus; import appeng.parts.automation.PartExportBus;
import appeng.util.Platform; import appeng.util.Platform;
@@ -23,6 +23,7 @@ import java.lang.reflect.Constructor;
import appeng.container.implementations.*; import appeng.container.implementations.*;
import appeng.helpers.ICustomNameObject; import appeng.helpers.ICustomNameObject;
import appeng.items.contents.QuartzKnifeObj;
import appeng.parts.misc.PartOreDicStorageBus; import appeng.parts.misc.PartOreDicStorageBus;
import appeng.parts.reporting.*; import appeng.parts.reporting.*;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@@ -71,7 +72,6 @@ import appeng.fluids.parts.PartSharedFluidBus;
import appeng.helpers.IInterfaceHost; import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.bootstrap.contents.QuartzKnifeObj;
import appeng.parts.automation.PartFormationPlane; import appeng.parts.automation.PartFormationPlane;
import appeng.parts.automation.PartLevelEmitter; import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.misc.PartStorageBus; import appeng.parts.misc.PartStorageBus;
@@ -180,9 +180,9 @@ public enum GuiBridge implements IGuiHandler
GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ), GUI_CRAFTING_STATUS( ContainerCraftingStatus.class, ITerminalHost.class, GuiHostType.ITEM_OR_WORLD, SecurityPermissions.CRAFT ),
GUI_INTERFACE_CONFIGURATION_TERMINAL( ContainerInterfaceConfigurationTerminal.class, PartInterfaceConfigurationTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ); GUI_INTERFACE_CONFIGURATION_TERMINAL( ContainerInterfaceConfigurationTerminal.class, PartInterfaceConfigurationTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_RENAMER(ContainerRenamer.class, ICustomNameObject.class, GuiHostType.WORLD, SecurityPermissions.BUILD); GUI_RENAMER( ContainerRenamer.class, ICustomNameObject.class, GuiHostType.WORLD, SecurityPermissions.BUILD );
private final Class tileClass; private final Class tileClass;
private final Class containerClass; private final Class containerClass;