Fix NPC Tag Modifier not saving and isNPC Crash

This commit is contained in:
Kam committed 2023-05-02 19:07:47 -04:00
1 parent 17566031d7
commit 36cd81e6e4
3 files changed
+35 -17

No files matched your search

@@ -9,14 +9,11 @@ import net.minecraft.entity.EntityList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.advanced.GuiNPCTagSetup;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.entity.EntityNPCInterface;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
@@ -35,10 +32,11 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
public GuiNpcMobSpawnerAdd(NBTTagCompound compound){
this.toClone = EntityList.createEntityFromNBT(compound, Minecraft.getMinecraft().theWorld);
this.compound = compound;
updateIsNPC();
// Get Tag UUIDs
this.getTagUUIDs();
if(isNPC){
this.getTagUUIDs();
Client.sendData(EnumPacketServer.TagsGet);
}
@@ -72,14 +70,10 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
}
public void getTagUUIDs(){
// Is an NPC
if(compound.hasKey("ModRev")){
this.isNPC = true;
if(compound.hasKey("TagUUIDs")){
NBTTagList nbtTagList = compound.getTagList("TagUUIDs",8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
npcTags.add(UUID.fromString(nbtTagList.getStringTagAt(i)));
}
if(compound.hasKey("TagUUIDs")){
NBTTagList nbtTagList = compound.getTagList("TagUUIDs",8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
npcTags.add(UUID.fromString(nbtTagList.getStringTagAt(i)));
}
}
}
@@ -153,10 +147,22 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
}
}
public void updateIsNPC(){
if(compound.hasKey("id")){
String id = compound.getString("id");
if(id.equals("customnpcs.CustomNpc")){
this.isNPC = true;
return;
}
}
this.isNPC = false;
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiNpcQuickTags) {
SubGuiNpcQuickTags filterGui = (SubGuiNpcQuickTags) subgui;
if (subgui instanceof SubGuiClonerQuickTags) {
SubGuiClonerQuickTags filterGui = (SubGuiClonerQuickTags) subgui;
// filter = filterGui.filterScroll.getSelectedList();
}
initGui();
@@ -29,7 +29,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
setBackground("menubg.png");
xSize = 305;
ySize = 220;
closeOnEsc = true;
closeOnEsc = false;
}
public void initGui()
@@ -60,6 +60,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
addButton(new GuiNpcButton(12, guiLeft + 120, guiTop + 140, 55, 20, ">>"));
addButton(new GuiNpcButton(13, guiLeft + 120, guiTop + 162, 55, 20, "<<"));
addButton(new GuiNpcButton(66, guiLeft + 120, guiTop + 50, 55, 20, "gui.save"));
}
@Override
@@ -77,6 +79,9 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
if (guibutton.id == 13) {
tagNames.clear();
}
if (guibutton.id == 66) {
close();
}
initGui();
}
@@ -122,4 +127,11 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
tagCompound.setTag("TagNames",tagList);
Client.sendData(EnumPacketServer.TagSet, tagCompound);
}
@Override
public void close() {
save();
super.close();
}
}
@@ -10,14 +10,14 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.HashSet;
public class SubGuiNpcQuickTags extends SubGuiInterface
public class SubGuiClonerQuickTags extends SubGuiInterface
{
public GuiNpcMobSpawnerAdd parent;
ArrayList<String> allTags = new ArrayList<>();
HashSet<String> filter;
public GuiCustomScroll filterScroll;
public SubGuiNpcQuickTags(GuiNpcMobSpawnerAdd par){
public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){
this.parent = par;
setBackground("menubg.png");
xSize = 305;