Files
CustomNPC-Plus/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java
T

65 lines
2.1 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.client.gui;
2025-02-02 17:00:32 -05:00
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
2025-02-02 17:03:45 -05:00
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
2018-09-13 12:03:28 -04:00
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileBorder;
2023-01-12 21:33:06 -05:00
import noppes.npcs.client.gui.util.*;
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public class GuiBorderBlock extends GuiNPCInterface implements IGuiData {
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
private TileBorder tile;
2025-02-02 17:00:32 -05:00
2018-09-13 12:03:28 -04:00
public GuiBorderBlock(int x, int y, int z) {
2025-03-13 17:14:45 -04:00
super();
tile = (TileBorder) player.worldObj.getTileEntity(x, y, z);
2025-02-02 17:00:32 -05:00
PacketClient.sendClient(new TileEntityGetPacket(x, y, z));
2025-03-13 17:14:45 -04:00
}
public void initGui() {
super.initGui();
2025-02-02 17:00:32 -05:00
2025-03-13 17:14:45 -04:00
this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 40, 120, 20, "Availability Options"));
2025-02-02 17:00:32 -05:00
2025-03-13 17:14:45 -04:00
addLabel(new GuiNpcLabel(0, "Height", guiLeft + 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 60, guiTop + 71, 40, 20, tile.height + ""));
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 500, 6);
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
addLabel(new GuiNpcLabel(1, "Message", guiLeft + 1, guiTop + 100, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 60, guiTop + 95, 200, 20, tile.message));
2025-02-02 17:00:32 -05:00
2025-03-13 17:14:45 -04:00
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190, 120, 20, "Done"));
2018-09-13 12:03:28 -04:00
}
2025-03-13 17:14:45 -04:00
protected void actionPerformed(GuiButton guibutton) {
int id = guibutton.id;
if (id == 0)
close();
if (id == 4) {
save();
setSubGui(new SubGuiNpcAvailability(tile.availability));
}
}
@Override
public void save() {
if (tile == null)
return;
tile.height = getTextField(0).getInteger();
tile.message = getTextField(1).getText();
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
2025-02-02 17:03:45 -05:00
PacketClient.sendClient(new TileEntitySavePacket(compound));
2025-03-13 17:14:45 -04:00
}
@Override
public void setGuiData(NBTTagCompound compound) {
tile.readFromNBT(compound);
}
2018-09-13 12:03:28 -04:00
}