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;
@@ -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,41 +8,33 @@ 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.setEnableBackgroundDrawing( false );
this.textField.setMaxStringLength( 32 );
this.textField.setFocused( true ); 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, "↵" ) );
@@ -51,58 +43,72 @@ public class GuiRenamer extends AEBaseGui {
} }
@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.bindTexture( "guis/renamer.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); 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
{
if( this.textField.isMouseIn( xCoord, yCoord ) )
{
if( btn == 1 )
{
this.textField.setText( "" );
}
this.textField.mouseClicked( xCoord, yCoord, btn ); this.textField.mouseClicked( xCoord, yCoord, btn );
}
super.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) { }
catch( IOException e )
{
AELog.debug( e ); AELog.debug( e );
} }
this.mc.player.closeScreen(); this.mc.player.closeScreen();
} else if (!this.textField.textboxKeyTyped(character, key)) { }
else if( !this.textField.textboxKeyTyped( character, key ) )
{
super.keyTyped( 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) { }
catch( IOException e )
{
AELog.debug( 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,7 +180,7 @@ 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 );