Search in sources :

Example 36 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class QuestInstance method readFromJson_Config.

private void readFromJson_Config(NBTTagCompound jObj) {
    this.qInfo.readFromNBT(jObj.getCompoundTag("properties"), EnumSaveType.CONFIG);
    this.tasks.readFromNBT(jObj.getTagList("tasks", 10), EnumSaveType.CONFIG);
    this.rewards.readFromNBT(jObj.getTagList("rewards", 10), EnumSaveType.CONFIG);
    preRequisites.clear();
    if (// Native NBT
    jObj.getTagId("preRequisites") == 11) {
        for (int prID : jObj.getIntArray("preRequisites")) {
            if (prID < 0) {
                continue;
            }
            IQuest tmp = parentDB.getValue(prID);
            if (tmp == null) {
                tmp = parentDB.createNew();
                parentDB.add(tmp, prID);
            }
            preRequisites.add(tmp);
        }
    } else // Probably an NBTTagList
    {
        NBTTagList rList = jObj.getTagList("preRequisites", 4);
        for (int i = 0; i < rList.tagCount(); i++) {
            NBTBase pTag = rList.get(i);
            int prID = pTag instanceof NBTPrimitive ? ((NBTPrimitive) pTag).getInt() : -1;
            if (prID < 0) {
                continue;
            }
            IQuest tmp = parentDB.getValue(prID);
            if (tmp == null) {
                tmp = parentDB.createNew();
                parentDB.add(tmp, prID);
            }
            preRequisites.add(tmp);
        }
    }
    this.setupProps();
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTPrimitive(net.minecraft.nbt.NBTPrimitive) IQuest(betterquesting.api.questing.IQuest) NBTBase(net.minecraft.nbt.NBTBase)

Example 37 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiPrerequisiteEditor method refreshGui.

@Override
public void refreshGui() {
    IQuest tmp = QuestDatabase.INSTANCE.getValue(questID);
    if (tmp == null) {
        mc.displayGuiScreen(parent);
        return;
    }
    quest = tmp;
    RefreshSearch();
    RefreshColumns();
}
Also used : IQuest(betterquesting.api.questing.IQuest)

Example 38 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiQuestLineEditorB method RefreshSearch.

public void RefreshSearch() {
    searchResults.clear();
    String query = searchBox.getText().toLowerCase();
    for (int id : QuestDatabase.INSTANCE.getAllKeys()) {
        IQuest q = QuestDatabase.INSTANCE.getValue(id);
        if (query.length() <= 0 || q.getUnlocalisedName().toLowerCase().contains(query) || I18n.format(q.getUnlocalisedName()).toLowerCase().contains(query) || query.equalsIgnoreCase("" + id)) {
            searchResults.add(id);
        }
    }
}
Also used : IQuest(betterquesting.api.questing.IQuest)

Example 39 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class GuiQuestLineEditorB method RefreshColumns.

public void RefreshColumns() {
    if (line == null) {
        lineQuests.clear();
    } else {
        lineQuests = line.getAllKeys();
    }
    qlBtnList.getEntryList().clear();
    for (int qID : lineQuests) {
        IQuest quest = QuestDatabase.INSTANCE.getValue(qID);
        if (quest == null) {
            continue;
        }
        int bWidth = qlBtnList.getListWidth();
        // First 3 bits reserved for column index
        int bID = (2 + qID) << 3;
        GuiButtonThemed btn1 = new GuiButtonThemed(bID + 0, 0, 0, bWidth - 20, 20, I18n.format(quest.getUnlocalisedName()));
        GuiButtonThemed btn2 = new GuiButtonThemed(bID + 1, 0, 0, 20, 20, TextFormatting.YELLOW + ">");
        qlBtnList.addButtonRow(btn1, btn2);
    }
    dbBtnList.getEntryList().clear();
    for (int qID : searchResults) {
        IQuest quest = QuestDatabase.INSTANCE.getValue(qID);
        if (quest == null) {
            continue;
        }
        int bWidth = dbBtnList.getListWidth();
        // First 3 bits reserved for column index
        int bID = (2 + qID) << 3;
        GuiButtonThemed btn3 = new GuiButtonThemed(bID + 2, 0, 0, 20, 20, TextFormatting.GREEN + "<");
        btn3.enabled = line != null && !lineQuests.contains(qID);
        GuiButtonThemed btn4 = new GuiButtonThemed(bID + 3, 0, 0, bWidth - 40, 20, I18n.format(quest.getUnlocalisedName()));
        GuiButtonThemed btn5 = new GuiButtonThemed(bID + 4, 0, 0, 20, 20, "" + TextFormatting.BOLD + TextFormatting.RED + "x");
        dbBtnList.addButtonRow(btn3, btn4, btn5);
    }
}
Also used : IQuest(betterquesting.api.questing.IQuest) GuiButtonThemed(betterquesting.api.client.gui.controls.GuiButtonThemed)

Example 40 with IQuest

use of betterquesting.api.questing.IQuest in project BetterQuesting by Funwayguy.

the class QuestCache method getActiveTasks.

/**
 * Returns a cached list of active tasks of the given type with references to their parent quest
 */
@SuppressWarnings("unchecked")
public <T extends ITask> Map<T, IQuest> getActiveTasks(UUID uuid, Class<T> type) {
    Map<T, IQuest> list = new HashMap<T, IQuest>();
    HashMap<Integer, List<Integer>> pCache = rawCache.get(uuid);
    pCache = pCache != null ? pCache : new HashMap<Integer, List<Integer>>();
    for (Entry<Integer, List<Integer>> entry : pCache.entrySet()) {
        IQuest quest = QuestingAPI.getAPI(ApiReference.QUEST_DB).getValue(entry.getKey());
        if (quest == null) {
            continue;
        }
        for (int tID : entry.getValue()) {
            ITask task = quest.getTasks().getValue(tID);
            if (task != null && type.isAssignableFrom(task.getClass())) {
                list.put((T) task, quest);
            }
        }
    }
    return list;
}
Also used : ITask(betterquesting.api.questing.tasks.ITask) IQuest(betterquesting.api.questing.IQuest) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

IQuest (betterquesting.api.questing.IQuest)44 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 ITask (betterquesting.api.questing.tasks.ITask)9 UUID (java.util.UUID)9 QuestInstance (betterquesting.questing.QuestInstance)8 ArrayList (java.util.ArrayList)6 GuiButtonQuestInstance (betterquesting.api.client.gui.controls.GuiButtonQuestInstance)5 QuestingPacket (betterquesting.api.network.QuestingPacket)4 IQuestLine (betterquesting.api.questing.IQuestLine)4 HashMap (java.util.HashMap)4 NBTBase (net.minecraft.nbt.NBTBase)4 GuiButtonThemed (betterquesting.api.client.gui.controls.GuiButtonThemed)3 IQuestLineEntry (betterquesting.api.questing.IQuestLineEntry)3 PanelButtonStorage (betterquesting.api2.client.gui.controls.PanelButtonStorage)3 QuestLineEntry (betterquesting.questing.QuestLineEntry)3 List (java.util.List)3 Minecraft (net.minecraft.client.Minecraft)3 CommandException (net.minecraft.command.CommandException)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 IPanelButton (betterquesting.api2.client.gui.controls.IPanelButton)2