mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 19:42:19 +00:00
Merge branch 'cloner_tabs' into dev
This commit is contained in:
commit
db7ae16ee9
35 files changed
+3311
-318
No files matched your search
@@ -13,6 +13,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.CloneFolder;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,20 +36,24 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
usage = "<npc> <tab|folder> [clonedname]",
|
||||
permission = 4
|
||||
)
|
||||
public void add(ICommandSender sender, String[] args) {
|
||||
int tab = 0;
|
||||
int tab = -1;
|
||||
String folder = null;
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
if (tab < 1 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
folder = args[1];
|
||||
if (ServerCloneController.Instance == null || !ServerCloneController.Instance.hasFolder(folder)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", folder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int x = sender.getPlayerCoordinates().posX;
|
||||
@@ -64,32 +69,47 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if (!npc.writeToNBTOptional(compound))
|
||||
return;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
|
||||
if (folder != null) {
|
||||
ServerCloneController.Instance.addClone(compound, name, folder);
|
||||
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Folder \u00A7b%s\u00A77", name, folder));
|
||||
} else {
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
sendResult(sender, String.format("Added NPC \u00A7e%s\u00A77 to Tab \u00A7b%d\u00A77", name, tab));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "List NPC from clone storage",
|
||||
usage = "<tab>",
|
||||
usage = "<tab|folder>",
|
||||
permission = 2
|
||||
)
|
||||
public void list(ICommandSender sender, String[] args) {
|
||||
sendMessage(sender, "--- Stored NPCs --- (server side)");
|
||||
int tab = 0;
|
||||
int tab = -1;
|
||||
String folder = null;
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
if (tab < 1 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
folder = args[1];
|
||||
if (ServerCloneController.Instance == null || !ServerCloneController.Instance.hasFolder(folder)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", folder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
List<String> clones;
|
||||
if (folder != null) {
|
||||
clones = ServerCloneController.Instance.getClones(folder);
|
||||
} else {
|
||||
clones = ServerCloneController.Instance.getClones(tab);
|
||||
}
|
||||
for (String name : clones) {
|
||||
sendMessage(sender, name);
|
||||
}
|
||||
sendMessage(sender, "------------------------------------");
|
||||
@@ -97,59 +117,75 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
|
||||
@SubCommand(
|
||||
desc = "Remove NPC from clone storage",
|
||||
usage = "<name> <tab>",
|
||||
usage = "<name> <tab|folder>",
|
||||
permission = 4
|
||||
)
|
||||
public void del(ICommandSender sender, String[] args) throws CommandException {
|
||||
String nametodel = args[0];
|
||||
int tab = 0;
|
||||
int tab = -1;
|
||||
String folder = null;
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
if (tab < 1 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean deleted = false;
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
if (nametodel.equalsIgnoreCase(name)) {
|
||||
ServerCloneController.Instance.removeClone(name, tab);
|
||||
deleted = true;
|
||||
break;
|
||||
folder = args[1];
|
||||
if (ServerCloneController.Instance == null || !ServerCloneController.Instance.hasFolder(folder)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", folder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
||||
|
||||
boolean success;
|
||||
if (folder != null) {
|
||||
success = ServerCloneController.Instance.removeClone(nametodel, folder);
|
||||
} else {
|
||||
success = ServerCloneController.Instance.removeClone(nametodel, tab);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
sendError(sender, String.format("NPC '%s' was not found", nametodel));
|
||||
} else {
|
||||
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Tab \u00A7b%d\u00A77", nametodel, tab));
|
||||
if (folder != null) {
|
||||
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Folder \u00A7b%s\u00A77", nametodel, folder));
|
||||
} else {
|
||||
sendResult(sender, String.format("Removed NPC \u00A7e%s\u00A77 from Tab \u00A7b%d\u00A77", nametodel, tab));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
usage = "<name> <tab|folder> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
)
|
||||
public void spawn(ICommandSender sender, String[] args) throws CommandException {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
int tab = -1;
|
||||
String folder = null;
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
if (tab < 1 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
folder = args[1];
|
||||
if (ServerCloneController.Instance == null || !ServerCloneController.Instance.hasFolder(folder)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", folder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
NBTTagCompound compound;
|
||||
if (folder != null) {
|
||||
compound = ServerCloneController.Instance.getCloneData(sender, name, folder);
|
||||
} else {
|
||||
compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
}
|
||||
if (compound == null) {
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
@@ -211,22 +247,26 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
desc = "Spawn cloned NPC in a grid",
|
||||
usage = "<name> <tab|folder> <width> <height> [[world:]x,y,z]] [newname]",
|
||||
permission = 2
|
||||
)
|
||||
public void grid(ICommandSender sender, String[] args) throws CommandException {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
int tab = -1;
|
||||
String folder = null;
|
||||
try {
|
||||
tab = Integer.parseInt(args[1]);
|
||||
if (tab < 0 || tab > 15) {
|
||||
sendError(sender, String.format("Tab must be within 1-15"));
|
||||
if (tab < 1 || tab > 15) {
|
||||
sendError(sender, "Tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
sendError(sender, String.format("Tab is not a number: %s", args[1]));
|
||||
return;
|
||||
folder = args[1];
|
||||
if (ServerCloneController.Instance == null || !ServerCloneController.Instance.hasFolder(folder)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", folder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int width, height;
|
||||
@@ -238,9 +278,13 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String newname = null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
NBTTagCompound compound;
|
||||
if (folder != null) {
|
||||
compound = ServerCloneController.Instance.getCloneData(sender, name, folder);
|
||||
} else {
|
||||
compound = ServerCloneController.Instance.getCloneData(sender, name, tab);
|
||||
}
|
||||
if (compound == null) {
|
||||
sendError(sender, "Unknown npc");
|
||||
return;
|
||||
@@ -317,6 +361,163 @@ public class CloneCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "List all custom clone folders",
|
||||
usage = "",
|
||||
permission = 2
|
||||
)
|
||||
public void listfolders(ICommandSender sender, String[] args) {
|
||||
if (ServerCloneController.Instance == null) {
|
||||
sendError(sender, "Folder system not initialized");
|
||||
return;
|
||||
}
|
||||
sendMessage(sender, "--- Clone Folders ---");
|
||||
for (CloneFolder f : ServerCloneController.Instance.getFolderList()) {
|
||||
sendMessage(sender, f.name);
|
||||
}
|
||||
sendMessage(sender, "------------------------------------");
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Create a custom clone folder",
|
||||
usage = "<name>",
|
||||
permission = 4
|
||||
)
|
||||
public void createfolder(ICommandSender sender, String[] args) {
|
||||
if (ServerCloneController.Instance == null) {
|
||||
sendError(sender, "Folder system not initialized");
|
||||
return;
|
||||
}
|
||||
String name = args[0];
|
||||
if (!CloneFolder.isValidName(name)) {
|
||||
sendError(sender, String.format("Invalid folder name: %s", name));
|
||||
return;
|
||||
}
|
||||
if (ServerCloneController.Instance.hasFolder(name)) {
|
||||
sendError(sender, String.format("Folder '%s' already exists", name));
|
||||
return;
|
||||
}
|
||||
CloneFolder created = ServerCloneController.Instance.createFolder(name);
|
||||
if (created != null) {
|
||||
sendResult(sender, String.format("Created folder \u00A7b%s", name));
|
||||
} else {
|
||||
sendError(sender, String.format("Failed to create folder '%s'", name));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Rename a custom clone folder",
|
||||
usage = "<oldname> <newname>",
|
||||
permission = 4
|
||||
)
|
||||
public void renamefolder(ICommandSender sender, String[] args) {
|
||||
if (ServerCloneController.Instance == null) {
|
||||
sendError(sender, "Folder system not initialized");
|
||||
return;
|
||||
}
|
||||
String oldName = args[0];
|
||||
String newName = args[1];
|
||||
if (!ServerCloneController.Instance.hasFolder(oldName)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", oldName));
|
||||
return;
|
||||
}
|
||||
if (!CloneFolder.isValidName(newName)) {
|
||||
sendError(sender, String.format("Invalid folder name: %s", newName));
|
||||
return;
|
||||
}
|
||||
if (ServerCloneController.Instance.renameFolder(oldName, newName)) {
|
||||
sendResult(sender, String.format("Renamed folder \u00A7b%s\u00A77 to \u00A7b%s", oldName, newName));
|
||||
} else {
|
||||
sendError(sender, String.format("Failed to rename folder '%s'", oldName));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Delete an empty custom clone folder",
|
||||
usage = "<name>",
|
||||
permission = 4
|
||||
)
|
||||
public void deletefolder(ICommandSender sender, String[] args) {
|
||||
if (ServerCloneController.Instance == null) {
|
||||
sendError(sender, "Folder system not initialized");
|
||||
return;
|
||||
}
|
||||
String name = args[0];
|
||||
if (!ServerCloneController.Instance.hasFolder(name)) {
|
||||
sendError(sender, String.format("Unknown folder: %s", name));
|
||||
return;
|
||||
}
|
||||
if (ServerCloneController.Instance.deleteFolder(name)) {
|
||||
sendResult(sender, String.format("Deleted folder \u00A7b%s", name));
|
||||
} else {
|
||||
sendError(sender, String.format("Failed to delete folder '%s' (folder must be empty)", name));
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Move a clone between tabs/folders",
|
||||
usage = "<clonename> <from_tab|folder> <to_tab|folder>",
|
||||
permission = 4
|
||||
)
|
||||
public void move(ICommandSender sender, String[] args) {
|
||||
if (ServerCloneController.Instance == null) {
|
||||
sendError(sender, "Folder system not initialized");
|
||||
return;
|
||||
}
|
||||
String cloneName = args[0];
|
||||
|
||||
int fromTab = -1;
|
||||
String fromFolder = null;
|
||||
try {
|
||||
fromTab = Integer.parseInt(args[1]);
|
||||
if (fromTab < 1 || fromTab > 15) {
|
||||
sendError(sender, "Source tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
fromFolder = args[1];
|
||||
if (!ServerCloneController.Instance.hasFolder(fromFolder)) {
|
||||
sendError(sender, String.format("Unknown source folder: %s", fromFolder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int toTab = -1;
|
||||
String toFolder = null;
|
||||
try {
|
||||
toTab = Integer.parseInt(args[2]);
|
||||
if (toTab < 1 || toTab > 15) {
|
||||
sendError(sender, "Destination tab must be within 1-15");
|
||||
return;
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
toFolder = args[2];
|
||||
if (!ServerCloneController.Instance.hasFolder(toFolder)) {
|
||||
sendError(sender, String.format("Unknown destination folder: %s", toFolder));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean success;
|
||||
if (fromFolder != null && toFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromFolder, toFolder);
|
||||
} else if (fromFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromFolder, toTab);
|
||||
} else if (toFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromTab, toFolder);
|
||||
} else {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromTab, toTab);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
String from = fromFolder != null ? fromFolder : String.valueOf(fromTab);
|
||||
String to = toFolder != null ? toFolder : String.valueOf(toTab);
|
||||
sendResult(sender, String.format("Moved \u00A7e%s\u00A77 from \u00A7b%s\u00A77 to \u00A7b%s", cloneName, from, to));
|
||||
} else {
|
||||
sendError(sender, String.format("Failed to move '%s'", cloneName));
|
||||
}
|
||||
}
|
||||
|
||||
public World getWorld(String t) {
|
||||
WorldServer[] ws = MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w : ws) {
|
||||
|
||||
@@ -108,6 +108,9 @@ import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BanksGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneAllTagsPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneAllTagsShortPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneFolderCrudPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneFolderListPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneMovePacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneListPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.ClonePreSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneRemovePacket;
|
||||
@@ -325,6 +328,9 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new CloneTagListPacket());
|
||||
REQUEST_PACKET.registerPacket(new CloneAllTagsPacket());
|
||||
REQUEST_PACKET.registerPacket(new CloneAllTagsShortPacket());
|
||||
REQUEST_PACKET.registerPacket(new CloneFolderListPacket());
|
||||
REQUEST_PACKET.registerPacket(new CloneFolderCrudPacket());
|
||||
REQUEST_PACKET.registerPacket(new CloneMovePacket());
|
||||
|
||||
|
||||
// Linked Packets
|
||||
|
||||
@@ -163,6 +163,9 @@ public enum EnumRequestPacket {
|
||||
CloneAllTags,
|
||||
CloneAllTagsShort,
|
||||
ClonePreSave,
|
||||
CloneFolderList,
|
||||
CloneFolderCrud,
|
||||
CloneMove,
|
||||
|
||||
EventScript,
|
||||
PlayerScript,
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package kamkeel.npcs.network.packets.request.clone;
|
||||
|
||||
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.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.CloneFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class CloneFolderCrudPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneFolderCrud";
|
||||
|
||||
public static final byte ACTION_CREATE = 0;
|
||||
public static final byte ACTION_RENAME = 1;
|
||||
public static final byte ACTION_DELETE = 2;
|
||||
|
||||
private byte action;
|
||||
private String name;
|
||||
private String newName;
|
||||
|
||||
public CloneFolderCrudPacket() {
|
||||
}
|
||||
|
||||
public CloneFolderCrudPacket(byte action, String name) {
|
||||
this.action = action;
|
||||
this.name = name;
|
||||
this.newName = "";
|
||||
}
|
||||
|
||||
public CloneFolderCrudPacket(byte action, String name, String newName) {
|
||||
this.action = action;
|
||||
this.name = name;
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.CloneFolderCrud;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomNpcsPermissions.Permission getPermission() {
|
||||
return CustomNpcsPermissions.NPC_CLONE;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeByte(action);
|
||||
ByteBufUtils.writeString(out, name);
|
||||
if (action == ACTION_RENAME) {
|
||||
ByteBufUtils.writeString(out, newName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
byte action = in.readByte();
|
||||
String name = ByteBufUtils.readString(in);
|
||||
|
||||
boolean success = false;
|
||||
switch (action) {
|
||||
case ACTION_CREATE:
|
||||
if (CloneFolder.isValidName(name))
|
||||
success = ServerCloneController.Instance.createFolder(name) != null;
|
||||
break;
|
||||
case ACTION_RENAME:
|
||||
String newName = ByteBufUtils.readString(in);
|
||||
if (CloneFolder.isValidName(newName))
|
||||
success = ServerCloneController.Instance.renameFolder(name, newName);
|
||||
break;
|
||||
case ACTION_DELETE:
|
||||
success = ServerCloneController.Instance.deleteFolder(name);
|
||||
break;
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("Success", success);
|
||||
NBTTagList folderList = new NBTTagList();
|
||||
for (CloneFolder folder : ServerCloneController.Instance.getFolderList()) {
|
||||
folderList.appendTag(folder.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
compound.setTag("CloneFolders", folderList);
|
||||
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package kamkeel.npcs.network.packets.request.clone;
|
||||
|
||||
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.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.CloneFolder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class CloneFolderListPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneFolderList";
|
||||
|
||||
public CloneFolderListPacket() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.CloneFolderList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList folderList = new NBTTagList();
|
||||
for (CloneFolder folder : ServerCloneController.Instance.getFolderList()) {
|
||||
folderList.appendTag(folder.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
compound.setTag("CloneFolders", folderList);
|
||||
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,16 @@ public final class CloneListPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneList";
|
||||
|
||||
private int tab;
|
||||
private String folderName;
|
||||
|
||||
public CloneListPacket(int tab) {
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
}
|
||||
|
||||
public CloneListPacket(String folderName) {
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public CloneListPacket() {
|
||||
@@ -45,6 +52,9 @@ public final class CloneListPacket extends AbstractPacket {
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(tab);
|
||||
if (tab == -1) {
|
||||
kamkeel.npcs.util.ByteBufUtils.writeString(out, folderName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,14 +64,26 @@ public final class CloneListPacket extends AbstractPacket {
|
||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.MOUNTER, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
int tab = in.readInt();
|
||||
for (String name : ServerCloneController.Instance.getClones(tab))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
String folder = null;
|
||||
if (tab == -1) {
|
||||
folder = kamkeel.npcs.util.ByteBufUtils.readString(in);
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagList listDate = new NBTTagList();
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(tab))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
|
||||
if (folder != null) {
|
||||
for (String name : ServerCloneController.Instance.getClones(folder))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(folder))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
} else {
|
||||
for (String name : ServerCloneController.Instance.getClones(tab))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(tab))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("List", list);
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package kamkeel.npcs.network.packets.request.clone;
|
||||
|
||||
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.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class CloneMovePacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneMove";
|
||||
|
||||
private String cloneName;
|
||||
private int fromTab;
|
||||
private String fromFolder;
|
||||
private int toTab;
|
||||
private String toFolder;
|
||||
|
||||
public CloneMovePacket() {
|
||||
}
|
||||
|
||||
public CloneMovePacket(String cloneName, int fromTab, String fromFolder, int toTab, String toFolder) {
|
||||
this.cloneName = cloneName;
|
||||
this.fromTab = fromTab;
|
||||
this.fromFolder = fromFolder;
|
||||
this.toTab = toTab;
|
||||
this.toFolder = toFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.CloneMove;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomNpcsPermissions.Permission getPermission() {
|
||||
return CustomNpcsPermissions.NPC_CLONE;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeString(out, cloneName);
|
||||
out.writeInt(fromTab);
|
||||
ByteBufUtils.writeString(out, fromFolder != null ? fromFolder : "");
|
||||
out.writeInt(toTab);
|
||||
ByteBufUtils.writeString(out, toFolder != null ? toFolder : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
String cloneName = ByteBufUtils.readString(in);
|
||||
int fromTab = in.readInt();
|
||||
String fromFolder = ByteBufUtils.readString(in);
|
||||
if (fromFolder.isEmpty()) fromFolder = null;
|
||||
int toTab = in.readInt();
|
||||
String toFolder = ByteBufUtils.readString(in);
|
||||
if (toFolder.isEmpty()) toFolder = null;
|
||||
|
||||
boolean success = false;
|
||||
if (fromFolder != null && toFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromFolder, toFolder);
|
||||
} else if (fromFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromFolder, toTab);
|
||||
} else if (toFolder != null) {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromTab, toFolder);
|
||||
} else {
|
||||
success = ServerCloneController.Instance.moveClone(cloneName, fromTab, toTab);
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("MoveSuccess", success);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ public final class ClonePreSavePacket extends AbstractPacket {
|
||||
|
||||
private String name;
|
||||
private int tab;
|
||||
private String folderName;
|
||||
|
||||
public ClonePreSavePacket() {
|
||||
}
|
||||
@@ -31,6 +32,13 @@ public final class ClonePreSavePacket extends AbstractPacket {
|
||||
public ClonePreSavePacket(String name, int tab) {
|
||||
this.name = name;
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
}
|
||||
|
||||
public ClonePreSavePacket(String name, String folderName) {
|
||||
this.name = name;
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,6 +61,9 @@ public final class ClonePreSavePacket extends AbstractPacket {
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeString(out, this.name);
|
||||
out.writeInt(tab);
|
||||
if (tab == -1) {
|
||||
ByteBufUtils.writeString(out, this.folderName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +73,15 @@ public final class ClonePreSavePacket extends AbstractPacket {
|
||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
boolean bo = ServerCloneController.Instance.getCloneData(null, ByteBufUtils.readString(in), in.readInt()) != null;
|
||||
String name = ByteBufUtils.readString(in);
|
||||
int tab = in.readInt();
|
||||
boolean bo;
|
||||
if (tab == -1) {
|
||||
String folder = ByteBufUtils.readString(in);
|
||||
bo = ServerCloneController.Instance.getCloneData(null, name, folder) != null;
|
||||
} else {
|
||||
bo = ServerCloneController.Instance.getCloneData(null, name, tab) != null;
|
||||
}
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("NameExists", bo);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
|
||||
@@ -25,6 +25,7 @@ public final class CloneRemovePacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneRemove";
|
||||
|
||||
private int tab;
|
||||
private String folderName;
|
||||
private String name;
|
||||
|
||||
public CloneRemovePacket() {
|
||||
@@ -32,6 +33,13 @@ public final class CloneRemovePacket extends AbstractPacket {
|
||||
|
||||
public CloneRemovePacket(int tab, String name) {
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public CloneRemovePacket(String folderName, String name) {
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -54,6 +62,9 @@ public final class CloneRemovePacket extends AbstractPacket {
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(tab);
|
||||
if (tab == -1) {
|
||||
ByteBufUtils.writeString(out, this.folderName);
|
||||
}
|
||||
ByteBufUtils.writeString(out, this.name);
|
||||
}
|
||||
|
||||
@@ -65,16 +76,28 @@ public final class CloneRemovePacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
int tab = in.readInt();
|
||||
ServerCloneController.Instance.removeClone(ByteBufUtils.readString(in), tab);
|
||||
String folder = null;
|
||||
if (tab == -1) {
|
||||
folder = ByteBufUtils.readString(in);
|
||||
}
|
||||
String cloneName = ByteBufUtils.readString(in);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (String name : ServerCloneController.Instance.getClones(tab))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
|
||||
NBTTagList listDate = new NBTTagList();
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(tab))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
|
||||
if (folder != null) {
|
||||
ServerCloneController.Instance.removeClone(cloneName, folder);
|
||||
for (String name : ServerCloneController.Instance.getClones(folder))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(folder))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
} else {
|
||||
ServerCloneController.Instance.removeClone(cloneName, tab);
|
||||
for (String name : ServerCloneController.Instance.getClones(tab))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
for (String name : ServerCloneController.Instance.getClonesDate(tab))
|
||||
listDate.appendTag(new NBTTagString(name));
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("List", list);
|
||||
|
||||
@@ -25,6 +25,7 @@ public final class CloneSavePacket extends AbstractPacket {
|
||||
|
||||
private String name;
|
||||
private int tab;
|
||||
private String folderName;
|
||||
private NBTTagCompound tagExtra;
|
||||
private NBTTagCompound tagCompound;
|
||||
|
||||
@@ -34,6 +35,15 @@ public final class CloneSavePacket extends AbstractPacket {
|
||||
public CloneSavePacket(String name, int tab, NBTTagCompound tagExtra, NBTTagCompound tagCompound) {
|
||||
this.name = name;
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
this.tagExtra = tagExtra;
|
||||
this.tagCompound = tagCompound;
|
||||
}
|
||||
|
||||
public CloneSavePacket(String name, String folderName, NBTTagCompound tagExtra, NBTTagCompound tagCompound) {
|
||||
this.name = name;
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
this.tagExtra = tagExtra;
|
||||
this.tagCompound = tagCompound;
|
||||
}
|
||||
@@ -58,6 +68,9 @@ public final class CloneSavePacket extends AbstractPacket {
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeString(out, this.name);
|
||||
out.writeInt(tab);
|
||||
if (tab == -1) {
|
||||
ByteBufUtils.writeString(out, this.folderName);
|
||||
}
|
||||
ByteBufUtils.writeNBT(out, this.tagExtra);
|
||||
ByteBufUtils.writeNBT(out, this.tagCompound);
|
||||
}
|
||||
@@ -75,11 +88,20 @@ public final class CloneSavePacket extends AbstractPacket {
|
||||
|
||||
String name = ByteBufUtils.readString(in);
|
||||
int tab = in.readInt();
|
||||
String folder = null;
|
||||
if (tab == -1) {
|
||||
folder = ByteBufUtils.readString(in);
|
||||
}
|
||||
NBTTagCompound tagExtra = ByteBufUtils.readNBT(in);
|
||||
NBTTagCompound tagCompound = ByteBufUtils.readNBT(in);
|
||||
|
||||
NBTTagList tagList = tagCompound.getTagList("TagUUIDs", 8);
|
||||
data.cloned.setTag("TagUUIDs", tagList);
|
||||
ServerCloneController.Instance.addClone(data.cloned, name, tab, tagExtra);
|
||||
|
||||
if (folder != null) {
|
||||
ServerCloneController.Instance.addClone(data.cloned, name, folder, tagExtra);
|
||||
} else {
|
||||
ServerCloneController.Instance.addClone(data.cloned, name, tab, tagExtra);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ 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 kamkeel.npcs.util.ByteBufUtils;
|
||||
import noppes.npcs.controllers.ServerTagMapController;
|
||||
import noppes.npcs.controllers.data.TagMap;
|
||||
|
||||
@@ -22,9 +23,16 @@ public final class CloneTagListPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|CloneTagList";
|
||||
|
||||
private int tab;
|
||||
private String folderName;
|
||||
|
||||
public CloneTagListPacket(int tab) {
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
}
|
||||
|
||||
public CloneTagListPacket(String folderName) {
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public CloneTagListPacket() {
|
||||
@@ -44,6 +52,9 @@ public final class CloneTagListPacket extends AbstractPacket {
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(tab);
|
||||
if (tab == -1) {
|
||||
ByteBufUtils.writeString(out, folderName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +65,13 @@ public final class CloneTagListPacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
int tab = in.readInt();
|
||||
TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab);
|
||||
TagMap tagMap;
|
||||
if (tab == -1) {
|
||||
String folder = ByteBufUtils.readString(in);
|
||||
tagMap = ServerTagMapController.Instance.getTagMap(folder);
|
||||
} else {
|
||||
tagMap = ServerTagMapController.Instance.getTagMap(tab);
|
||||
}
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("CloneTags", tagMap.writeNBT());
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
|
||||
@@ -31,6 +31,7 @@ public class MobSpawnerPacket extends AbstractPacket {
|
||||
|
||||
private String selectedName;
|
||||
private int tab;
|
||||
private String folderName;
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
@@ -44,6 +45,17 @@ public class MobSpawnerPacket extends AbstractPacket {
|
||||
this.posz = posz;
|
||||
this.selectedName = selectedName;
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
}
|
||||
|
||||
public MobSpawnerPacket(Action type, int posX, int posY, int posz, String selectedName, String folderName) {
|
||||
this.type = type;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posz = posz;
|
||||
this.selectedName = selectedName;
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public MobSpawnerPacket(Action type, int posX, int posY, int posz, NBTTagCompound compound) {
|
||||
@@ -58,6 +70,10 @@ public class MobSpawnerPacket extends AbstractPacket {
|
||||
PacketClient.sendClient(new MobSpawnerPacket(Action.Server, x, y, z, name, tab));
|
||||
}
|
||||
|
||||
public static void ServerFolder(int x, int y, int z, String name, String folderName) {
|
||||
PacketClient.sendClient(new MobSpawnerPacket(Action.Server, x, y, z, name, folderName));
|
||||
}
|
||||
|
||||
public static void Client(int x, int y, int z, NBTTagCompound compound) {
|
||||
PacketClient.sendClient(new MobSpawnerPacket(Action.Client, x, y, z, compound));
|
||||
}
|
||||
@@ -88,6 +104,9 @@ public class MobSpawnerPacket extends AbstractPacket {
|
||||
if (type == Action.Server) {
|
||||
ByteBufUtils.writeString(out, this.selectedName);
|
||||
out.writeInt(this.tab);
|
||||
if (this.tab == -1) {
|
||||
ByteBufUtils.writeString(out, this.folderName);
|
||||
}
|
||||
} else {
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
@@ -107,10 +126,18 @@ public class MobSpawnerPacket extends AbstractPacket {
|
||||
int z = in.readInt();
|
||||
NBTTagCompound compound;
|
||||
|
||||
if (requestedAction == Action.Server)
|
||||
compound = ServerCloneController.Instance.getCloneData(player, ByteBufUtils.readString(in), in.readInt());
|
||||
else
|
||||
if (requestedAction == Action.Server) {
|
||||
String name = ByteBufUtils.readString(in);
|
||||
int tab = in.readInt();
|
||||
if (tab == -1) {
|
||||
String folder = ByteBufUtils.readString(in);
|
||||
compound = ServerCloneController.Instance.getCloneData(player, name, folder);
|
||||
} else {
|
||||
compound = ServerCloneController.Instance.getCloneData(player, name, tab);
|
||||
}
|
||||
} else {
|
||||
compound = ByteBufUtils.readNBT(in);
|
||||
}
|
||||
|
||||
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) {
|
||||
return;
|
||||
|
||||
@@ -37,6 +37,7 @@ public class SpawnMobPacket extends AbstractPacket {
|
||||
|
||||
private String selectedName;
|
||||
private int tab;
|
||||
private String folderName;
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
@@ -50,6 +51,17 @@ public class SpawnMobPacket extends AbstractPacket {
|
||||
this.posz = posz;
|
||||
this.selectedName = selectedName;
|
||||
this.tab = tab;
|
||||
this.folderName = null;
|
||||
}
|
||||
|
||||
public SpawnMobPacket(Action type, int posX, int posY, int posz, String selectedName, String folderName) {
|
||||
this.type = type;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
this.posz = posz;
|
||||
this.selectedName = selectedName;
|
||||
this.tab = -1;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public SpawnMobPacket(Action type, int posX, int posY, int posz, NBTTagCompound compound) {
|
||||
@@ -64,6 +76,10 @@ public class SpawnMobPacket extends AbstractPacket {
|
||||
PacketClient.sendClient(new SpawnMobPacket(Action.Server, x, y, z, name, tab));
|
||||
}
|
||||
|
||||
public static void ServerFolder(int x, int y, int z, String name, String folderName) {
|
||||
PacketClient.sendClient(new SpawnMobPacket(Action.Server, x, y, z, name, folderName));
|
||||
}
|
||||
|
||||
public static void Client(int x, int y, int z, NBTTagCompound compound) {
|
||||
PacketClient.sendClient(new SpawnMobPacket(Action.Client, x, y, z, compound));
|
||||
}
|
||||
@@ -94,6 +110,9 @@ public class SpawnMobPacket extends AbstractPacket {
|
||||
if (type == Action.Server) {
|
||||
ByteBufUtils.writeString(out, this.selectedName);
|
||||
out.writeInt(this.tab);
|
||||
if (this.tab == -1) {
|
||||
ByteBufUtils.writeString(out, this.folderName);
|
||||
}
|
||||
} else {
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
@@ -113,10 +132,18 @@ public class SpawnMobPacket extends AbstractPacket {
|
||||
int z = in.readInt();
|
||||
NBTTagCompound compound;
|
||||
|
||||
if (requestedAction == Action.Server)
|
||||
compound = ServerCloneController.Instance.getCloneData(player, ByteBufUtils.readString(in), in.readInt());
|
||||
else
|
||||
if (requestedAction == Action.Server) {
|
||||
String name = ByteBufUtils.readString(in);
|
||||
int tab = in.readInt();
|
||||
if (tab == -1) {
|
||||
String folder = ByteBufUtils.readString(in);
|
||||
compound = ServerCloneController.Instance.getCloneData(player, name, folder);
|
||||
} else {
|
||||
compound = ServerCloneController.Instance.getCloneData(player, name, tab);
|
||||
}
|
||||
} else {
|
||||
compound = ByteBufUtils.readNBT(in);
|
||||
}
|
||||
|
||||
if (compound == null)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user