Tile Entity Get and Save

This commit is contained in:
Kam committed 2025-02-02 17:03:45 -05:00
1 parent 55d271abad
commit 902fad4e6f
8 files changed
+51 -50

No files matched your search

@@ -1,5 +1,7 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileWaypoint;
@@ -13,7 +15,7 @@ import noppes.npcs.constants.EnumPacketServer;
public class GuiNpcWaypoint extends GuiNPCInterface{
private TileWaypoint tile;
public GuiNpcWaypoint(int x, int y, int z) {
super();
tile = (TileWaypoint) player.worldObj.getTileEntity(x, y, z);
@@ -23,11 +25,11 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
{
super.initGui();
addLabel(new GuiNpcLabel(0,"gui.name", guiLeft+ 1, guiTop + 76, 0xffffff));
addLabel(new GuiNpcLabel(0,"gui.name", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,200,20, tile.name));
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(2, 60, 10);
@@ -43,10 +45,10 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
public void save() {
tile.name = getTextField(0).getText();
tile.range = getTextField(1).getInteger();
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
PacketClient.sendClient(new TileEntitySavePacket(compound));
}
}