use of com.mraof.minestuck.util.GristAmount in project Minestuck by mraof.
the class GuiUtil method drawGristBoard.
public static void drawGristBoard(GristSet grist, GristboardMode mode, int boardX, int boardY, FontRenderer fontRenderer) {
if (grist == null) {
fontRenderer.drawString(I18n.format("gui.notAlchemizable"), 9, 45, 16711680);
return;
}
if (grist.isEmpty()) {
fontRenderer.drawString(I18n.format("gui.free"), 9, 45, 65280);
return;
}
GristSet playerGrist = MinestuckPlayerData.getClientGrist();
Iterator<GristAmount> it = grist.getArray().iterator();
if (!MinestuckConfig.alchemyIcons) {
int place = 0;
while (it.hasNext()) {
GristAmount amount = it.next();
GristType type = amount.getType();
int need = amount.getAmount();
int have = playerGrist.getGrist(type);
int row = place % 3;
int col = place / 3;
int color = getGristColor(mode, need <= have);
String needStr = addSuffix(need), haveStr = addSuffix(have);
fontRenderer.drawString(needStr + " " + type.getDisplayName() + " (" + haveStr + ")", boardX + GRIST_BOARD_WIDTH / 2 * col, boardY + GRIST_BOARD_HEIGHT / 3 * row, color);
place++;
}
} else {
int index = 0;
while (it.hasNext()) {
GristAmount amount = it.next();
GristType type = amount.getType();
int need = amount.getAmount();
int have = playerGrist.getGrist(type);
int row = index / GRIST_BOARD_WIDTH;
int color = getGristColor(mode, need <= have);
String needStr = addSuffix(need), haveStr = '(' + addSuffix(have) + ')';
int needStrWidth = fontRenderer.getStringWidth(needStr);
if (index + needStrWidth + 10 + fontRenderer.getStringWidth(haveStr) > (row + 1) * GRIST_BOARD_WIDTH) {
row++;
index = row * GRIST_BOARD_WIDTH;
}
fontRenderer.drawString(needStr, boardX + 1 + index % GRIST_BOARD_WIDTH, boardY + 8 * row, color);
fontRenderer.drawString(haveStr, boardX + needStrWidth + 10 + index % GRIST_BOARD_WIDTH, boardY + 8 * row, color);
GlStateManager.color(1, 1, 1);
GlStateManager.disableLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(type.getIcon().getResourceDomain(), "textures/grist/" + type.getIcon().getResourcePath() + ".png"));
Gui.drawModalRectWithCustomSizedTexture(boardX + needStrWidth + 1 + index % GRIST_BOARD_WIDTH, boardY + 8 * row, 0, 0, 8, 8, 8, 8);
index += needStrWidth + 10 + fontRenderer.getStringWidth(haveStr);
index = Math.min(index + 6, (row + 1) * 158);
}
}
}
use of com.mraof.minestuck.util.GristAmount in project Minestuck by mraof.
the class GuiUtil method getGristboardTooltip.
public static List<String> getGristboardTooltip(GristSet grist, int mouseX, int mouseY, int boardX, int boardY, FontRenderer fontRenderer) {
if (grist == null || grist.isEmpty())
return null;
mouseX -= boardX;
mouseY -= boardY;
GristSet playerGrist = MinestuckPlayerData.getClientGrist();
if (!MinestuckConfig.alchemyIcons) {
int place = 0;
for (GristAmount entry : grist.getArray()) {
int row = place % 3;
int col = place / 3;
if (mouseY >= 8 * row && mouseY < 8 * row + 8) {
int need = entry.getAmount();
String needStr = addSuffix(need);
if (!needStr.equals(String.valueOf(need)) && mouseX >= GRIST_BOARD_WIDTH / 2 * col && mouseX < GRIST_BOARD_WIDTH / 2 * col + fontRenderer.getStringWidth(needStr))
return Collections.singletonList(String.valueOf(need));
int width = fontRenderer.getStringWidth(needStr + " " + entry.getType().getDisplayName() + " (");
int have = playerGrist.getGrist(entry.getType());
String haveStr = addSuffix(have);
if (!haveStr.equals(String.valueOf(have)) && mouseX >= boardX + GRIST_BOARD_WIDTH / 2 * col + width && mouseX < boardX + GRIST_BOARD_WIDTH / 2 * col + width + fontRenderer.getStringWidth(haveStr))
return Collections.singletonList(String.valueOf(have));
}
place++;
}
} else {
int index = 0;
for (GristAmount entry : grist.getArray()) {
GristType type = entry.getType();
int need = entry.getAmount();
int have = playerGrist.getGrist(type);
int row = index / GRIST_BOARD_WIDTH;
String needStr = addSuffix(need), haveStr = addSuffix(have);
int needStrWidth = fontRenderer.getStringWidth(needStr);
int haveStrWidth = fontRenderer.getStringWidth('(' + haveStr + ')');
if (index + needStrWidth + 10 + haveStrWidth > (row + 1) * GRIST_BOARD_WIDTH) {
row++;
index = row * GRIST_BOARD_WIDTH;
}
if (mouseY >= 8 * row && mouseY < 8 * row + 8) {
if (!needStr.equals(String.valueOf(need)) && mouseX >= index % GRIST_BOARD_WIDTH && mouseX < index % GRIST_BOARD_WIDTH + needStrWidth)
return Collections.singletonList(String.valueOf(need));
else if (mouseX >= index % 158 + needStrWidth + 1 && mouseX < index % 158 + needStrWidth + 9)
return Collections.singletonList(type.getDisplayName());
else if (!haveStr.equals(String.valueOf(have)) && mouseX >= index % 158 + needStrWidth + 10 + fontRenderer.getCharWidth('(') && mouseX < index % 158 + needStrWidth + 10 + fontRenderer.getStringWidth("(" + haveStr))
return Collections.singletonList(String.valueOf(have));
}
index += needStrWidth + 10 + haveStrWidth;
index = Math.min(index + 6, (row + 1) * GRIST_BOARD_WIDTH);
}
}
return null;
}
use of com.mraof.minestuck.util.GristAmount in project Minestuck by mraof.
the class GuiSburbMachine method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRenderer.drawString(I18n.format("gui." + guis[type.ordinal()] + ".name"), 8, 6, 4210752);
// draws "Inventory" or your regional equivalent
fontRenderer.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 4210752);
if (type == MachineType.ALCHEMITER && !te.getStackInSlot(0).isEmpty()) {
// Render grist requirements
ItemStack stack = AlchemyRecipeHandler.getDecodedItem(te.getStackInSlot(0));
if (type == MachineType.ALCHEMITER && !(te.getStackInSlot(0).hasTagCompound() && te.getStackInSlot(0).getTagCompound().hasKey("contentID")))
stack = new ItemStack(MinestuckBlocks.genericObject);
GristSet set = GristRegistry.getGristConversion(stack);
boolean useSelectedType = stack.getItem() == MinestuckItems.captchaCard;
if (useSelectedType)
set = new GristSet(te.selectedGrist, MinestuckConfig.clientCardCost);
if (set != null && stack.isItemDamaged()) {
float multiplier = 1 - stack.getItem().getDamage(stack) / ((float) stack.getMaxDamage());
for (GristAmount amount : set.getArray()) {
if (type == MachineType.ALCHEMITER) {
set.setGrist(amount.getType(), (int) Math.ceil(amount.getAmount() * multiplier));
} else {
set.setGrist(amount.getType(), (int) (amount.getAmount() * multiplier));
}
}
}
GuiUtil.drawGristBoard(set, useSelectedType ? GuiUtil.GristboardMode.ALCHEMITER_SELECT : GuiUtil.GristboardMode.ALCHEMITER, 9, 45, fontRenderer);
List<String> tooltip = GuiUtil.getGristboardTooltip(set, mouseX - this.guiLeft, mouseY - this.guiTop, 9, 45, fontRenderer);
if (tooltip != null)
this.drawHoveringText(tooltip, mouseX - this.guiLeft, mouseY - this.guiTop, fontRenderer);
}
}
use of com.mraof.minestuck.util.GristAmount in project Minestuck by mraof.
the class EntityUnderling method onDeathUpdate.
@Override
protected void onDeathUpdate() {
super.onDeathUpdate();
if (this.deathTime == 20 && !this.world.isRemote) {
GristSet grist = this.getGristSpoils();
if (fromSpawner)
grist.scaleGrist(0.5F);
if (!dropCandy) {
for (GristAmount gristType : grist.getArray()) this.world.spawnEntity(new EntityGrist(world, randX(), this.posY, randZ(), gristType));
} else {
for (GristAmount gristType : grist.getArray()) {
int candy = (gristType.getAmount() + 2) / 4;
int gristAmount = gristType.getAmount() - candy * 2;
if (candy > 0)
this.world.spawnEntity(new EntityItem(world, randX(), this.posY, randZ(), new ItemStack(MinestuckItems.candy, candy, gristType.getType().getId() + 1)));
if (gristAmount > 0)
this.world.spawnEntity(new EntityGrist(world, randX(), this.posY, randZ(), new GristAmount(gristType.getType(), gristAmount)));
}
}
if (this.rand.nextInt(4) == 0)
this.world.spawnEntity(new EntityVitalityGel(world, randX(), this.posY, randZ(), this.getVitalityGel()));
}
}
use of com.mraof.minestuck.util.GristAmount in project Minestuck by mraof.
the class GuiCrockerMachine method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRenderer.drawString(I18n.format("gui." + guis[type.ordinal()] + ".name"), 8, 6, 0xFFFFFF);
// draws "Inventory" or your regional equivalent
fontRenderer.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 0xFFFFFF);
if (type == MachineType.GRIST_WIDGET && !te.getStackInSlot(0).isEmpty()) {
// Render grist requirements
ItemStack stack = AlchemyRecipeHandler.getDecodedItem(te.getStackInSlot(0));
GristSet set = GristRegistry.getGristConversion(stack);
if (set != null) {
float multiplier = stack.getCount();
if (multiplier != 1) {
set = set.scaleGrist(multiplier);
}
set.scaleGrist(0.9F);
}
if (set != null && stack.isItemDamaged()) {
float multiplier = 1 - stack.getItem().getDamage(stack) / ((float) stack.getMaxDamage());
for (GristAmount amount : set.getArray()) {
set.setGrist(amount.getType(), (int) (amount.getAmount() * multiplier));
}
}
GuiUtil.drawGristBoard(set, GuiUtil.GristboardMode.GRIST_WIDGET, 9, 45, fontRenderer);
List<String> tooltip = GuiUtil.getGristboardTooltip(set, mouseX - this.guiLeft, mouseY - this.guiTop, 9, 45, fontRenderer);
if (tooltip != null)
this.drawHoveringText(tooltip, mouseX - this.guiLeft, mouseY - this.guiTop, fontRenderer);
}
}
Aggregations