mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 16:55:12 +00:00
Send Valid Tags to Client that correlate with UUIDs found on the Server. No longer needs the Clones Data
This commit is contained in:
1 parent
0943299384
commit
41c4fc66d0
5 files changed
+80
-24
No files matched your search
@@ -1080,6 +1080,15 @@ public class PacketHandlerServer{
|
||||
TagMap tagMap = ServerTagMapController.Instance.getTagMap(tab);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("CloneTags", tagMap.writeNBT());
|
||||
|
||||
HashSet<Tag> validTags = TagController.getInstance().getValidTags(tagMap);
|
||||
NBTTagList validTagList = new NBTTagList();
|
||||
for(Tag tag : validTags){
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tag.writeNBT(tagCompound);
|
||||
validTagList.appendTag(tagCompound);
|
||||
}
|
||||
compound.setTag("ValidTags", validTagList);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,7 +23,8 @@ import java.util.*;
|
||||
public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGuiData {
|
||||
public static HashSet<String> allTags = new HashSet<>();
|
||||
public static HashSet<String> filter = new HashSet<>();
|
||||
public static boolean showHidden = false;
|
||||
public static HashMap<UUID, Tag> tags = new HashMap<>();
|
||||
public byte displayTags = 0;
|
||||
public TagMap tagMap;
|
||||
|
||||
private final GuiCustomScrollCloner scroll = new GuiCustomScrollCloner(this,0);
|
||||
@@ -120,7 +121,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
|
||||
addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll"));
|
||||
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll"));
|
||||
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("tags.taglessEntries") + ":", guiLeft + 150, guiTop + 72));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 240, guiTop + 65, new String[]{"display.show", "display.hide"}, showHidden ? 0 : 1));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 240, guiTop + 65, new String[]{"all", "none", "hidden"}, displayTags));
|
||||
getButton(12).width = 60;
|
||||
getButton(12).height = 20;
|
||||
}
|
||||
@@ -312,7 +313,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
|
||||
filterScroll.setSelectedList(new HashSet<>());
|
||||
}
|
||||
if (id == 12) {
|
||||
showHidden = !showHidden;
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
displayTags = (byte) button.getValue();
|
||||
}
|
||||
if(id > 20){
|
||||
activeTab = id - 20;
|
||||
@@ -341,6 +343,17 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
|
||||
tagMap = new TagMap(activeTab);
|
||||
NBTTagCompound cloneTags = compound.getCompoundTag("CloneTags");
|
||||
tagMap.readNBT(cloneTags);
|
||||
|
||||
NBTTagList validTags = compound.getTagList("ValidTags", 10);
|
||||
if(validTags != null){
|
||||
for(int j = 0; j < validTags.tagCount(); j++)
|
||||
{
|
||||
NBTTagCompound tagStructure = validTags.getCompoundTagAt(j);
|
||||
Tag tag = new Tag();
|
||||
tag.readNBT(tagStructure);
|
||||
tags.put(tag.uuid, tag);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NBTTagList nbtlist = compound.getTagList("List", 8);
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
@@ -20,21 +20,21 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
int l = 0;
|
||||
for(int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
HashSet<UUID> tags = this.parent.tagMap.getUUIDs(list.get(i));
|
||||
boolean inFilter = false;
|
||||
for (UUID uuid : tags) {
|
||||
if (GuiNpcMobSpawner.filter.contains(uuid)) {
|
||||
inFilter = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inFilter) {
|
||||
continue;
|
||||
}
|
||||
} else if (!GuiNpcMobSpawner.showHidden) {
|
||||
continue;
|
||||
}
|
||||
// if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
// HashSet<UUID> tags = this.parent.tagMap.getUUIDs(list.get(i));
|
||||
// boolean inFilter = false;
|
||||
// for (UUID uuid : tags) {
|
||||
// if (GuiNpcMobSpawner.filter.contains(uuid)) {
|
||||
// inFilter = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!inFilter) {
|
||||
// continue;
|
||||
// }
|
||||
// } else if (!GuiNpcMobSpawner.showHidden) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
int j = 4;
|
||||
int k = (14 * l + 4) - scrollY;
|
||||
@@ -72,12 +72,23 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
}
|
||||
|
||||
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 5;
|
||||
if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tag : this.parent.tagMap.getUUIDs(list.get(i))) {
|
||||
// if (!tag.getIsHidden()) {
|
||||
// fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
|
||||
// tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
|
||||
// }
|
||||
if(this.parent.displayTags == 0 || this.parent.displayTags == 2){
|
||||
if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.parent.tagMap.getUUIDs(list.get(i))){
|
||||
Tag tag = this.parent.tags.get(tagUUID);
|
||||
if(tag != null){
|
||||
if(this.parent.displayTags == 2){
|
||||
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
|
||||
}
|
||||
else {
|
||||
if(!tag.getIsHidden()){
|
||||
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.handler.ITagHandler;
|
||||
import noppes.npcs.api.handler.data.ITag;
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.controllers.data.TagMap;
|
||||
import scala.Int;
|
||||
|
||||
import java.io.*;
|
||||
@@ -246,4 +247,15 @@ public class TagController implements ITagHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashSet<Tag> getValidTags(TagMap tagMap){
|
||||
HashSet<Tag> tags = new HashSet<Tag>();
|
||||
for(UUID tagUUID : tagMap.getAllUUIDs()){
|
||||
Tag foundTag = get(tagUUID);
|
||||
if(foundTag != null){
|
||||
tags.add(foundTag);
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TagMap {
|
||||
@@ -84,4 +87,12 @@ public class TagMap {
|
||||
return uuids.contains(tag);
|
||||
}
|
||||
|
||||
public HashSet<UUID> getAllUUIDs() {
|
||||
HashSet<UUID> uuids = new HashSet<UUID>();
|
||||
for(HashSet<UUID> uuids1 : tagMap.values()){
|
||||
uuids.addAll(uuids1);
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user