mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 04:05:12 +00:00
Tile Entity Get and Save
This commit is contained in:
1 parent
55d271abad
commit
902fad4e6f
8 files changed
+51
-50
No files matched your search
@@ -246,6 +246,7 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new ModelDataSavePacket());
|
||||
REQUEST_PACKET.registerPacket(new MailOpenSetupPacket());
|
||||
REQUEST_PACKET.registerPacket(new TileEntityGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new TileEntitySavePacket());
|
||||
}
|
||||
|
||||
public void registerDataPackets(){
|
||||
|
||||
@@ -97,7 +97,7 @@ public enum EnumRequestPacket {
|
||||
|
||||
RemoteNpcsGet,
|
||||
RemoteTpToNpc,
|
||||
SaveTileEntity,
|
||||
TileEntitySave,
|
||||
TileEntityGet,
|
||||
Gui,
|
||||
IsGuiOpen,
|
||||
|
||||
@@ -9,16 +9,16 @@ import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class TileEntitySavePacket extends AbstractPacket {
|
||||
public static final String packetName = "Request|TileEntityGet";
|
||||
public static final String packetName = "Request|TileEntitySave";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.TileEntityGet;
|
||||
return EnumRequestPacket.TileEntitySave;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,9 +41,7 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(this.x);
|
||||
out.writeInt(this.y);
|
||||
out.writeInt(this.z);
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,9 +52,6 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||
return;
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(in.readInt(), in.readInt(), in.readInt());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, ByteBufUtils.readNBT(in));
|
||||
}
|
||||
}
|
||||
@@ -365,10 +365,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
|
||||
private void blockPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if (type == EnumPacketServer.SaveTileEntity) {
|
||||
NoppesUtilServer.saveTileEntity(player, ByteBufUtils.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoriesGet){
|
||||
if(type == EnumPacketServer.DialogCategoriesGet){
|
||||
ScrollDataPacket.sendScrollData(player, DialogController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogsGetFromDialog){
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.blocks.tiles.TileBorder;
|
||||
@@ -53,7 +54,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
|
||||
PacketClient.sendClient(new TileEntitySavePacket(compound));
|
||||
}
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
|
||||
@@ -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 net.minecraft.util.StatCollector;
|
||||
@@ -14,58 +16,58 @@ import noppes.npcs.constants.EnumPacketServer;
|
||||
public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
|
||||
private TileRedstoneBlock tile;
|
||||
|
||||
|
||||
public GuiNpcRedstoneBlock(int x, int y, int z) {
|
||||
super();
|
||||
tile = (TileRedstoneBlock) player.worldObj.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 20, 120, 20, "availability.options"));
|
||||
|
||||
addLabel(new GuiNpcLabel(11,"gui.detailed", guiLeft+ 40, guiTop + 47, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(11,"gui.detailed", guiLeft+ 40, guiTop + 47, 0xffffff));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 42, 50, 20, new String[]{"gui.no", "gui.yes"},tile.isDetailed?1:0));
|
||||
|
||||
|
||||
if(tile.isDetailed){
|
||||
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
|
||||
getTextField(0).integersOnly = true;
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
||||
getTextField(1).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
|
||||
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
||||
getTextField(4).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
|
||||
getTextField(5).integersOnly = true;
|
||||
getTextField(5).setMinMaxDefault(0, 50, 10);
|
||||
}
|
||||
else{
|
||||
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
|
||||
getTextField(0).integersOnly = true;
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
}
|
||||
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
||||
}
|
||||
@@ -96,7 +98,7 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
tile.offRangeX = getTextField(3).getInteger();
|
||||
tile.offRangeY = getTextField(4).getInteger();
|
||||
tile.offRangeZ = getTextField(5).getInteger();
|
||||
|
||||
|
||||
if(tile.onRangeX > tile.offRangeX)
|
||||
tile.offRangeX = tile.onRangeX;
|
||||
if(tile.onRangeY > tile.offRangeY)
|
||||
@@ -111,10 +113,10 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
tile.offRange = tile.onRange;
|
||||
}
|
||||
tile.isActivated = false;
|
||||
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
|
||||
PacketClient.sendClient(new TileEntitySavePacket(compound));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,11 +54,14 @@ public enum EnumPacketServer {
|
||||
SpawnRider(CustomNpcsPermissions.TOOL_MOUNTER),
|
||||
MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true), MovingPathGet(true),
|
||||
|
||||
QuestLogToServer, PartyLogToServer, UntrackQuest,
|
||||
QuestLogToServer,
|
||||
PartyLogToServer,
|
||||
UntrackQuest,
|
||||
|
||||
QuestGet,
|
||||
SaveTileEntity,
|
||||
DimensionTeleport, GetTileEntity, IsGuiOpen,
|
||||
DimensionTeleport,
|
||||
GetTileEntity,
|
||||
IsGuiOpen,
|
||||
|
||||
SavePartyData, CreateParty, GetPartyData, DisbandParty, KickPlayer, LeavePlayer, PartyInvite, GetPartyInviteList, AcceptInvite,
|
||||
IgnoreInvite, SetPartyLeader, SetPartyQuest,
|
||||
|
||||
Reference in new issue
Block a user