mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 22:45:09 +00:00
Continue to replace Client Packet Handler with PacketHandler
This commit is contained in:
1 parent
e8c3fc4d0a
commit
a1f10db0de
18 files changed
+160
-154
No files matched your search
+23
-8
@@ -7,24 +7,35 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.player.GuiBook;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class OpenBookPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|OpenBook";
|
||||
public final class GuiOpenBookPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|GuiOpenBook";
|
||||
|
||||
public OpenBookPacket() {}
|
||||
private int i;
|
||||
private int j;
|
||||
private int k;
|
||||
private NBTTagCompound nbtTagCompound;
|
||||
|
||||
public GuiOpenBookPacket() {}
|
||||
|
||||
public GuiOpenBookPacket(int i, int j, int k, NBTTagCompound nbtTagCompound) {
|
||||
this.i = i;
|
||||
this.j = j;
|
||||
this.k = k;
|
||||
this.nbtTagCompound = nbtTagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.OPEN_BOOK;
|
||||
return EnumClientPacket.GUI_BOOK;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +45,11 @@ public final class OpenBookPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
out.writeInt(this.i);
|
||||
out.writeInt(this.j);
|
||||
out.writeInt(this.k);
|
||||
|
||||
ByteBufUtils.writeNBT(out, this.nbtTagCompound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -43,7 +58,7 @@ public final class OpenBookPacket extends AbstractPacket {
|
||||
int x = in.readInt();
|
||||
int y = in.readInt();
|
||||
int z = in.readInt();
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(nbt);
|
||||
NoppesUtil.openGUI(player, new GuiBook(player, book, x, y, z));
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public final class GuiOpenPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.GUI;
|
||||
return EnumClientPacket.GUI_OPEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -18,8 +19,14 @@ import java.io.IOException;
|
||||
public final class GuiRedstonePacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|GuiRedstone";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public GuiRedstonePacket() {}
|
||||
|
||||
public GuiRedstonePacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.GUI_REDSTONE;
|
||||
@@ -32,13 +39,13 @@ public final class GuiRedstonePacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
NoppesUtil.saveRedstoneBlock(player, nbt);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public final class GuiTeleporterPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.TELEPORTER;
|
||||
return EnumClientPacket.GUI_TELEPORTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -18,8 +19,14 @@ import java.io.IOException;
|
||||
public final class GuiWaypointPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|GuiWaypoint";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public GuiWaypointPacket() {}
|
||||
|
||||
public GuiWaypointPacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.GUI_WAYPOINT;
|
||||
@@ -32,13 +39,13 @@ public final class GuiWaypointPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
NoppesUtil.saveWayPointBlock(player, nbt);
|
||||
}
|
||||
}
|
||||
+23
-12
@@ -1,35 +1,35 @@
|
||||
package kamkeel.npcs.network.packets.client.gui;
|
||||
package kamkeel.npcs.network.packets.client.large;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import kamkeel.npcs.network.LargeAbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class GuiClonerPacket extends AbstractPacket {
|
||||
public final class LargeClonerPacket extends LargeAbstractPacket {
|
||||
public static final String packetName = "Client|Clone";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public GuiClonerPacket() {}
|
||||
public LargeClonerPacket() {}
|
||||
|
||||
public GuiClonerPacket(NBTTagCompound comp){
|
||||
public LargeClonerPacket(NBTTagCompound comp){
|
||||
this.compound = comp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.CLONE;
|
||||
return EnumClientPacket.CLONE_NPC;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,15 +37,26 @@ public final class GuiClonerPacket extends AbstractPacket {
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeNBT(out, compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(nbt));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getData() throws IOException {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
ByteBufUtils.writeBigNBT(buffer, compound);
|
||||
byte[] bytes = new byte[buffer.readableBytes()];
|
||||
buffer.readBytes(bytes);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
protected void handleCompleteData(ByteBuf data, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = ByteBufUtils.readBigNBT(data);
|
||||
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(nbt));
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public final class LargeGuiDataPacket extends LargeAbstractPacket {
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.LARGE_PACKET;
|
||||
return PacketHandler.CLIENT_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -422,7 +422,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
QuestLogData data = new QuestLogData();
|
||||
data.setData(player);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
|
||||
PacketUtil.sendGuiData(player, data.writeNBT());
|
||||
}
|
||||
|
||||
public static void sendTrackedQuest(EntityPlayerMP player) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -147,20 +148,20 @@ public class PacketHandlerPlayer{
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.extendFollower(player, npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerState){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.changeFollowerState(player,npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.RoleGet){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.Transport){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
@@ -212,11 +213,11 @@ public class PacketHandlerPlayer{
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FactionsGet){
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData());
|
||||
PacketUtil.sendGuiData(player, data.getPlayerGuiData());
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailGet){
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailDelete){
|
||||
long time = buffer.readLong();
|
||||
@@ -230,7 +231,7 @@ public class PacketHandlerPlayer{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailSend){
|
||||
if(!(player.openContainer instanceof ContainerMail))
|
||||
|
||||
@@ -116,7 +116,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
compound.setTag("TagNames",tagList);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
} else if (type == EnumPacketServer.CacheAnimation) {
|
||||
PlayerDataController.Instance.getPlayerData(player).animationData.cacheAnimation(buffer.readInt());
|
||||
return;
|
||||
@@ -372,7 +372,7 @@ public class PacketHandlerServer{
|
||||
compound.setBoolean("PlayerScriptsEnabled", ConfigScript.GlobalPlayerScripts);
|
||||
compound.setBoolean("GlobalNPCScriptsEnabled", ConfigScript.GlobalNPCScripts);
|
||||
compound.setBoolean("ForgeScriptsEnabled", ConfigScript.GlobalForgeScripts);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataSave) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
@@ -395,7 +395,7 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.ScriptDataGet){
|
||||
NBTTagCompound compound = npc.script.writeToNBT(new NBTTagCompound());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ public class PacketHandlerServer{
|
||||
compound.setString("ScriptLanguage", data.getLanguage());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
compound.setTag("ScriptConsole", NBTTags.NBTLongStringMap(data.getConsoleText()));
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
List<ScriptContainer> containers = data.getScripts();
|
||||
for (int i = 0; i < containers.size(); i++) {
|
||||
ScriptContainer container = containers.get(i);
|
||||
@@ -413,7 +413,7 @@ public class PacketHandlerServer{
|
||||
tabCompound.setInteger("Tab",i);
|
||||
tabCompound.setTag("Script",container.writeToNBT(new NBTTagCompound()));
|
||||
tabCompound.setInteger("TotalScripts",containers.size());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, tabCompound);
|
||||
PacketUtil.sendGuiData(player, tabCompound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ public class PacketHandlerServer{
|
||||
iw.loadScriptData();
|
||||
NBTTagCompound compound = iw.getMCNbt();
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
} else if (type == EnumPacketServer.ScriptItemDataSave) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
return;
|
||||
@@ -530,7 +530,7 @@ public class PacketHandlerServer{
|
||||
return;
|
||||
NBTTagCompound compound = ((TileScripted) tile).getNBT(new NBTTagCompound());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
} else if (type == EnumPacketServer.ScriptBlockDataSave) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ public class PacketHandlerServer{
|
||||
|
||||
private void movingPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException {
|
||||
if(type == EnumPacketServer.MovingPathGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MovingPathSave){
|
||||
npc.ai.setMovingPath(NBTTags.getIntegerArraySet(Server.readNBT(buffer).getTagList("MovingPathNew",10)));
|
||||
@@ -582,7 +582,7 @@ public class PacketHandlerServer{
|
||||
TileEntity tile = player.worldObj.getTileEntity(buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoriesGet){
|
||||
PacketUtil.sendScrollData(player, DialogController.Instance.getScroll());
|
||||
@@ -632,7 +632,7 @@ public class PacketHandlerServer{
|
||||
Quest quest = QuestController.Instance.quests.get(dialog.quest);
|
||||
if(quest != null)
|
||||
compound.setString("DialogQuestName", quest.title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestGet){
|
||||
@@ -641,20 +641,20 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest.hasNewQuest())
|
||||
compound.setString("NextQuestTitle", quest.getNextQuest().title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, quest.writeToNBT(compound));
|
||||
PacketUtil.sendGuiData(player, quest.writeToNBT(compound));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Faction faction = FactionController.getInstance().get(buffer.readInt());
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.TagGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Tag tag = TagController.getInstance().get(buffer.readInt());
|
||||
tag.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.NaturalSpawnGet){
|
||||
SpawnData spawn = SpawnController.Instance.getSpawnData(buffer.readInt());
|
||||
if(spawn != null){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, spawn.writeNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, spawn.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnSave){
|
||||
@@ -832,7 +832,7 @@ public class PacketHandlerServer{
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, comp);
|
||||
PacketUtil.sendGuiData(player, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogSave){
|
||||
@@ -881,7 +881,7 @@ public class PacketHandlerServer{
|
||||
if(option != null && option.hasDialog()){
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", slot);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcRemove){
|
||||
@@ -892,7 +892,7 @@ public class PacketHandlerServer{
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, comp);
|
||||
PacketUtil.sendGuiData(player, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategorySave){
|
||||
@@ -931,7 +931,7 @@ public class PacketHandlerServer{
|
||||
compound.setString("2", quest2.title);
|
||||
if(quest3 != null)
|
||||
compound.setString("3", quest3.title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestRemove){
|
||||
Quest quest = QuestController.Instance.quests.get(buffer.readInt());
|
||||
@@ -980,7 +980,7 @@ public class PacketHandlerServer{
|
||||
return;
|
||||
RoleTransporter role = (RoleTransporter) npc.roleInterface;
|
||||
if(role.hasTransport()){
|
||||
Server.sendData(player,EnumPacketClient.GUI_DATA,role.getLocation().writeNBT());
|
||||
PacketUtil.sendGuiData(player, role.getLocation().writeNBT());
|
||||
PacketUtil.setSelectedList(player, role.getLocation().category.title);
|
||||
}
|
||||
}
|
||||
@@ -994,14 +994,14 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionRemove){
|
||||
FactionController.getInstance().delete(buffer.readInt());
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
(new Faction()).writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.TagSet){
|
||||
this.setTags(npc,buffer);
|
||||
@@ -1013,14 +1013,14 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.sendTagDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tag.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.TagRemove){
|
||||
TagController.getInstance().delete(buffer.readInt());
|
||||
NoppesUtilServer.sendTagDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
(new Tag()).writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerDataGet){
|
||||
int id = buffer.readInt();
|
||||
@@ -1039,21 +1039,21 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.regenPlayerData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.display.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplaySave){
|
||||
npc.display.readToNBT(Server.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuStatsGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.stats.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.stats.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuStatsSave){
|
||||
npc.stats.readToNBT(Server.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuInvGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuInvSave){
|
||||
npc.inventory.readEntityFromNBT(Server.readNBT(buffer));
|
||||
@@ -1061,7 +1061,7 @@ public class PacketHandlerServer{
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAIGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAISave){
|
||||
npc.ai.readToNBT(Server.readNBT(buffer));
|
||||
@@ -1070,7 +1070,7 @@ public class PacketHandlerServer{
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAdvancedGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAdvancedSave){
|
||||
npc.advanced.readToNBT(Server.readNBT(buffer));
|
||||
@@ -1101,10 +1101,10 @@ public class PacketHandlerServer{
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
((JobSpawner)npc.jobInterface).cleanCompound(compound);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, ((JobSpawner)npc.jobInterface).getTitles());
|
||||
PacketUtil.sendGuiData(player, ((JobSpawner)npc.jobInterface).getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSpawnerAdd){
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
@@ -1118,7 +1118,7 @@ public class PacketHandlerServer{
|
||||
else{
|
||||
job.setJobCompound(buffer.readInt(), Server.readNBT(buffer));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, job.getTitles());
|
||||
PacketUtil.sendGuiData(player, job.getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleCompanionUpdate){
|
||||
if(npc.advanced.role != EnumRoleType.Companion)
|
||||
@@ -1131,7 +1131,7 @@ public class PacketHandlerServer{
|
||||
return;
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
job.setJobCompound(buffer.readInt(), null);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, job.getTitles());
|
||||
PacketUtil.sendGuiData(player, job.getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleSave){
|
||||
npc.roleInterface.readFromNBT(Server.readNBT(buffer));
|
||||
@@ -1142,7 +1142,7 @@ public class PacketHandlerServer{
|
||||
return;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("RoleData", true);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(compound));
|
||||
PacketUtil.sendGuiData(player, npc.roleInterface.writeToNBT(compound));
|
||||
}
|
||||
else if(type == EnumPacketServer.MerchantUpdate){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
@@ -1168,7 +1168,7 @@ public class PacketHandlerServer{
|
||||
npc.updateAI = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.TransformGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.transform.writeOptions(new NBTTagCompound()));
|
||||
PacketUtil.sendGuiData(player, npc.transform.writeOptions(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.TransformLoad){
|
||||
if(npc.transform.isValid())
|
||||
@@ -1192,20 +1192,20 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.AnimationGet){
|
||||
Animation animation = (Animation) AnimationController.getInstance().get(buffer.readInt());
|
||||
NBTTagCompound compound = animation.writeToNBT();
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.AnimationRemove){
|
||||
AnimationController.getInstance().delete(buffer.readInt());
|
||||
NoppesUtilServer.sendAnimationDataAll(player);
|
||||
NBTTagCompound compound = (new Animation()).writeToNBT();
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.AnimationSave){
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(Server.readNBT(buffer));
|
||||
AnimationController.getInstance().saveAnimation(animation);
|
||||
NoppesUtilServer.sendAnimationDataAll(player);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, animation.writeToNBT());
|
||||
PacketUtil.sendGuiData(player, animation.writeToNBT());
|
||||
}
|
||||
else
|
||||
blockPackets(type, buffer, player);
|
||||
@@ -1234,7 +1234,7 @@ public class PacketHandlerServer{
|
||||
compound.setTag("List", list);
|
||||
compound.setTag("ListDate", listDate);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else
|
||||
warn(player,"WE 1 tried todo something with the wrong tool, probably a hacker");
|
||||
@@ -1290,7 +1290,7 @@ public class PacketHandlerServer{
|
||||
boolean bo = ServerCloneController.Instance.getCloneData(null, Server.readString(buffer), buffer.readInt()) != null;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("NameExists", bo);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneSave){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
@@ -1322,7 +1322,7 @@ public class PacketHandlerServer{
|
||||
compound.setTag("List", list);
|
||||
compound.setTag("ListDate", listDate);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneList){
|
||||
NBTTagList list = new NBTTagList();
|
||||
@@ -1338,14 +1338,14 @@ public class PacketHandlerServer{
|
||||
compound.setTag("List", list);
|
||||
compound.setTag("ListDate", listDate);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.CloneTagList) {
|
||||
int tab = buffer.readInt();
|
||||
TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("CloneTags", tagMap.writeNBT());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.CloneAllTags) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
@@ -1357,7 +1357,7 @@ public class PacketHandlerServer{
|
||||
validTagList.appendTag(tagCompound);
|
||||
}
|
||||
compound.setTag("AllTags", validTagList);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.CloneAllTagsShort) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
@@ -1369,7 +1369,7 @@ public class PacketHandlerServer{
|
||||
validTagList.appendTag(tagCompound);
|
||||
}
|
||||
compound.setTag("ShortTags", validTagList);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
PacketUtil.sendGuiData(player, compound);
|
||||
}
|
||||
else if (type == EnumPacketServer.TagSet) {
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
|
||||
@@ -10,6 +10,8 @@ import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.enums.EnumSyncAction;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import kamkeel.npcs.network.packets.client.SoundManagementPacket;
|
||||
import kamkeel.npcs.network.packets.client.VillagerListPacket;
|
||||
import kamkeel.npcs.network.packets.client.large.LargeClonerPacket;
|
||||
import kamkeel.npcs.network.packets.client.large.LargeSyncPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -98,8 +100,7 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
PacketHandler.Instance.sendToPlayer(new LargeClonerPacket(compound), (EntityPlayerMP)event.entityPlayer);
|
||||
data.cloned = compound;
|
||||
if (event.target instanceof EntityNPCInterface) {
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
|
||||
@@ -137,7 +138,7 @@ public class ServerEventsHandler {
|
||||
|
||||
if (merchantrecipelist != null)
|
||||
{
|
||||
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
||||
PacketHandler.Instance.sendToPlayer(new VillagerListPacket(merchantrecipelist), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.client.gui.GuiRedstonePacket;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -32,8 +34,8 @@ public class BlockNpcRedstone extends BlockContainer{
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_REDSTONE, compound);
|
||||
return true;
|
||||
PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP)player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.client.gui.GuiWaypointPacket;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -34,7 +36,7 @@ public class BlockWaypoint extends BlockContainer{
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_WAYPOINT, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new GuiWaypointPacket(compound), (EntityPlayerMP)player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -48,42 +48,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
data.setNBT(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_REDSTONE){
|
||||
NoppesUtil.saveRedstoneBlock(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_WAYPOINT){
|
||||
NoppesUtil.saveWayPointBlock(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.CLONE){
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(compound));
|
||||
}
|
||||
else if(type == EnumPacketClient.TELEPORTER){
|
||||
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_DATA){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
return;
|
||||
|
||||
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
|
||||
}
|
||||
else if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
|
||||
}
|
||||
if(gui instanceof IGuiData)
|
||||
((IGuiData)gui).setGuiData(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.VILLAGER_LIST){
|
||||
MerchantRecipeList merchantrecipelist = MerchantRecipeList.func_151390_b(new PacketBuffer(buffer));
|
||||
ServerEventsHandler.Merchant.setRecipes(merchantrecipelist);
|
||||
}
|
||||
else if(type == EnumPacketClient.OPEN_BOOK){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
|
||||
NoppesUtil.openGUI(player, new GuiBook(player, ItemStack.loadItemStackFromNBT(Server.readNBT(buffer)), x, y, z));
|
||||
}
|
||||
else if(type == EnumPacketClient.ISGUIOPEN){
|
||||
boolean isGUIOpen = Minecraft.getMinecraft().currentScreen != null;
|
||||
|
||||
|
||||
@@ -2,13 +2,6 @@ package
|
||||
noppes.npcs.constants;
|
||||
|
||||
public enum EnumPacketClient {
|
||||
GUI_REDSTONE,
|
||||
GUI_WAYPOINT,
|
||||
GUI_DATA,
|
||||
VILLAGER_LIST,
|
||||
CLONE,
|
||||
TELEPORTER,
|
||||
OPEN_BOOK,
|
||||
ISGUIOPEN,
|
||||
SCRIPT_OVERLAY_DATA,
|
||||
SCRIPT_OVERLAY_CLOSE,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -27,13 +28,13 @@ public class CustomGuiController {
|
||||
EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getMCEntity();
|
||||
entityPlayerMP.openGui(CustomNpcs.instance, EnumGuiType.CustomGui.ordinal(), player.getWorld().getMCWorld(), gui.getSlots().size(), 0, 0);
|
||||
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
PacketUtil.sendGuiData((EntityPlayerMP)player.getMCEntity(), gui.toNBT());
|
||||
}
|
||||
|
||||
public static boolean updateGui(IPlayer player, ScriptGui gui) {
|
||||
if (((EntityPlayerMP)player.getMCEntity()).openContainer instanceof ContainerCustomGui) {
|
||||
((ContainerCustomGui)((EntityPlayerMP)player.getMCEntity()).openContainer).setGui(gui, (EntityPlayer)player.getMCEntity());
|
||||
Server.sendDataChecked((EntityPlayerMP)player.getMCEntity(), EnumPacketClient.GUI_DATA, new Object[]{gui.toNBT()});
|
||||
PacketUtil.sendGuiData((EntityPlayerMP)player.getMCEntity(), gui.toNBT());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -108,7 +109,8 @@ public class BankData {
|
||||
if (container != null)
|
||||
container.setCurrency(item);
|
||||
}
|
||||
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
PacketUtil.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
private ContainerNPCBankInterface getContainer(EntityPlayer player){
|
||||
Container con = player.openContainer;
|
||||
|
||||
@@ -18,13 +18,13 @@ public class DataTransform {
|
||||
public NBTTagCompound stats;
|
||||
public NBTTagCompound role;
|
||||
public NBTTagCompound job;
|
||||
|
||||
|
||||
public boolean hasDisplay, hasAi, hasAdvanced, hasInv, hasStats, hasRole, hasJob, isActive;
|
||||
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
|
||||
public boolean editingModus = false;
|
||||
|
||||
|
||||
public DataTransform(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
@@ -47,11 +47,11 @@ public class DataTransform {
|
||||
compound.setTag("TransformRole", role);
|
||||
if(hasJob)
|
||||
compound.setTag("TransformJob", job);
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public Object writeOptions(NBTTagCompound compound) {
|
||||
|
||||
public NBTTagCompound writeOptions(NBTTagCompound compound) {
|
||||
compound.setBoolean("TransformHasDisplay", hasDisplay);
|
||||
compound.setBoolean("TransformHasAI", hasAi);
|
||||
compound.setBoolean("TransformHasAdvanced", hasAdvanced);
|
||||
@@ -62,7 +62,7 @@ public class DataTransform {
|
||||
compound.setBoolean("TransformEditingModus", editingModus);
|
||||
return compound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void readToNBT(NBTTagCompound compound) {
|
||||
isActive = compound.getBoolean("TransformIsActive");
|
||||
@@ -75,7 +75,7 @@ public class DataTransform {
|
||||
job = hasJob?compound.getCompoundTag("TransformJob"): getJob();
|
||||
role = hasRole?compound.getCompoundTag("TransformRole"): getRole();
|
||||
}
|
||||
|
||||
|
||||
public NBTTagCompound getJob() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
@@ -83,17 +83,17 @@ public class DataTransform {
|
||||
if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null) {
|
||||
npc.jobInterface.writeToNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
public NBTTagCompound getRole() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
compound.setInteger("Role", npc.advanced.role.ordinal());
|
||||
compound.setInteger("Role", npc.advanced.role.ordinal());
|
||||
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null) {
|
||||
npc.roleInterface.writeToNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DataTransform {
|
||||
if(npc instanceof EntityCustomNpc){
|
||||
compound.setTag("ModelData", ((EntityCustomNpc)npc).modelData.writeToNBT());
|
||||
}
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class DataTransform {
|
||||
|
||||
npc.advanced.job = jopType;
|
||||
npc.advanced.role = roleType;
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class DataTransform {
|
||||
boolean hadStats = hasStats;
|
||||
boolean hadRole = hasRole;
|
||||
boolean hadJob = hasJob;
|
||||
|
||||
|
||||
hasDisplay = compound.getBoolean("TransformHasDisplay");
|
||||
hasAi = compound.getBoolean("TransformHasAI");
|
||||
hasAdvanced = compound.getBoolean("TransformHasAdvanced");
|
||||
@@ -158,7 +158,7 @@ public class DataTransform {
|
||||
if(hasRole && !hadRole)
|
||||
role = getRole();
|
||||
}
|
||||
|
||||
|
||||
public boolean isValid(){
|
||||
return hasAdvanced || hasAi || hasDisplay || hasInv || hasStats || hasJob || hasRole;
|
||||
}
|
||||
@@ -166,14 +166,14 @@ public class DataTransform {
|
||||
|
||||
public NBTTagCompound processAdvanced(NBTTagCompound compoundAdv,
|
||||
NBTTagCompound compoundRole, NBTTagCompound compoundJob) {
|
||||
|
||||
|
||||
if(hasAdvanced)
|
||||
compoundAdv = advanced;
|
||||
if(hasRole)
|
||||
compoundRole = role;
|
||||
if(hasJob)
|
||||
compoundJob = job;
|
||||
|
||||
|
||||
Set<String> names = compoundRole.func_150296_c();
|
||||
for(String name : names)
|
||||
compoundAdv.setTag(name, compoundRole.getTag(name));
|
||||
@@ -181,10 +181,10 @@ public class DataTransform {
|
||||
names = compoundJob.func_150296_c();
|
||||
for(String name : names)
|
||||
compoundAdv.setTag(name, compoundJob.getTag(name));
|
||||
|
||||
|
||||
return compoundAdv;
|
||||
}
|
||||
|
||||
|
||||
public void transform(boolean isActive){
|
||||
if(this.isActive == isActive)
|
||||
return;
|
||||
@@ -205,14 +205,14 @@ public class DataTransform {
|
||||
NBTTagCompound compoundAdv = getAdvanced();
|
||||
NBTTagCompound compoundRole = getRole();
|
||||
NBTTagCompound compoundJob = getJob();
|
||||
|
||||
|
||||
NBTTagCompound compound = processAdvanced(compoundAdv, compoundRole, compoundJob);
|
||||
npc.advanced.readToNBT(compound);
|
||||
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null)
|
||||
if (npc.advanced.role != EnumRoleType.None && npc.roleInterface != null)
|
||||
npc.roleInterface.readFromNBT(NBTTags.NBTMerge(compoundRole, compound));
|
||||
if (npc.advanced.job != EnumJobType.None && npc.jobInterface != null)
|
||||
npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound));
|
||||
|
||||
npc.jobInterface.readFromNBT(NBTTags.NBTMerge(compoundJob, compound));
|
||||
|
||||
if(hasAdvanced)
|
||||
advanced = compoundAdv;
|
||||
if(hasRole)
|
||||
|
||||
Reference in new issue
Block a user