Search in sources :

Example 6 with IAlleleFruit

use of forestry.api.arboriculture.IAlleleFruit in project ForestryMC by ForestryMC.

the class FruitPodStateMapper method putStateModelLocations.

@Override
public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block block) {
    if (block instanceof BlockFruitPod) {
        BlockFruitPod blockFruitPod = (BlockFruitPod) block;
        IAlleleFruit fruit = blockFruitPod.getFruit();
        String modID = fruit.getModID();
        if (modID == null) {
            modID = Constants.MOD_ID;
        }
        String modelName = fruit.getModelName();
        String resourcePath = modID + ":pods/" + modelName;
        for (IBlockState state : block.getBlockState().getValidStates()) {
            String propertyString = getPropertyString(state.getProperties());
            mapStateModelLocations.put(state, new ModelResourceLocation(resourcePath, propertyString));
        }
    }
    return mapStateModelLocations;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) BlockFruitPod(forestry.arboriculture.blocks.BlockFruitPod)

Example 7 with IAlleleFruit

use of forestry.api.arboriculture.IAlleleFruit in project ForestryMC by ForestryMC.

the class ModuleArboriculture method registerSprites.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerSprites(TextureStitchEvent.Pre event) {
    TextureLeaves.registerAllSprites();
    WoodTextureManager.parseFile();
    for (IAlleleFruit alleleFruit : AlleleFruits.getFruitAlleles()) {
        alleleFruit.getProvider().registerSprites();
    }
    List<ResourceLocation> textures = new ArrayList<>();
    for (IWoodType type : TreeManager.woodAccess.getRegisteredWoodTypes()) {
        textures.add(new ResourceLocation(type.getHeartTexture()));
        textures.add(new ResourceLocation(type.getBarkTexture()));
        textures.add(new ResourceLocation(type.getDoorLowerTexture()));
        textures.add(new ResourceLocation(type.getDoorUpperTexture()));
        textures.add(new ResourceLocation(type.getPlankTexture()));
        for (WoodBlockKind kind : WoodBlockKind.values()) {
            for (Entry<String, String> loc : WoodTextureManager.getTextures(type, kind).entrySet()) {
                textures.add(new ResourceLocation(loc.getValue()));
            }
        }
    }
    for (ResourceLocation loc : textures) {
        TextureManagerForestry.registerSprite(loc);
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with IAlleleFruit

use of forestry.api.arboriculture.IAlleleFruit in project ForestryMC by ForestryMC.

the class TreeAlyzerPlugin method drawAnalyticsPage2.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage2(GuiScreen gui, ItemStack itemStack) {
    if (gui instanceof GuiAlyzer) {
        GuiAlyzer guiAlyzer = (GuiAlyzer) gui;
        ITree tree = TreeManager.treeRoot.getMember(itemStack);
        if (tree == null) {
            return;
        }
        TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
        textLayout.startPage(GuiAlyzer.COLUMN_0, GuiAlyzer.COLUMN_1, GuiAlyzer.COLUMN_2);
        int speciesDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getPrimary().isDominant());
        int speciesDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getSecondary().isDominant());
        textLayout.drawLine(Translator.translateToLocal("for.gui.active"), GuiAlyzer.COLUMN_1);
        textLayout.drawLine(Translator.translateToLocal("for.gui.inactive"), GuiAlyzer.COLUMN_2);
        textLayout.newLine();
        textLayout.newLine();
        String yes = Translator.translateToLocal("for.yes");
        String no = Translator.translateToLocal("for.no");
        String fireproofActive = StringUtil.readableBoolean(tree.getGenome().getFireproof(), yes, no);
        String fireproofInactive = StringUtil.readableBoolean(((AlleleBoolean) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF)).getValue(), yes, no);
        guiAlyzer.drawRow(Translator.translateToLocal("for.gui.fireproof"), fireproofActive, fireproofInactive, tree, EnumTreeChromosome.FIREPROOF);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.native"), GuiAlyzer.COLUMN_0);
        textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1, speciesDominance0);
        textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2, speciesDominance1);
        textLayout.newLine();
        // FRUITS
        textLayout.drawLine(Translator.translateToLocal("for.gui.supports"), GuiAlyzer.COLUMN_0);
        List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
        List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
        int max = Math.max(families0.size(), families1.size());
        for (int i = 0; i < max; i++) {
            if (i > 0) {
                textLayout.newLineCompressed();
            }
            if (families0.size() > i) {
                textLayout.drawLine(families0.get(i).getName(), GuiAlyzer.COLUMN_1, speciesDominance0);
            }
            if (families1.size() > i) {
                textLayout.drawLine(families1.get(i).getName(), GuiAlyzer.COLUMN_2, speciesDominance1);
            }
        }
        textLayout.newLine();
        int fruitDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
        int fruitDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant());
        textLayout.drawLine(Translator.translateToLocal("for.gui.fruits"), GuiAlyzer.COLUMN_0);
        String strike = "";
        IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS);
        if (!tree.canBearFruit() && fruit0 != AlleleFruits.fruitNone) {
            strike = TextFormatting.STRIKETHROUGH.toString();
        }
        textLayout.drawLine(strike + tree.getGenome().getFruitProvider().getDescription(), GuiAlyzer.COLUMN_1, fruitDominance0);
        strike = "";
        IAlleleFruit fruit1 = (IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS);
        if (!tree.getGenome().getSecondary().getSuitableFruit().contains(fruit1.getProvider().getFamily()) && fruit1 != AlleleFruits.fruitNone) {
            strike = TextFormatting.STRIKETHROUGH.toString();
        }
        textLayout.drawLine(strike + fruit1.getProvider().getDescription(), GuiAlyzer.COLUMN_2, fruitDominance1);
        textLayout.newLine();
        textLayout.drawLine(Translator.translateToLocal("for.gui.family"), GuiAlyzer.COLUMN_0);
        IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily();
        IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily();
        if (primary != null && !primary.getUID().equals(EnumFruitFamily.NONE.getUID())) {
            textLayout.drawLine(primary.getName(), GuiAlyzer.COLUMN_1, fruitDominance0);
        }
        if (secondary != null && !secondary.getUID().equals(EnumFruitFamily.NONE.getUID())) {
            textLayout.drawLine(secondary.getName(), GuiAlyzer.COLUMN_2, fruitDominance1);
        }
        textLayout.endPage();
    }
}
Also used : TextLayoutHelper(forestry.core.gui.TextLayoutHelper) IAllele(forestry.api.genetics.IAllele) IFruitFamily(forestry.api.genetics.IFruitFamily) ArrayList(java.util.ArrayList) ITree(forestry.api.arboriculture.ITree) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit) GuiAlyzer(forestry.core.gui.GuiAlyzer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with IAlleleFruit

use of forestry.api.arboriculture.IAlleleFruit in project ForestryMC by ForestryMC.

the class BlockFruitPod method create.

public static List<BlockFruitPod> create() {
    List<BlockFruitPod> blocks = new ArrayList<>();
    for (IAlleleFruit fruit : AlleleFruits.getFruitAllelesWithModels()) {
        BlockFruitPod block = new BlockFruitPod(fruit);
        blocks.add(block);
    }
    return blocks;
}
Also used : ArrayList(java.util.ArrayList) IAlleleFruit(forestry.api.arboriculture.IAlleleFruit)

Aggregations

IAlleleFruit (forestry.api.arboriculture.IAlleleFruit)9 IAllele (forestry.api.genetics.IAllele)4 ArrayList (java.util.ArrayList)4 ITree (forestry.api.arboriculture.ITree)2 IFruitFamily (forestry.api.genetics.IFruitFamily)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IAlleleTreeSpecies (forestry.api.arboriculture.IAlleleTreeSpecies)1 IFruitProvider (forestry.api.arboriculture.IFruitProvider)1 IWoodType (forestry.api.arboriculture.IWoodType)1 WoodBlockKind (forestry.api.arboriculture.WoodBlockKind)1 IAlleleInteger (forestry.api.genetics.IAlleleInteger)1 BlockFruitPod (forestry.arboriculture.blocks.BlockFruitPod)1 GuiAlyzer (forestry.core.gui.GuiAlyzer)1 TextLayoutHelper (forestry.core.gui.TextLayoutHelper)1 Collection (java.util.Collection)1 IBlockState (net.minecraft.block.state.IBlockState)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1