Search in sources :

Example 1 with GristType

use of com.mraof.minestuck.util.GristType 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 GristType

use of com.mraof.minestuck.util.GristType 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 GristType

use of com.mraof.minestuck.util.GristType 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 GristType

use of com.mraof.minestuck.util.GristType 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)

Example 5 with GristType

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

the class ItemMinestuckCandy method updateCandy.

public void updateCandy() {
    for (GristType type : GristType.REGISTRY.getValues()) {
        // Perhaps change build to 0.1 or 0.05
        float saturationModifier = type == GristType.Build ? 0.0F : 0.6F - type.getRarity();
        String name = type.getName();
        candyMap.put(type.getId() + 1, new Candy(2, saturationModifier, name.substring(0, 1).toUpperCase() + name.substring(1)));
    }
}
Also used : GristType(com.mraof.minestuck.util.GristType)

Aggregations

GristType (com.mraof.minestuck.util.GristType)10 GristSet (com.mraof.minestuck.util.GristSet)8 ItemStack (net.minecraft.item.ItemStack)4 Block (net.minecraft.block.Block)3 Item (net.minecraft.item.Item)3 GristAmount (com.mraof.minestuck.util.GristAmount)2 MinestuckPacket (com.mraof.minestuck.network.MinestuckPacket)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ResourceLocation (net.minecraft.util.ResourceLocation)1