Search in sources :

Example 1 with GristSet

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

Example 2 with GristSet

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

Example 3 with GristSet

use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.

the class ExtraUtilitiesSupport method registerRecipes.

@Override
public void registerRecipes() throws Exception {
    if (Class.forName("com.rwtema.extrautils.ExtraUtils").getField("bedrockiumEnabled").getBoolean(null)) {
        Item bedrockium = ((Item) Class.forName("com.rwtema.extrautils.ExtraUtils").getField("bedrockium").get(null));
        GristRegistry.addGristConversion(new ItemStack(bedrockium), new GristSet(GristType.Zillium, 1));
    }
    if (Class.forName("com.rwtema.extrautils.ExtraUtils").getField("enderLilyEnabled").getBoolean(null)) {
        Block enderLily = ((Block) Class.forName("com.rwtema.extrautils.ExtraUtils").getField("enderLily").get(null));
        GristRegistry.addGristConversion(new ItemStack(enderLily), new GristSet(new GristType[] { GristType.Uranium, GristType.Iodine }, new int[] { 24, 6 }));
        CombinationRegistry.addCombination(new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.ENDER_PEARL), CombinationRegistry.MODE_OR, new ItemStack(enderLily));
        // Might as well do this too
        CombinationRegistry.addCombination(new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.ENDER_EYE), CombinationRegistry.MODE_OR, new ItemStack(enderLily));
    }
    if (Class.forName("com.rwtema.extrautils.ExtraUtils").getField("transferPipeEnabled").getBoolean(null)) {
        Block transferPipe = ((Block) Class.forName("com.rwtema.extrautils.ExtraUtils").getField("transferPipe").get(null));
        GristRegistry.addGristConversion(new ItemStack(transferPipe), new GristSet(new GristType[] { GristType.Build, GristType.Garnet }, new int[] { 1, 1 }));
    }
}
Also used : Item(net.minecraft.item.Item) GristSet(com.mraof.minestuck.util.GristSet) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) GristType(com.mraof.minestuck.util.GristType)

Example 4 with GristSet

use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.

the class Minegicka3Support method registerDynamicRecipes.

@Override
public void registerDynamicRecipes() throws Exception {
    Debug.debug("Adding minegicka 3 recipes...");
    Map<Integer, Object> recipes = ((Map<Integer, Object>) (Class.forName("com.williameze.minegicka3.mechanics.ClickCraft").getField("recipes").get(null)));
    recipes: for (Entry<Integer, Object> entry : (Set<Entry<Integer, Object>>) recipes.entrySet()) {
        List<Entry<ItemStack, Integer>> input = (List<Entry<ItemStack, Integer>>) entry.getValue().getClass().getField("input").get(entry.getValue());
        ItemStack output = (ItemStack) entry.getValue().getClass().getField("output").get(entry.getValue());
        if (GristRegistry.getGristConversion(output) == null) {
            GristSet cost = new GristSet();
            for (Entry<ItemStack, Integer> ingredient : input) {
                GristSet set = GristRegistry.getGristConversion(ingredient.getKey());
                if (set != null) {
                    set = set.scaleGrist(ingredient.getValue());
                    cost.addGrist(set);
                } else
                    continue recipes;
            }
            if (!cost.isEmpty())
                GristRegistry.addGristConversion(output, cost);
        }
    }
}
Also used : Entry(java.util.Map.Entry) GristSet(com.mraof.minestuck.util.GristSet) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 5 with GristSet

use of com.mraof.minestuck.util.GristSet in project Minestuck by mraof.

the class NeverSayNetherSupport method registerRecipes.

@Override
public void registerRecipes() throws Exception {
    Item dust = ((Item) (Class.forName("com.debbie.nsn.items.ModItems").getField("daedalean_dustItem").get(null)));
    Item quartz = ((Item) (Class.forName("com.debbie.nsn.items.ModItems").getField("daedalean_quartzItem").get(null)));
    Block ore = ((Block) (Class.forName("com.debbie.nsn.blocks.ModBlocks").getField("daedalean_oreBlock").get(null)));
    GristRegistry.addGristConversion(new ItemStack(dust), new GristSet(GristType.Build, 1));
    GristRegistry.addGristConversion(new ItemStack(quartz), new GristSet(new GristType[] { GristType.Build, GristType.Quartz }, new int[] { 1, 1 }));
    GristRegistry.addGristConversion(ore, new GristSet(GristType.Build, 5));
}
Also used : Item(net.minecraft.item.Item) GristSet(com.mraof.minestuck.util.GristSet) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) GristType(com.mraof.minestuck.util.GristType)

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