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;
@@ -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 MEGuiTextField textField;
private GuiButton confirmButton; private GuiButton confirmButton;
public GuiRenamer(InventoryPlayer ip, ICustomNameObject obj) { public GuiRenamer( InventoryPlayer ip, ICustomNameObject obj )
super(new ContainerRenamer(ip, obj)); {
super( new ContainerRenamer( ip, obj ) );
this.xSize = 256; this.xSize = 256;
this.textField = new MEGuiTextField(Minecraft.getMinecraft().fontRenderer, 0, 0, 230, 12) {
@Override
public void onTextChange(final String oldText) {
final String text = getText();
if (!text.equals(oldText)) {
((ContainerRenamer) inventorySlots).setCustomName(text);
}
}
};
this.textField.setEnableBackgroundDrawing(false);
this.textField.setMaxStringLength(32);
} }
@Override @Override
public void initGui() { public void initGui()
{
super.initGui(); super.initGui();
this.textField.x = this.guiLeft + 12; this.textField = new MEGuiTextField( this.fontRenderer, this.guiLeft + 9, this.guiTop + 33, 229, 12 );
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.textField.setEnableBackgroundDrawing( false );
this.textField.setMaxStringLength( 32 );
((ContainerRenamer) this.inventorySlots).setTextField(this.textField); this.textField.setFocused( true );
this.buttonList.add( this.confirmButton = new GuiButton( 0, this.guiLeft + 238, this.guiTop + 33, 12, 12, "↵" ) );
( (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.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.textField.drawTextBox(); 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 )
{ // Enter
try
{
NetworkHandler.instance().sendToServer( NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText())); new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
} catch (IOException e) { }
AELog.debug(e); catch( IOException e )
{
AELog.debug( e );
} }
this.mc.player.closeScreen(); this.mc.player.closeScreen();
} else if (!this.textField.textboxKeyTyped(character, key)) { }
super.keyTyped(character, key); 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 { {
try
{
NetworkHandler.instance().sendToServer( NetworkHandler.instance().sendToServer(
new PacketValueConfig("QuartzKnife.ReName", this.textField.getText())); new PacketValueConfig( "QuartzKnife.ReName", this.textField.getText() ) );
this.mc.player.closeScreen(); this.mc.player.closeScreen();
} catch (IOException e) { }
AELog.debug(e); 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;
@@ -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;