Search in sources :

Example 1 with IJsonDoc

use of betterquesting.api.jdoc.IJsonDoc in project BetterQuesting by Funwayguy.

the class ScrollingJsonEntry method onActionPerformed.

public void onActionPerformed(GuiButtonThemed btn) {
    if (// Delete Entry
    je != null && btn.id == 3) {
        if (json.getId() == 10) {
            ((NBTTagCompound) json).removeTag(key);
            host.getEntryList().remove(this);
            host.refresh();
            return;
        } else if (json.getId() == 9) {
            ((NBTTagList) json).removeTag(idx);
            host.getEntryList().remove(this);
            host.refresh();
            return;
        }
    }
    if (btn.id == 2) {
        if (json.getId() == 9) {
            mc.displayGuiScreen(new GuiJsonAdd(mc.currentScreen, (NBTTagList) json, idx));
            return;
        } else if (json.getId() == 10) {
            mc.displayGuiScreen(new GuiJsonAdd(mc.currentScreen, (NBTTagCompound) json));
            return;
        }
    } else if (je != null && je.getId() == 10) {
        NBTTagCompound jo = (NBTTagCompound) je;
        IJsonDoc childDoc = jDoc == null ? null : jDoc.getChildDoc(key);
        if (// Main
        btn.id == 0) {
            if (!(JsonHelper.isItem(jo) || JsonHelper.isFluid(jo) || JsonHelper.isEntity(jo))) {
                mc.displayGuiScreen(new GuiJsonEditor(mc.currentScreen, jo, childDoc));
            } else if (JsonHelper.isItem(jo)) {
                mc.displayGuiScreen(new GuiJsonItemSelection(mc.currentScreen, new JsonItemCallback(jo), JsonHelper.JsonToItemStack(jo)));
            } else if (JsonHelper.isFluid(jo)) {
                mc.displayGuiScreen(new GuiJsonFluidSelection(mc.currentScreen, new JsonFluidCallback(jo), JsonHelper.JsonToFluidStack(jo)));
            } else if (JsonHelper.isEntity(jo)) {
                mc.displayGuiScreen(new GuiJsonEntitySelection(mc.currentScreen, new JsonEntityCallback(jo), JsonHelper.JsonToEntity(jo, mc.world, true)));
            }
        } else if (// Advanced
        btn.id == 1) {
            mc.displayGuiScreen(new GuiJsonTypeMenu(mc.currentScreen, jo));
        }
    } else if (je != null && je.getId() == 9) {
        mc.displayGuiScreen(new GuiJsonEditor(mc.currentScreen, (NBTTagList) je, jDoc));
    }
/* else if(je != null && je.isJsonPrimitive() && je.getAsJsonPrimitive().isBoolean())
		{
			if(json.isJsonObject())
			{
				json.getAsJsonObject().addProperty(key, !je.getAsBoolean());
				host.refresh();
				return;
			} else if(json.isJsonArray())
			{
				JsonHelper.GetUnderlyingArray(json.getAsJsonArray()).set(idx, new JsonPrimitive(!je.getAsBoolean()));
				host.refresh();
				return;
			}
		}*/
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GuiJsonAdd(betterquesting.client.gui.editors.json.GuiJsonAdd) JsonEntityCallback(betterquesting.client.gui.editors.json.callback.JsonEntityCallback) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IJsonDoc(betterquesting.api.jdoc.IJsonDoc) JsonFluidCallback(betterquesting.client.gui.editors.json.callback.JsonFluidCallback) GuiJsonItemSelection(betterquesting.client.gui.editors.json.GuiJsonItemSelection) GuiJsonEntitySelection(betterquesting.client.gui.editors.json.GuiJsonEntitySelection) JsonItemCallback(betterquesting.client.gui.editors.json.callback.JsonItemCallback) GuiJsonTypeMenu(betterquesting.client.gui.editors.json.GuiJsonTypeMenu) GuiJsonFluidSelection(betterquesting.client.gui.editors.json.GuiJsonFluidSelection)

Aggregations

IJsonDoc (betterquesting.api.jdoc.IJsonDoc)1 GuiJsonAdd (betterquesting.client.gui.editors.json.GuiJsonAdd)1 GuiJsonEntitySelection (betterquesting.client.gui.editors.json.GuiJsonEntitySelection)1 GuiJsonFluidSelection (betterquesting.client.gui.editors.json.GuiJsonFluidSelection)1 GuiJsonItemSelection (betterquesting.client.gui.editors.json.GuiJsonItemSelection)1 GuiJsonTypeMenu (betterquesting.client.gui.editors.json.GuiJsonTypeMenu)1 JsonEntityCallback (betterquesting.client.gui.editors.json.callback.JsonEntityCallback)1 JsonFluidCallback (betterquesting.client.gui.editors.json.callback.JsonFluidCallback)1 JsonItemCallback (betterquesting.client.gui.editors.json.callback.JsonItemCallback)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1