Lots more packet schtuff

This commit is contained in:
Kam committed 2025-02-02 17:00:32 -05:00
1 parent 601123811a
commit 55d271abad
27 files changed
+276 -190

No files matched your search

@@ -15,6 +15,7 @@ import kamkeel.npcs.network.packets.data.large.*;
import kamkeel.npcs.network.packets.data.npc.*;
import kamkeel.npcs.network.packets.data.script.*;
import kamkeel.npcs.network.packets.request.*;
import kamkeel.npcs.network.packets.request.animation.*;
import kamkeel.npcs.network.packets.request.bank.BankGetPacket;
import kamkeel.npcs.network.packets.request.bank.BankRemovePacket;
import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
@@ -52,9 +53,7 @@ import kamkeel.npcs.network.packets.request.recipe.RecipesGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleCompanionUpdatePacket;
import kamkeel.npcs.network.packets.request.role.RoleGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
import kamkeel.npcs.network.packets.request.tags.TagRemovePacket;
import kamkeel.npcs.network.packets.request.tags.TagSavePacket;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import kamkeel.npcs.network.packets.request.tags.*;
import kamkeel.npcs.network.packets.request.transform.TransformGetPacket;
import kamkeel.npcs.network.packets.request.transform.TransformLoadPacket;
import kamkeel.npcs.network.packets.request.transform.TransformSavePacket;
@@ -105,7 +104,6 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new NpcClosePacket());
REQUEST_PACKET.registerPacket(new NpcDeletePacket());
// Linked Packets
REQUEST_PACKET.registerPacket(new LinkedGetAllPacket());
REQUEST_PACKET.registerPacket(new LinkedRemovePacket());
@@ -149,6 +147,7 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new QuestCategoryGetPacket());
// Quest Packets
REQUEST_PACKET.registerPacket(new QuestOpenGuiPacket());
REQUEST_PACKET.registerPacket(new QuestSavePacket());
REQUEST_PACKET.registerPacket(new QuestRemovePacket());
REQUEST_PACKET.registerPacket(new QuestDialogGetTitlePacket());
@@ -159,6 +158,8 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new FactionSetPacket());
// Tag Packets
REQUEST_PACKET.registerPacket(new TagsGetPacket());
REQUEST_PACKET.registerPacket(new TagsNpcGetPacket());
REQUEST_PACKET.registerPacket(new TagSetPacket());
REQUEST_PACKET.registerPacket(new TagSavePacket());
REQUEST_PACKET.registerPacket(new TagRemovePacket());
@@ -227,6 +228,15 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new TransformGetPacket());
REQUEST_PACKET.registerPacket(new TransformLoadPacket());
// Trader Packets
REQUEST_PACKET.registerPacket(new TraderMarketSavePacket());
// Animation Packets
REQUEST_PACKET.registerPacket(new AnimationsGetPacket());
REQUEST_PACKET.registerPacket(new AnimationGetPacket());
REQUEST_PACKET.registerPacket(new AnimationRemovePacket());
REQUEST_PACKET.registerPacket(new AnimationSavePacket());
// Other Packets
REQUEST_PACKET.registerPacket(new IsGuiOpenInform());
REQUEST_PACKET.registerPacket(new GuiRequestPacket());
@@ -235,6 +245,7 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new MerchantUpdatePacket());
REQUEST_PACKET.registerPacket(new ModelDataSavePacket());
REQUEST_PACKET.registerPacket(new MailOpenSetupPacket());
REQUEST_PACKET.registerPacket(new TileEntityGetPacket());
}
public void registerDataPackets(){
@@ -98,7 +98,7 @@ public enum EnumRequestPacket {
RemoteNpcsGet,
RemoteTpToNpc,
SaveTileEntity,
GetTileEntity,
TileEntityGet,
Gui,
IsGuiOpen,
CacheAnimation,
@@ -8,7 +8,7 @@ import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumDataPacket;
import kamkeel.npcs.network.packets.request.AnimationCachePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationCachePacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
@@ -1,55 +0,0 @@
package kamkeel.npcs.network.packets.request;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.CustomNpcsPermissions;
import java.io.IOException;
public final class REQUESTPacket extends AbstractPacket {
public static final String packetName = "Request|Name";
public REQUESTPacket() {
}
@Override
public Enum getType() {
return EnumRequestPacket.NPCDelete;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public CustomNpcsPermissions.Permission getPermission() {
return null;
}
@Override
public boolean needsNPC() {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
}
}
@@ -0,0 +1,71 @@
package kamkeel.npcs.network.packets.request;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
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.network.packets.data.large.ScrollDataPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.WorldProvider;
import net.minecraftforge.common.DimensionManager;
import java.io.IOException;
import java.util.HashMap;
public final class TileEntityGetPacket extends AbstractPacket {
public static final String packetName = "Request|TileEntityGet";
private int x;
private int y;
private int z;
public TileEntityGetPacket() {}
public TileEntityGetPacket(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public Enum getType() {
return EnumRequestPacket.TileEntityGet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.x);
out.writeInt(this.y);
out.writeInt(this.z);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
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);
}
}
@@ -0,0 +1,62 @@
package kamkeel.npcs.network.packets.request;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
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 net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import java.io.IOException;
public final class TileEntitySavePacket extends AbstractPacket {
public static final String packetName = "Request|TileEntityGet";
private NBTTagCompound compound;
public TileEntitySavePacket() {}
public TileEntitySavePacket(NBTTagCompound compound) {
this.compound = compound;
}
@Override
public Enum getType() {
return EnumRequestPacket.TileEntityGet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.x);
out.writeInt(this.y);
out.writeInt(this.z);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
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);
}
}
@@ -21,8 +21,16 @@ import java.io.IOException;
public final class TraderMarketSavePacket extends AbstractPacket {
public static String packetName = "Request|TraderMarketSave";
private String marketName;
private boolean setMarket;
public TraderMarketSavePacket() { }
public TraderMarketSavePacket(String marketName, boolean setMarket) {
this.marketName = marketName;
this.setMarket = setMarket;
}
@Override
public Enum getType() {
return EnumRequestPacket.TraderMarketSave;
@@ -45,14 +53,23 @@ public final class TraderMarketSavePacket extends AbstractPacket {
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException { }
public void sendData(ByteBuf out) throws IOException {
ByteBufUtils.writeString(out, this.marketName);
out.writeBoolean(this.setMarket);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP)) return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
String market = ByteBufUtils.readString(in);
if (market == null) return;
if (market == null)
return;
boolean bo = in.readBoolean();
if(npc.roleInterface instanceof RoleTrader){
if(bo)
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.request;
package kamkeel.npcs.network.packets.request.animation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -21,8 +21,14 @@ import java.io.IOException;
public final class AnimationGetPacket extends AbstractPacket {
public static String packetName = "Request|AnimationGet";
private int animationID;
public AnimationGetPacket() { }
public AnimationGetPacket(int animationID) {
this.animationID = animationID;
}
@Override
public Enum getType() {
return EnumRequestPacket.AnimationGet;
@@ -35,13 +41,17 @@ public final class AnimationGetPacket extends AbstractPacket {
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(0);
out.writeInt(animationID);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP)) return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
int id = in.readInt();
Animation animation = (Animation) AnimationController.getInstance().get(id);
NBTTagCompound compound = animation.writeToNBT();
@@ -23,8 +23,14 @@ import java.io.IOException;
public final class AnimationRemovePacket extends AbstractPacket {
public static String packetName = "Request|AnimationRemove";
private int animationID;
public AnimationRemovePacket() { }
public AnimationRemovePacket(int animationID) {
this.animationID = animationID;
}
@Override
public Enum getType() {
return EnumRequestPacket.AnimationRemove;
@@ -43,13 +49,17 @@ public final class AnimationRemovePacket extends AbstractPacket {
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(0);
out.writeInt(this.animationID );
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP)) return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
int id = in.readInt();
AnimationController.getInstance().delete(id);
NoppesUtilServer.sendAnimationDataAll((EntityPlayerMP) player);
@@ -29,7 +29,7 @@ public final class AnimationSavePacket extends AbstractPacket {
public AnimationSavePacket(NBTTagCompound animationNBT) {
this.animationNBT = animationNBT;
}
public AnimationSavePacket() { }
public AnimationSavePacket(){}
@Override
public Enum getType() {
@@ -54,8 +54,12 @@ public final class AnimationSavePacket extends AbstractPacket {
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP)) return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
NBTTagCompound compound = ByteBufUtils.readNBT(in);
Animation animation = new Animation();
animation.readFromNBT(compound);
@@ -36,8 +36,11 @@ public final class AnimationsGetPacket extends AbstractPacket {
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP)) return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
NoppesUtilServer.sendAnimationDataAll((EntityPlayerMP) player);
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.request;
package kamkeel.npcs.network.packets.request.quest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.controllers.data.Quest;
import java.io.IOException;
@@ -22,16 +23,15 @@ import java.io.IOException;
public final class QuestOpenGuiPacket extends AbstractPacket {
public static String packetName = "Request|QuestOpenGui";
private int guiId;
private EnumGuiType guiType;
private NBTTagCompound questNBT;
public QuestOpenGuiPacket(int guiId, NBTTagCompound questNBT) {
this.guiId = guiId;
public QuestOpenGuiPacket(EnumGuiType guiType, NBTTagCompound questNBT) {
this.guiType = guiType;
this.questNBT = questNBT;
}
public QuestOpenGuiPacket() {
}
public QuestOpenGuiPacket() {}
@Override
public Enum getType() {
@@ -46,7 +46,7 @@ public final class QuestOpenGuiPacket extends AbstractPacket {
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(guiId);
out.writeInt(guiType.ordinal());
ByteBufUtils.writeNBT(out, questNBT);
}
@@ -54,6 +54,7 @@ public final class QuestOpenGuiPacket extends AbstractPacket {
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
return;
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.request;
package kamkeel.npcs.network.packets.request.quest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.request;
package kamkeel.npcs.network.packets.request.tags;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -6,6 +6,8 @@ import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -36,6 +38,9 @@ public final class TagsGetPacket extends AbstractPacket {
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER))
return;
NoppesUtilServer.sendTagDataAll((EntityPlayerMP) player);
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.network.packets.request;
package kamkeel.npcs.network.packets.request.tags;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -6,6 +6,8 @@ import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
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 net.minecraft.entity.player.EntityPlayer;
@@ -22,8 +24,7 @@ import java.util.UUID;
public final class TagsNpcGetPacket extends AbstractPacket {
public static final String packetName = "Request|NpcTagsGet";
public TagsNpcGetPacket() {
}
public TagsNpcGetPacket() {}
@Override
public Enum getType() {
@@ -47,6 +48,9 @@ public final class TagsNpcGetPacket extends AbstractPacket {
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER))
return;
NBTTagCompound compound = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();
for (UUID uuid : npc.advanced.tagUUIDs) {
@@ -368,12 +368,6 @@ public class PacketHandlerServer{
if (type == EnumPacketServer.SaveTileEntity) {
NoppesUtilServer.saveTileEntity(player, ByteBufUtils.readNBT(buffer));
}
else if(type == EnumPacketServer.GetTileEntity){
TileEntity tile = player.worldObj.getTileEntity(buffer.readInt(), buffer.readInt(), buffer.readInt());
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
GuiDataPacket.sendGuiData(player, compound);
}
else if(type == EnumPacketServer.DialogCategoriesGet){
ScrollDataPacket.sendScrollData(player, DialogController.Instance.getScroll());
}
@@ -449,48 +443,7 @@ public class PacketHandlerServer{
}
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
if(type == EnumPacketServer.QuestOpenGui){
Quest quest = new Quest();
int gui = buffer.readInt();
quest.readNBT(ByteBufUtils.readNBT(buffer));
NoppesUtilServer.setEditingQuest(player,quest);
player.openGui(CustomNpcs.instance, gui , player.worldObj, 0, 0, 0);
}
else if(type == EnumPacketServer.TraderMarketSave){
String market = ByteBufUtils.readString(buffer);
if(market == null)
return;
boolean bo = buffer.readBoolean();
if(npc.roleInterface instanceof RoleTrader){
if(bo)
Market.setMarket(npc, market);
else
Market.save((RoleTrader)npc.roleInterface, market);
}
}
else if(type == EnumPacketServer.AnimationsGet){
NoppesUtilServer.sendAnimationDataAll(player);
}
else if(type == EnumPacketServer.AnimationGet){
Animation animation = (Animation) AnimationController.getInstance().get(buffer.readInt());
NBTTagCompound compound = animation.writeToNBT();
GuiDataPacket.sendGuiData(player, compound);
}
else if(type == EnumPacketServer.AnimationRemove){
AnimationController.getInstance().delete(buffer.readInt());
NoppesUtilServer.sendAnimationDataAll(player);
NBTTagCompound compound = (new Animation()).writeToNBT();
GuiDataPacket.sendGuiData(player, compound);
}
else if(type == EnumPacketServer.AnimationSave){
Animation animation = new Animation();
animation.readFromNBT(ByteBufUtils.readNBT(buffer));
AnimationController.getInstance().saveAnimation(animation);
NoppesUtilServer.sendAnimationDataAll(player);
GuiDataPacket.sendGuiData(player, animation.writeToNBT());
}
else
blockPackets(type, buffer, player);
blockPackets(type, buffer, player);
}
private void mountPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException{
if(type == EnumPacketServer.SpawnRider){
@@ -652,19 +605,6 @@ public class PacketHandlerServer{
compound.setTag("ShortTags", validTagList);
GuiDataPacket.sendGuiData(player, compound);
}
else if (type != EnumPacketServer.NpcTagsGet && type != EnumPacketServer.TagsGet) {
warn(player, "WE 2 tried todo something with the wrong tool, probably a hacker");
}
}
private void setTags(EntityNPCInterface npc, ByteBuf buffer) throws IOException {
npc.advanced.tagUUIDs.removeIf(uuid -> TagController.getInstance().getTagFromUUID(uuid) != null);
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
NBTTagList list = compound.getTagList("TagNames",8);
for (int i = 0; i < list.tagCount(); i++) {
String tagName = list.getStringTagAt(i);
npc.advanced.tagUUIDs.add(((Tag)TagController.getInstance().getTagFromName(tagName)).uuid);
}
}
private void warn(EntityPlayer player, String warning){
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileBorder;
@@ -10,27 +12,27 @@ import noppes.npcs.constants.EnumPacketServer;
public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
private TileBorder tile;
public GuiBorderBlock(int x, int y, int z) {
super();
tile = (TileBorder) player.worldObj.getTileEntity(x, y, z);
Client.sendData(EnumPacketServer.GetTileEntity, x, y, z);
PacketClient.sendClient(new TileEntityGetPacket(x, y, z));
}
public void initGui()
{
super.initGui();
this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 40, 120, 20, "Availability Options"));
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
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);
getTextField(0).setMinMaxDefault(0, 500, 6);
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 95,200,20, tile.message));
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
}
protected void actionPerformed(GuiButton guibutton) {
@@ -48,7 +50,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
return;
tile.height = getTextField(0).getInteger();
tile.message = getTextField(1).getText();
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
@@ -1,18 +1,15 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.TagController;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -33,8 +30,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
{
this.parent = guiNpcMobSpawnerAdd;
this.mobSpawnerAdd = guiNpcMobSpawnerAdd;
Client.sendData(EnumPacketServer.TagsGet);
Client.sendData(EnumPacketServer.NpcTagsGet);
PacketClient.sendClient(new TagsGetPacket());
PacketClient.sendClient(new TagsNpcGetPacket());
setBackground("menubg.png");
xSize = 305;
ySize = 220;
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.quest.QuestOpenGuiPacket;
import kamkeel.npcs.network.packets.request.quest.QuestSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
@@ -103,7 +104,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
setSubGui(new SubGuiNpcTextArea(quest.logText));
}
if(button.id == 5 && quest.id >= 0){
Client.sendData(EnumPacketServer.QuestOpenGui, EnumGuiType.QuestReward, quest.writeToNBT(new NBTTagCompound()));
PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestReward, quest.writeToNBT(new NBTTagCompound())));
}
if(button.id == 6 && quest.id >= 0){
quest.setType(EnumQuestType.values()[button.getValue()]);
@@ -111,7 +112,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
if(button.id == 7)
{
if(quest.type == EnumQuestType.Item)
Client.sendData(EnumPacketServer.QuestOpenGui, EnumGuiType.QuestItem, quest.writeToNBT(new NBTTagCompound()));
PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestItem, quest.writeToNBT(new NBTTagCompound())));
if(quest.type == EnumQuestType.Dialog)
setSubGui(new GuiNpcQuestTypeDialog(npc, quest, this));
@@ -1,15 +1,15 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -28,8 +28,8 @@ public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData,ICus
public GuiNPCTagSetup(EntityNPCInterface npc)
{
super(npc);
Client.sendData(EnumPacketServer.TagsGet);
Client.sendData(EnumPacketServer.NpcTagsGet);
PacketClient.sendClient(new TagsGetPacket());
PacketClient.sendClient(new TagsNpcGetPacket());
}
public void initGui()
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.Client;
@@ -585,7 +587,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
public void close() {
if (!this.hasSubGui()) {
if (animation != null) {
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
}
displayGuiScreen(parent);
} else {
@@ -1,5 +1,10 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
@@ -33,7 +38,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
this.setSave(save);
this.xOffset = -148 + 70;
this.yOffset = -170 + 137;
Client.sendData(EnumPacketServer.AnimationsGet);
PacketClient.sendClient(new AnimationsGetPacket());
AnimationData data = npc.display.animationData;
data.setEnabled(true);
@@ -164,7 +169,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
while(data.containsKey(name))
name += "_";
Animation animation = new Animation(-1, name);
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
}
if(button.id == 1){
if(data.containsKey(scrollAnimations.getSelected())) {
@@ -234,13 +239,13 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
if(guiCustomScroll.id == 0)
{
selected = scrollAnimations.getSelected();
Client.sendData(EnumPacketServer.AnimationGet, data.get(selected));
PacketClient.sendClient(new AnimationGetPacket(data.get(selected)));
}
}
public void save() {
if(selected != null && data.containsKey(selected) && animation != null){
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
}
}
@@ -272,7 +277,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
return;
if(id == 1) {
if(data.containsKey(scrollAnimations.getSelected())) {
Client.sendData(EnumPacketServer.AnimationRemove, data.get(selected));
PacketClient.sendClient(new AnimationRemovePacket(data.get(selected)));
scrollAnimations.clear();
animation = new Animation();
initGui();
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagRemovePacket;
import kamkeel.npcs.network.packets.request.tags.TagSavePacket;
import net.minecraft.client.gui.GuiButton;
@@ -28,7 +29,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
public GuiNPCManageTags(EntityNPCInterface npc)
{
super(npc);
Client.sendData(EnumPacketServer.TagsGet);
PacketClient.sendClient(new TagsGetPacket());
}
public void initGui()
@@ -2,6 +2,7 @@
package noppes.npcs.client.gui.roles;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.TraderMarketSavePacket;
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
@@ -87,7 +88,7 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
@Override
public void save() {
Client.sendData(EnumPacketServer.TraderMarketSave, role.marketName, false);
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, false));
PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound())));
}
@@ -96,8 +97,7 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
String name = guiNpcTextField.getText();
if(!name.equalsIgnoreCase(role.marketName)){
role.marketName = name;
Client.sendData(EnumPacketServer.TraderMarketSave, role.marketName, true);
}
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, true));
}
}
}
@@ -44,9 +44,7 @@ public enum EnumPacketServer {
FactionsGet,
FactionGet,
TagsGet,
TagGet,
NpcTagsGet,
QuestCategoriesGet,
QuestRemove(CustomNpcsPermissions.GLOBAL_QUEST),
QuestRewardSave(CustomNpcsPermissions.GLOBAL_QUEST),
@@ -56,10 +54,7 @@ public enum EnumPacketServer {
SpawnRider(CustomNpcsPermissions.TOOL_MOUNTER),
MovingPathSave(CustomNpcsPermissions.TOOL_PATHER,true), MovingPathGet(true),
AnimationsGet, AnimationGet,
AnimationRemove(CustomNpcsPermissions.GLOBAL_ANIMATION), AnimationSave(CustomNpcsPermissions.GLOBAL_ANIMATION),
QuestOpenGui, QuestLogToServer, PartyLogToServer, UntrackQuest,
QuestLogToServer, PartyLogToServer, UntrackQuest,
QuestGet,
SaveTileEntity,