Search in sources :

Example 1 with BlockETDoor

use of binnie.extratrees.blocks.wood.BlockETDoor 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)

Aggregations

ItemMetadata (binnie.core.block.ItemMetadata)1 BlockETDecorativeLeaves (binnie.extratrees.blocks.BlockETDecorativeLeaves)1 BlockETDefaultLeaves (binnie.extratrees.blocks.BlockETDefaultLeaves)1 BlockMultiFence (binnie.extratrees.blocks.decor.BlockMultiFence)1 PropertyETType (binnie.extratrees.blocks.property.PropertyETType)1 BlockETDoor (binnie.extratrees.blocks.wood.BlockETDoor)1 BlockETFence (binnie.extratrees.blocks.wood.BlockETFence)1 BlockETLog (binnie.extratrees.blocks.wood.BlockETLog)1 BlockETPlank (binnie.extratrees.blocks.wood.BlockETPlank)1 BlockETSlab (binnie.extratrees.blocks.wood.BlockETSlab)1 BlockShrubLog (binnie.extratrees.blocks.wood.BlockShrubLog)1 ItemBlockETWoodDoor (binnie.extratrees.blocks.wood.ItemBlockETWoodDoor)1 ItemETSlab (binnie.extratrees.blocks.wood.ItemETSlab)1 ETTreeDefinition (binnie.extratrees.genetics.ETTreeDefinition)1 ItemBlockETDecorativeLeaves (binnie.extratrees.items.ItemBlockETDecorativeLeaves)1 EnumETLog (binnie.extratrees.wood.EnumETLog)1 ExtraTreePlanks (binnie.extratrees.wood.planks.ExtraTreePlanks)1 IWoodAccess (forestry.api.arboriculture.IWoodAccess)1 WoodAccess (forestry.arboriculture.WoodAccess)1 BlockForestryFenceGate (forestry.arboriculture.blocks.BlockForestryFenceGate)1