use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.
the class Alchemy method setOreDictCost.
@ZenMethod
public static void setOreDictCost(String name, String cost) {
GristSet grist = getGrist(cost);
if (grist == null)
return;
recipes.add(new SetCost(name, OreDictionary.WILDCARD_VALUE, grist));
}
use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.
the class Alchemy method getGrist.
private static GristSet getGrist(String str) {
if (str == null)
return null;
GristSet grist = new GristSet();
String[] values = str.split(",");
for (String value : values) {
value = value.trim();
String[] gristAmount = value.split("\\s+");
if (gristAmount.length == 2) {
if (GristType.getTypeFromString(gristAmount[0].toLowerCase()) != null)
grist.addGrist(GristType.getTypeFromString(gristAmount[0].toLowerCase()), Integer.parseInt(gristAmount[1]));
else {
CraftTweakerAPI.logError("\"" + gristAmount[0].toLowerCase() + "\" does not match any grist types. Look for typos and make sure the grist type is actually in the mod.");
return null;
}
} else {
CraftTweakerAPI.logError("\"" + value + "\" is not an acceptable grist value. Separate grist-number pairings with commas.");
return null;
}
}
return grist;
}
use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.
the class Alchemy method setCost.
@ZenMethod
public static void setCost(IItemStack iStack, String cost) {
ItemStack stack = (ItemStack) iStack.getInternal();
GristSet grist = getGrist(cost);
if (grist == null)
return;
recipes.add(new SetCost(stack.getItem(), stack.getItemDamage(), grist));
}
use of com.mraof.minestuck.util.GristSet 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.GristSet in project Minestuck by mraof.
the class GristCachePacket method consumePacket.
@Override
public MinestuckPacket consumePacket(ByteBuf data) {
values = new GristSet();
int length = data.readInt();
for (int i = 0; i < length; i++) {
values.setGrist(GristType.REGISTRY.getValue(data.readInt()), data.readInt());
}
targetGrist = data.readBoolean();
return this;
}
Aggregations