Search in sources :

Example 6 with GristSet

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));
}
Also used : GristSet(com.mraof.minestuck.util.GristSet) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 7 with GristSet

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;
}
Also used : GristSet(com.mraof.minestuck.util.GristSet)

Example 8 with GristSet

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));
}
Also used : GristSet(com.mraof.minestuck.util.GristSet) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 9 with GristSet

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);
    }
}
Also used : GristSet(com.mraof.minestuck.util.GristSet) GristAmount(com.mraof.minestuck.util.GristAmount) ItemStack(net.minecraft.item.ItemStack)

Example 10 with GristSet

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;
}
Also used : GristSet(com.mraof.minestuck.util.GristSet)

Aggregations

GristSet (com.mraof.minestuck.util.GristSet)18 ItemStack (net.minecraft.item.ItemStack)11 GristType (com.mraof.minestuck.util.GristType)8 GristAmount (com.mraof.minestuck.util.GristAmount)5 Block (net.minecraft.block.Block)3 Item (net.minecraft.item.Item)3 List (java.util.List)2 Map (java.util.Map)2 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)2 EntityGrist (com.mraof.minestuck.entity.item.EntityGrist)1 EntityVitalityGel (com.mraof.minestuck.entity.item.EntityVitalityGel)1 IItemStack (crafttweaker.api.item.IItemStack)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ResourceLocation (net.minecraft.util.ResourceLocation)1