use of betterquesting.api.utils.BigItemStack in project BetterQuesting by Funwayguy.
the class GuiButtonJson method refreshJson.
public void refreshJson() {
if (json == null) {
this.displayString = "?";
return;
} else if (json.getId() == 10) {
NBTTagCompound jcTag = (NBTTagCompound) json;
if (JsonHelper.isItem(jcTag)) {
isItem = true;
} else if (JsonHelper.isFluid(jcTag)) {
isFluid = true;
} else if (JsonHelper.isEntity(jcTag)) {
isEntity = true;
}
}
if (isItem) {
BigItemStack stack = JsonHelper.JsonToItemStack((NBTTagCompound) json);
this.displayString = I18n.format("betterquesting.btn.item") + ": " + stack.getBaseStack().getDisplayName();
} else if (isFluid) {
FluidStack fluid = JsonHelper.JsonToFluidStack((NBTTagCompound) json);
this.displayString = I18n.format("betterquesting.btn.fluid") + ": " + fluid.getLocalizedName();
} else if (isEntity) {
Entity entity = JsonHelper.JsonToEntity((NBTTagCompound) json, this.mc.world);
this.displayString = I18n.format("betterquesting.btn.entity") + ": " + entity.getName();
} else {
this.displayString = getJsonName();
}
}
use of betterquesting.api.utils.BigItemStack in project BetterQuesting by Funwayguy.
the class GuiJsonItemSelection method mouseClicked.
@Override
public void mouseClicked(int mx, int my, int type) throws IOException {
ItemStack gStack = itemGrid.getStackUnderMouse(mx, my);
this.searchBox.mouseClicked(mx, my, type);
this.numberBox.mouseClicked(mx, my, type);
int btnWidth = sizeX / 2 - 16;
int isx = (18 * 9);
int isy = (18 * 4);
float scale = Math.min((btnWidth - 16) / (float) isx, (sizeY / 2F - 32) / isy);
int ipx = guiLeft + 16 + btnWidth / 2 - (int) (isx / 2 * scale);
int ipy = guiTop + sizeY / 2;
if (gStack != null) {
this.stackSelect = new BigItemStack(gStack.copy());
numberBox.setText("" + stackSelect.stackSize);
oreDictIdx = -1;
btnOreDict.displayString = "OreDict: NONE";
return;
} else if (this.mc.player != null && this.isWithin(mx, my, ipx, ipy, (int) (18 * 9 * scale), (int) (18 * 4 * scale), false)) {
int idxSize = (int) (18 * scale);
int sx = (mx - ipx) / idxSize;
int sy = (my - ipy) / idxSize;
int index = sx + (sy * 9);
if (index >= 0 && index < this.mc.player.inventory.mainInventory.size()) {
ItemStack invoStack = this.mc.player.inventory.mainInventory.get(index);
if (invoStack != null) {
this.stackSelect = new BigItemStack(invoStack.copy());
numberBox.setText("" + stackSelect.stackSize);
oreDictIdx = -1;
btnOreDict.displayString = "OreDict: NONE";
}
}
return;
} else if (!numberBox.isFocused() && stackSelect != null && stackSelect.stackSize != numberBox.getNumber().intValue()) {
int i = Math.max(1, numberBox.getNumber().intValue());
numberBox.setText("" + i);
stackSelect.stackSize = i;
}
super.mouseClicked(mx, my, type);
}
use of betterquesting.api.utils.BigItemStack in project BetterQuesting by Funwayguy.
the class GuiJsonItemSelection method drawBackPanel.
@Override
public void drawBackPanel(int mx, int my, float partialTick) {
super.drawBackPanel(mx, my, partialTick);
ttStack = null;
int btnWidth = sizeX / 2 - 16;
GlStateManager.color(1f, 1f, 1f, 1f);
this.fontRenderer.drawString(I18n.format("betterquesting.gui.selection"), guiLeft + 24, guiTop + 36, getTextColor(), false);
this.fontRenderer.drawString("x", guiLeft + 65, guiTop + 52, getTextColor(), false);
this.mc.renderEngine.bindTexture(currentTheme().getGuiTexture());
GlStateManager.pushMatrix();
GlStateManager.scale(2F, 2F, 1F);
GlStateManager.color(1F, 1F, 1F, 1F);
this.drawTexturedModalRect((guiLeft + 24) / 2, (guiTop + 48) / 2, 0, 48, 18, 18);
if (this.stackSelect != null) {
GlStateManager.enableDepth();
RenderUtils.RenderItemStack(this.mc, this.stackSelect.getBaseStack(), (guiLeft + 26) / 2, (guiTop + 50) / 2, "");
GlStateManager.disableDepth();
if (this.isWithin(mx, my, 25, 49, 32, 32)) {
ttStack = this.stackSelect;
}
}
GlStateManager.popMatrix();
fontRenderer.drawString(I18n.format("container.inventory"), this.guiLeft + 24, this.guiTop + sizeY / 2 - 12, getTextColor(), false);
GlStateManager.color(1F, 1F, 1F, 1F);
if (this.mc.player != null) {
NonNullList<ItemStack> invoStacks = this.mc.player.inventory.mainInventory;
int isx = (18 * 9);
int isy = (18 * 4);
float scale = Math.min((btnWidth - 16) / (float) isx, (sizeY / 2F - 32) / isy);
int ipx = guiLeft + 16 + btnWidth / 2 - (int) (isx / 2 * scale);
int ipy = guiTop + sizeY / 2;
GlStateManager.pushMatrix();
GlStateManager.translate(ipx, ipy, 0F);
GlStateManager.scale(scale, scale, 1F);
for (// Intentionally limited to vanilla size for UI neatness
int i = 0; // Intentionally limited to vanilla size for UI neatness
i < invoStacks.size() && i < 9 * 4; // Intentionally limited to vanilla size for UI neatness
i++) {
int x = i % 9 * 18;
int y = (i - i % 9) / 9 * 18;
this.mc.renderEngine.bindTexture(currentTheme().getGuiTexture());
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.disableDepth();
this.drawTexturedModalRect(x, y, 0, 48, 18, 18);
GlStateManager.enableDepth();
ItemStack stack = invoStacks.get(i);
if (stack != null) {
RenderUtils.RenderItemStack(mc, stack, x + 1, y + 1, "" + (stack.getCount() > 1 ? stack.getCount() : ""));
if (isWithin(mx, my, ipx + (int) ((x + 1) * scale), ipy + (int) ((y + 1) * scale), (int) (16 * scale), (int) (16 * scale), false)) {
ttStack = new BigItemStack(stack);
}
}
}
GlStateManager.popMatrix();
}
RenderUtils.DrawLine(width / 2, guiTop + 32, width / 2, guiTop + sizeY - 32, 2F, getTextColor());
this.searchBox.drawTextBox(mx, my, partialTick);
this.numberBox.drawTextBox();
}
use of betterquesting.api.utils.BigItemStack in project BetterQuesting by Funwayguy.
the class PlaceholderConverter method convertItem.
public static BigItemStack convertItem(Item item, String name, int count, int damage, String oreDict, NBTTagCompound nbt) {
if (item == null) {
BigItemStack stack = new BigItemStack(ItemPlaceholder.placeholder, count, damage);
stack.oreDict = oreDict;
stack.SetTagCompound(new NBTTagCompound());
stack.GetTagCompound().setString("orig_id", name);
stack.GetTagCompound().setInteger("orig_meta", damage);
if (nbt != null) {
stack.GetTagCompound().setTag("orig_tag", nbt);
}
return stack;
} else if (item == ItemPlaceholder.placeholder) {
if (nbt != null) {
Item restored = (Item) Item.REGISTRY.getObject(new ResourceLocation(nbt.getString("orig_id")));
if (restored != null) {
BigItemStack stack = new BigItemStack(restored, count, nbt.hasKey("orig_meta") ? nbt.getInteger("orig_meta") : damage);
stack.oreDict = oreDict;
if (nbt.hasKey("orig_tag")) {
stack.SetTagCompound(nbt.getCompoundTag("orig_tag"));
}
return stack;
} else if (damage > 0 && !nbt.hasKey("orig_meta")) {
nbt.setInteger("orig_meta", damage);
damage = 0;
}
}
}
BigItemStack stack = new BigItemStack(item, count, damage);
stack.oreDict = oreDict;
if (nbt != null) {
stack.SetTagCompound(nbt);
}
return stack;
}
Aggregations