Search in sources :

Example 1 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class ModuleWood method registerItemsAndBlocks.

@Override
public void registerItemsAndBlocks() {
    MinecraftForge.EVENT_BUS.register(this);
    WoodAccess woodAccess = WoodAccess.getInstance();
    registerPlanks();
    logs = BlockETLog.create(false);
    logsFireproof = BlockETLog.create(true);
    for (BlockETLog block : logs) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
    }
    logsFireproof = BlockETLog.create(true);
    for (BlockETLog block : logsFireproof) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
    }
    woodAccess.registerLogs(logs);
    woodAccess.registerLogs(logsFireproof);
    planks = BlockETPlank.create(false);
    for (BlockETPlank block : planks) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
    }
    planksFireproof = BlockETPlank.create(true);
    for (BlockETPlank block : planksFireproof) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
    }
    woodAccess.registerPlanks(planks);
    woodAccess.registerPlanks(planksFireproof);
    slabs = BlockETSlab.create(false, false);
    slabsDouble = BlockETSlab.create(false, true);
    for (int i = 0; i < slabs.size(); i++) {
        BlockETSlab slab = slabs.get(i);
        BlockETSlab slabDouble = slabsDouble.get(i);
        ExtraTrees.proxy.registerBlock(slab, new ItemETSlab(slab, slab, slabDouble));
        ExtraTrees.proxy.registerBlock(slabDouble, new ItemETSlab(slabDouble, slab, slabDouble));
        registerOreDictWildcard(OreDictUtil.SLAB_WOOD, slab);
    }
    slabsFireproof = BlockETSlab.create(true, false);
    slabsDoubleFireproof = BlockETSlab.create(true, true);
    for (int i = 0; i < slabsFireproof.size(); i++) {
        BlockETSlab slab = slabsFireproof.get(i);
        BlockETSlab slabDouble = slabsDoubleFireproof.get(i);
        ExtraTrees.proxy.registerBlock(slab, new ItemETSlab(slab, slab, slabDouble));
        ExtraTrees.proxy.registerBlock(slabDouble, new ItemETSlab(slabDouble, slab, slabDouble));
        registerOreDictWildcard(OreDictUtil.SLAB_WOOD, slab);
    }
    woodAccess.registerSlabs(slabs);
    woodAccess.registerSlabs(slabsFireproof);
    stairs = new ArrayList<>();
    for (BlockETPlank plank : planks) {
        for (IBlockState blockState : plank.getBlockState().getValidStates()) {
            int meta = plank.getMetaFromState(blockState);
            EnumETLog woodType = plank.getWoodType(meta);
            BlockForestryStairs<EnumETLog> stair = new BlockForestryStairs<>(false, blockState, woodType);
            String name = "stairs." + woodType;
            stair.setRegistryName(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, name));
            stair.setUnlocalizedName(name);
            ExtraTrees.proxy.registerBlock(stair, new ItemBlockETWood<>(stair));
            stairs.add(stair);
            registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
        }
    }
    stairsFireproof = new ArrayList<>();
    for (BlockETPlank plank : planksFireproof) {
        for (IBlockState blockState : plank.getBlockState().getValidStates()) {
            int meta = plank.getMetaFromState(blockState);
            EnumETLog woodType = plank.getWoodType(meta);
            BlockForestryStairs<EnumETLog> stair = new BlockForestryStairs<>(true, blockState, woodType);
            String name = "stairs.fireproof." + woodType;
            stair.setRegistryName(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, name));
            stair.setUnlocalizedName(name);
            ExtraTrees.proxy.registerBlock(stair, new ItemBlockETWood<>(stair));
            stairsFireproof.add(stair);
            registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
        }
    }
    woodAccess.registerStairs(stairs);
    woodAccess.registerStairs(stairsFireproof);
    fences = BlockETFence.create(false);
    for (BlockETFence block : fences) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
        FMLInterModComms.sendMessage("forestry", "add-fence-block", block.getRegistryName().toString());
    }
    fencesFireproof = BlockETFence.create(true);
    for (BlockETFence block : fencesFireproof) {
        ExtraTrees.proxy.registerBlock(block, new ItemBlockETWood<>(block));
        registerOreDictWildcard(OreDictUtil.FENCE_WOOD, block);
        FMLInterModComms.sendMessage("forestry", "add-fence-block", block.getRegistryName().toString());
    }
    woodAccess.registerFences(fences);
    woodAccess.registerFences(fencesFireproof);
    fenceGates = new ArrayList<>();
    fenceGatesFireproof = new ArrayList<>();
    for (ExtraTreePlanks plankType : ExtraTreePlanks.VALUES) {
        EnumETLog woodType = plankType.getWoodType();
        BlockForestryFenceGate<EnumETLog> fenceGate = new BlockForestryFenceGate<>(false, woodType);
        String name = "fence.gates." + woodType;
        fenceGate.setRegistryName(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, name));
        fenceGate.setUnlocalizedName(name);
        ExtraTrees.proxy.registerBlock(fenceGate, new ItemBlockETWood<>(fenceGate));
        registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGate);
        fenceGates.add(fenceGate);
        FMLInterModComms.sendMessage("forestry", "add-fence-block", fenceGate.getRegistryName().toString());
        BlockForestryFenceGate<EnumETLog> fenceGateFireproof = new BlockForestryFenceGate<>(true, woodType);
        String nameFireproof = "fence.gates.fireproof." + woodType;
        fenceGateFireproof.setRegistryName(new ResourceLocation(Constants.EXTRA_TREES_MOD_ID, nameFireproof));
        fenceGateFireproof.setUnlocalizedName(nameFireproof);
        ExtraTrees.proxy.registerBlock(fenceGateFireproof, new ItemBlockETWood<>(fenceGateFireproof));
        registerOreDictWildcard(OreDictUtil.FENCE_GATE_WOOD, fenceGateFireproof);
        fenceGatesFireproof.add(fenceGateFireproof);
        FMLInterModComms.sendMessage("forestry", "add-fence-block", fenceGateFireproof.getRegistryName().toString());
    }
    // Forestry's API doesn't allow typed lists to be registered, but making a new one allows us to get away with it
    woodAccess.registerFenceGates(new ArrayList<>(fenceGates));
    woodAccess.registerFenceGates(new ArrayList<>(fenceGatesFireproof));
    doors = new ArrayList<>();
    for (EnumETLog woodType : EnumETLog.VALUES) {
        if (woodType.hasProducts()) {
            BlockETDoor door = new BlockETDoor(woodType);
            ExtraTrees.proxy.registerBlock(door, new ItemBlockETWoodDoor(door));
            registerOreDictWildcard(OreDictUtil.DOOR_WOOD, door);
            doors.add(door);
        }
    }
    registerDoors(woodAccess, doors);
    blockMultiFence = new BlockMultiFence();
    ExtraTrees.proxy.registerBlock(blockMultiFence, new ItemMetadata(blockMultiFence));
    leavesDefault = BlockETDefaultLeaves.create();
    Map speciesToLeavesDefault = ModuleArboriculture.getBlocks().speciesToLeavesDefault;
    for (BlockETDefaultLeaves leaves : leavesDefault) {
        ExtraTrees.proxy.registerBlock(leaves, new ItemBlockLeaves(leaves));
        registerOreDictWildcard(OreDictUtil.TREE_LEAVES, leaves);
        PropertyETType treeType = leaves.getVariant();
        for (ETTreeDefinition treeDefinition : treeType.getAllowedValues()) {
            Preconditions.checkNotNull(treeDefinition);
            String speciesUid = treeDefinition.getUID();
            IBlockState blockState = leaves.getDefaultState().withProperty(treeType, treeDefinition);
            speciesToLeavesDefault.put(speciesUid, blockState);
        }
    }
    leavesDecorative = BlockETDecorativeLeaves.create();
    speciesToLeavesDecorative = new HashMap<>();
    for (BlockETDecorativeLeaves leaves : leavesDecorative) {
        ExtraTrees.proxy.registerBlock(leaves, new ItemBlockETDecorativeLeaves(leaves));
        registerOreDictWildcard(OreDictUtil.TREE_LEAVES, leaves);
        for (IBlockState state : leaves.getBlockState().getValidStates()) {
            ETTreeDefinition treeDefinition = state.getValue(leaves.getVariant());
            String speciesUid = treeDefinition.getUID();
            int meta = leaves.getMetaFromState(state);
            speciesToLeavesDecorative.put(speciesUid, new ItemStack(leaves, 1, meta));
        }
    }
    shrubLog = new BlockShrubLog();
    ExtraTrees.proxy.registerBlock(shrubLog, new ItemBlockETWood<>(shrubLog));
    woodAccess.register(EnumShrubLog.INSTANCE, WoodBlockKind.LOG, false, shrubLog.getStateFromMeta(0), new ItemStack(shrubLog, 1, 0));
    woodAccess.register(EnumShrubLog.INSTANCE, WoodBlockKind.LOG, true, shrubLog.getStateFromMeta(1), new ItemStack(shrubLog, 1, 1));
}
Also used : ExtraTreePlanks(binnie.extratrees.wood.planks.ExtraTreePlanks) BlockETDoor(binnie.extratrees.blocks.wood.BlockETDoor) BlockETSlab(binnie.extratrees.blocks.wood.BlockETSlab) BlockForestryStairs(forestry.arboriculture.blocks.BlockForestryStairs) BlockETDecorativeLeaves(binnie.extratrees.blocks.BlockETDecorativeLeaves) ItemBlockETDecorativeLeaves(binnie.extratrees.items.ItemBlockETDecorativeLeaves) BlockETLog(binnie.extratrees.blocks.wood.BlockETLog) BlockETDefaultLeaves(binnie.extratrees.blocks.BlockETDefaultLeaves) BlockETPlank(binnie.extratrees.blocks.wood.BlockETPlank) ItemBlockETWoodDoor(binnie.extratrees.blocks.wood.ItemBlockETWoodDoor) BlockETFence(binnie.extratrees.blocks.wood.BlockETFence) ItemBlockLeaves(forestry.arboriculture.items.ItemBlockLeaves) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) BlockForestryFenceGate(forestry.arboriculture.blocks.BlockForestryFenceGate) IBlockState(net.minecraft.block.state.IBlockState) ItemBlockETDecorativeLeaves(binnie.extratrees.items.ItemBlockETDecorativeLeaves) BlockMultiFence(binnie.extratrees.blocks.decor.BlockMultiFence) ItemETSlab(binnie.extratrees.blocks.wood.ItemETSlab) WoodAccess(forestry.arboriculture.WoodAccess) IWoodAccess(forestry.api.arboriculture.IWoodAccess) PropertyETType(binnie.extratrees.blocks.property.PropertyETType) ItemMetadata(binnie.core.block.ItemMetadata) BlockShrubLog(binnie.extratrees.blocks.wood.BlockShrubLog) EnumETLog(binnie.extratrees.wood.EnumETLog) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) HashMap(java.util.HashMap) TextureMap(net.minecraft.client.renderer.texture.TextureMap)

