use of betterquesting.client.gui.editors.json.callback.JsonItemCallback 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;
}
}*/
}
use of betterquesting.client.gui.editors.json.callback.JsonItemCallback in project BetterQuesting by Funwayguy.
the class GuiJsonTypeMenu method initGui.
@Override
public void initGui() {
super.initGui();
fluid = null;
stack = null;
entity = null;
if (json != null) {
if (// Must have at least these 3 to be considered a valid 'item'
JsonHelper.isItem(json)) {
stack = JsonHelper.JsonToItemStack(json);
}
if (stack == null && JsonHelper.isEntity(json)) {
entity = EntityList.createEntityFromNBT(json, Minecraft.getMinecraft().world);
}
if (stack == null && entity == null && JsonHelper.isFluid(json)) {
fluid = JsonHelper.JsonToFluidStack(json);
}
} else // JSON cannot be null!
{
this.mc.displayGuiScreen(parent);
return;
}
if (stack == null) {
stack = new BigItemStack(Blocks.STONE);
}
if (entity == null) {
entity = new EntityPig(Minecraft.getMinecraft().world);
}
if (fluid == null) {
fluid = new FluidStack(FluidRegistry.WATER, 1000);
}
if (lastType == EditType.ITEM) {
JsonHelper.ClearCompoundTag(json);
JsonHelper.ItemStackToJson(stack, json);
} else if (lastType == EditType.FLUID) {
JsonHelper.ClearCompoundTag(json);
JsonHelper.FluidStackToJson(fluid, json);
} else if (lastType == EditType.ENTITY) {
JsonHelper.ClearCompoundTag(json);
JsonHelper.EntityToJson(entity, json);
}
if (lastType != EditType.NONE) {
mc.displayGuiScreen(parent);
}
// JSON Editor
GuiButtonThemed editButton = new GuiButtonThemed(3, this.width / 2 - 100, this.height / 2 - 40, 200, 20, I18n.format("betterquesting.btn.raw_nbt"), true);
// Item Selector
GuiButtonThemed itemButton = new GuiButtonThemed(1, this.width / 2 - 100, this.height / 2 - 20, 200, 20, I18n.format("betterquesting.btn.item"), true);
// Fluid Editor
GuiButtonThemed fluidButton = new GuiButtonThemed(4, this.width / 2 - 100, this.height / 2 + 00, 200, 20, I18n.format("betterquesting.btn.fluid"), true);
// Entity Selector
GuiButtonThemed entityButton = new GuiButtonThemed(2, this.width / 2 - 100, this.height / 2 + 20, 200, 20, I18n.format("betterquesting.btn.entity"), true);
this.buttonList.add(itemButton);
this.buttonList.add(entityButton);
this.buttonList.add(editButton);
this.buttonList.add(fluidButton);
itemCallback = new JsonItemCallback(json, stack);
fluidCallback = new JsonFluidCallback(json, fluid);
entityCallback = new JsonEntityCallback(json, entity);
}
Aggregations