mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 00:22:19 +00:00
Support for loading quest data from legacy CustomNPCs formats (1.6.4)
This commit is contained in:
1 parent
8e9d2fedc5
commit
9a07bb36a4
2 files changed
+16
-3
No files matched your search
+1
-1
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
def embedMixin = !project.hasProperty("nomixin");
|
||||
dependencies {
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.75-GTNH:dev")
|
||||
runtimeOnlyNonPublishable("curse.maven:Nashorn-374413:2924946")
|
||||
|
||||
if(embedMixin){
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.api.handler.data.IQuestCategory;
|
||||
|
||||
@@ -21,8 +22,8 @@ public class QuestCategory implements IQuestCategory {
|
||||
public void readNBT(NBTTagCompound nbttagcompound) {
|
||||
id = nbttagcompound.getInteger("Slot");
|
||||
title = nbttagcompound.getString("Title");
|
||||
NBTTagList questList = nbttagcompound.getTagList("Quests", 10);
|
||||
if (questList != null) {
|
||||
NBTTagList questList = getFirstValidList(nbttagcompound, Constants.NBT.TAG_COMPOUND, "Quests", "Dialogs");
|
||||
if (questList.tagCount() > 0) {
|
||||
for (int ii = 0; ii < questList.tagCount(); ii++) {
|
||||
NBTTagCompound nbttagcompound2 = questList.getCompoundTagAt(ii);
|
||||
Quest quest = new Quest();
|
||||
@@ -33,6 +34,18 @@ public class QuestCategory implements IQuestCategory {
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagList getFirstValidList(NBTTagCompound nbt, int type, String... keys) {
|
||||
for (String key : keys) {
|
||||
if (nbt.hasKey(key, Constants.NBT.TAG_LIST)) {
|
||||
NBTTagList list = nbt.getTagList(key, type);
|
||||
if (list.tagCount() > 0) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new NBTTagList();
|
||||
}
|
||||
|
||||
public NBTTagCompound writeNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("Slot", id);
|
||||
nbttagcompound.setString("Title", title);
|
||||
|
||||
Reference in new issue
Block a user