Example 2 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class ItemBlockETDecorativeLeaves method getItemStackDisplayName.

@Override
public String getItemStackDisplayName(ItemStack itemStack) {
    int meta = itemStack.getMetadata();
    BlockETDecorativeLeaves block = getBlock();
    ETTreeDefinition treeDefinition = block.getTreeType(meta);
    if (treeDefinition == null || treeDefinition.getGenome() == null) {
        return I18N.localise(ModId.EXTRA_TREES, "grammar.leaves.type");
    }
    String unlocalizedSpeciesName = treeDefinition.getGenome().getPrimary().getUnlocalizedName();
    return ItemBlockLeaves.getDisplayName(unlocalizedSpeciesName);
}
Also used : BlockETDecorativeLeaves(binnie.extratrees.blocks.BlockETDecorativeLeaves) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition)

Example 3 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class ModelDefaultETLeaves method getWorldKey.

@Override
protected ETTreeDefinition getWorldKey(IBlockState state) {
    Block block = state.getBlock();
    Preconditions.checkArgument(block instanceof BlockETDefaultLeaves, "state must be for default leaves.");
    BlockETDefaultLeaves bBlock = (BlockETDefaultLeaves) block;
    ETTreeDefinition treeDefinition = bBlock.getTreeDefinition(state);
    Preconditions.checkNotNull(treeDefinition);
    return treeDefinition;
}
Also used : Block(net.minecraft.block.Block) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) BlockETDefaultLeaves(binnie.extratrees.blocks.BlockETDefaultLeaves)

