Send All Tags to Client for Viewing

This commit is contained in:
KAMKEEL committed 2023-03-22 20:13:36 -04:00
1 parent ac87f2c2c2
commit 30b3f55e7c
4 files changed
+23 -26

No files matched your search

@@ -28,6 +28,7 @@ import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.handler.data.ITag;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.ConfigScript;
@@ -1081,14 +1082,14 @@ public class PacketHandlerServer{
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("CloneTags", tagMap.writeNBT());
HashSet<Tag> validTags = TagController.getInstance().getValidTags(tagMap);
HashSet<Tag> validTags = TagController.getInstance().getAllTags();
NBTTagList validTagList = new NBTTagList();
for(Tag tag : validTags){
NBTTagCompound tagCompound = new NBTTagCompound();
tag.writeNBT(tagCompound);
validTagList.appendTag(tagCompound);
}
compound.setTag("ValidTags", validTagList);
compound.setTag("AllTags", validTagList);
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
}
else
@@ -20,10 +20,10 @@ import noppes.npcs.controllers.data.TagMap;
import java.lang.reflect.Modifier;
import java.util.*;
public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGuiData {
public static HashSet<String> allTags = new HashSet<>();
public static HashSet<String> tagFilters = new HashSet<>();
public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
public static HashMap<String, UUID> tagNames = new HashMap<>();
public static HashMap<UUID, Tag> tags = new HashMap<>();
public static HashSet<String> tagFilters = new HashSet<>();
public byte displayTags = 0;
public TagMap tagMap;
@@ -66,7 +66,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
filterScroll.setSize(140, 188);
filterScroll.guiLeft = guiLeft + 4;
filterScroll.guiTop = guiTop + 19;
filterScroll.setList(new ArrayList<>(allTags));
filterScroll.setList(new ArrayList<>(tagNames.keySet()));
filterScroll.multipleSelection = true;
filterScroll.setSelectedList(tagFilters);
@@ -314,7 +314,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
}
}
if (id == 10) {
HashSet<String> hashSet = new HashSet<>(allTags);
HashSet<String> hashSet = new HashSet<>(tagNames.keySet());
filterScroll.setSelectedList(hashSet);
}
if (id == 11) {
@@ -330,29 +330,20 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
}
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data)
{
allTags.addAll(list);
}
@Override
public void setSelected(String selected) {
}
@Override
public void save() {
// TODO Auto-generated method stub
}
@Override
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("CloneTags")) {
tagMap = new TagMap(activeTab);
NBTTagCompound cloneTags = compound.getCompoundTag("CloneTags");
tagMap.readNBT(cloneTags);
NBTTagList validTags = compound.getTagList("ValidTags", 10);
}
else if (compound.hasKey("AllTags")) {
NBTTagList validTags = compound.getTagList("AllTags", 10);
if(validTags != null){
for(int j = 0; j < validTags.tagCount(); j++)
{
@@ -362,7 +353,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IScrollData,IGu
tags.put(tag.uuid, tag);
}
}
} else {
}
else {
NBTTagList nbtlist = compound.getTagList("List", 8);
List<String> list = new ArrayList<String>();
for(int i = 0; i < nbtlist.tagCount(); i++){
@@ -34,13 +34,13 @@ public class ServerTagMapController {
public TagMap getTagMap(int tab){
this.tagMap = new TagMap(tab);
try {
File file = new File(getCloneTabDir(tab), "_____tag_map.dat");
File file = new File(getCloneTabDir(tab), "___tagmap.dat");
if(file.exists()){
loadTagMapFile(file);
}
} catch (Exception e) {
try {
File file = new File(getCloneTabDir(tab), "_____tag_map.dat_old");
File file = new File(getCloneTabDir(tab), "___tagmap.dat_old");
if(file.exists()){
loadTagMapFile(file);
}
@@ -63,9 +63,9 @@ public class ServerTagMapController {
public void saveTagMap(TagMap tagMap){
try {
File saveDir = getCloneTabDir(tagMap.cloneTab);
File file = new File(saveDir, "_____tag_map.dat_new");
File file1 = new File(saveDir, "_____tag_map.dat_old");
File file2 = new File(saveDir, "_____tag_map.dat");
File file = new File(saveDir, "___tagmap.dat_new");
File file1 = new File(saveDir, "___tagmap.dat_old");
File file2 = new File(saveDir, "___tagmap.dat");
CompressedStreamTools.writeCompressed(tagMap.writeNBT(), new FileOutputStream(file));
if(file1.exists())
{
@@ -231,6 +231,10 @@ public class TagController implements ITagHandler {
return names;
}
public HashSet<Tag> getAllTags(){
return new HashSet<Tag>(this.tags.values());
}
public HashSet<Tag> getValidTags(TagMap tagMap){
HashSet<Tag> tags = new HashSet<Tag>();
for(UUID tagUUID : tagMap.getAllUUIDs()){