Example 4 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class BlockETDefaultLeaves method getTree.

@Override
protected ITree getTree(IBlockAccess world, BlockPos pos) {
    IBlockState blockState = world.getBlockState(pos);
    ETTreeDefinition treeDefinition = getTreeDefinition(blockState);
    if (treeDefinition != null) {
        return treeDefinition.getIndividual();
    } else {
        return null;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition)

Example 5 with ETTreeDefinition

use of binnie.extratrees.genetics.ETTreeDefinition in project Binnie by ForestryMC.

the class BlockETDefaultLeaves method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    ETTreeDefinition treeDefinition = getTreeDefinition(state);
    if (treeDefinition == null) {
        treeDefinition = ETTreeDefinition.OrchardApple;
    }
    ITreeGenome genome = treeDefinition.getGenome();
    if (tintIndex == 0) {
        return genome.getPrimary().getLeafSpriteProvider().getColor(false);
    } else {
        IFruitProvider fruitProvider = genome.getFruitProvider();
        return fruitProvider.getDecorativeColor();
    }
}
Also used : ETTreeDefinition(binnie.extratrees.genetics.ETTreeDefinition) ITreeGenome(forestry.api.arboriculture.ITreeGenome) IFruitProvider(forestry.api.arboriculture.IFruitProvider) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ETTreeDefinition (binnie.extratrees.genetics.ETTreeDefinition)8 BlockETDecorativeLeaves (binnie.extratrees.blocks.BlockETDecorativeLeaves)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 BlockETDefaultLeaves (binnie.extratrees.blocks.BlockETDefaultLeaves)3 IFruitProvider (forestry.api.arboriculture.IFruitProvider)3 ITreeGenome (forestry.api.arboriculture.ITreeGenome)3 ItemMetadata (binnie.core.block.ItemMetadata)2 BlockMultiFence (binnie.extratrees.blocks.decor.BlockMultiFence)2 PropertyETType (binnie.extratrees.blocks.property.PropertyETType)2 BlockETDoor (binnie.extratrees.blocks.wood.BlockETDoor)2 BlockETFence (binnie.extratrees.blocks.wood.BlockETFence)2 BlockETLog (binnie.extratrees.blocks.wood.BlockETLog)2 BlockETPlank (binnie.extratrees.blocks.wood.BlockETPlank)2 BlockETSlab (binnie.extratrees.blocks.wood.BlockETSlab)2 BlockShrubLog (binnie.extratrees.blocks.wood.BlockShrubLog)2 ItemBlockETWoodDoor (binnie.extratrees.blocks.wood.ItemBlockETWoodDoor)2 ItemETSlab (binnie.extratrees.blocks.wood.ItemETSlab)2 ItemBlockETDecorativeLeaves (binnie.extratrees.items.ItemBlockETDecorativeLeaves)2 EnumETLog (binnie.extratrees.wood.EnumETLog)2 IBlockState (net.minecraft.block.state.IBlockState)2