Search in sources :

Example 1 with BlockRegistryArboriculture

use of forestry.arboriculture.blocks.BlockRegistryArboriculture in project ForestryMC by ForestryMC.

the class TreeRoot method plantSapling.

@Override
public boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos) {
    BlockRegistryArboriculture blocks = ModuleArboriculture.getBlocks();
    IBlockState state = blocks.saplingGE.getDefaultState().withProperty(BlockSapling.TREE, tree.getGenome().getPrimary());
    boolean placed = world.setBlockState(pos, state);
    if (!placed) {
        return false;
    }
    IBlockState blockState = world.getBlockState(pos);
    Block block = blockState.getBlock();
    if (blocks.saplingGE != block) {
        return false;
    }
    TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
    if (sapling == null) {
        world.setBlockToAir(pos);
        return false;
    }
    sapling.setTree(tree.copy());
    sapling.getOwnerHandler().setOwner(owner);
    PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState);
    NetworkUtil.sendNetworkPacket(packet, pos, world);
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) Block(net.minecraft.block.Block) PacketFXSignal(forestry.core.network.packets.PacketFXSignal) TileSapling(forestry.arboriculture.tiles.TileSapling)

Example 2 with BlockRegistryArboriculture

use of forestry.arboriculture.blocks.BlockRegistryArboriculture in project ForestryMC by ForestryMC.

the class ModuleArboriculture method registerItemsAndBlocks.

@Override
public void registerItemsAndBlocks() {
    items = new ItemRegistryArboriculture();
    blocks = new BlockRegistryArboriculture();
}
Also used : ItemRegistryArboriculture(forestry.arboriculture.items.ItemRegistryArboriculture) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture)

Example 3 with BlockRegistryArboriculture

use of forestry.arboriculture.blocks.BlockRegistryArboriculture in project ForestryMC by ForestryMC.

the class ModuleArboriculture method preInit.

@Override
public void preInit() {
    MinecraftForge.EVENT_BUS.register(this);
    if (Config.generateTrees) {
        MinecraftForge.TERRAIN_GEN_BUS.register(new TreeDecorator());
    }
    BlockRegistryArboriculture blocks = getBlocks();
    WoodAccess woodAccess = WoodAccess.getInstance();
    woodAccess.registerLogs(blocks.logs);
    woodAccess.registerPlanks(blocks.planks);
    woodAccess.registerSlabs(blocks.slabs);
    woodAccess.registerFences(blocks.fences);
    woodAccess.registerFenceGates(blocks.fenceGates);
    woodAccess.registerStairs(blocks.stairs);
    woodAccess.registerDoors(blocks.doors);
    woodAccess.registerLogs(blocks.logsFireproof);
    woodAccess.registerPlanks(blocks.planksFireproof);
    woodAccess.registerSlabs(blocks.slabsFireproof);
    woodAccess.registerFences(blocks.fencesFireproof);
    woodAccess.registerFenceGates(blocks.fenceGatesFireproof);
    woodAccess.registerStairs(blocks.stairsFireproof);
    woodAccess.registerLogs(blocks.logsVanillaFireproof);
    woodAccess.registerPlanks(blocks.planksVanillaFireproof);
    woodAccess.registerSlabs(blocks.slabsVanillaFireproof);
    woodAccess.registerFences(blocks.fencesVanillaFireproof);
    woodAccess.registerFenceGates(blocks.fenceGatesVanillaFireproof);
    woodAccess.registerStairs(blocks.stairsVanillaFireproof);
    // Init rendering
    proxy.initializeModels();
    // Commands
    ModuleCore.rootCommand.addChildCommand(new CommandTree());
    if (ModuleManager.getInstance().isModuleEnabled(Constants.MOD_ID, ForestryModuleUids.SORTING)) {
        ArboricultureFilterRuleType.init();
    }
}
Also used : TreeDecorator(forestry.arboriculture.worldgen.TreeDecorator) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) CommandTree(forestry.arboriculture.commands.CommandTree)

Example 4 with BlockRegistryArboriculture

use of forestry.arboriculture.blocks.BlockRegistryArboriculture in project ForestryMC by ForestryMC.

the class TreeRoot method setFruitBlock.

@Override
public boolean setFruitBlock(World world, ITreeGenome genome, IAlleleFruit allele, float sappiness, BlockPos pos) {
    BlockRegistryArboriculture blocks = ModuleArboriculture.getBlocks();
    EnumFacing facing = BlockUtil.getValidPodFacing(world, pos);
    if (facing != null) {
        BlockFruitPod fruitPod = blocks.getFruitPod(allele);
        if (fruitPod != null) {
            IBlockState state = fruitPod.getDefaultState().withProperty(BlockHorizontal.FACING, facing);
            boolean placed = world.setBlockState(pos, state);
            if (placed) {
                Block block = world.getBlockState(pos).getBlock();
                if (fruitPod == block) {
                    TileFruitPod pod = TileUtil.getTile(world, pos, TileFruitPod.class);
                    if (pod != null) {
                        pod.setProperties(genome, allele, sappiness);
                        world.markBlockRangeForRenderUpdate(pos, pos);
                        return true;
                    } else {
                        world.setBlockToAir(pos);
                        return false;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) Block(net.minecraft.block.Block) BlockFruitPod(forestry.arboriculture.blocks.BlockFruitPod) TileFruitPod(forestry.arboriculture.tiles.TileFruitPod)

Example 5 with BlockRegistryArboriculture

use of forestry.arboriculture.blocks.BlockRegistryArboriculture in project ForestryMC by ForestryMC.

the class ModuleArboriculture method doInit.

@Override
public void doInit() {
    // Create alleles
    registerAlleles();
    TreeDefinition.initTrees();
    registerErsatzGenomes();
    GameRegistry.registerTileEntity(TileSapling.class, "forestry.Sapling");
    GameRegistry.registerTileEntity(TileLeaves.class, "forestry.Leaves");
    GameRegistry.registerTileEntity(TileFruitPod.class, "forestry.Pods");
    ItemRegistryArboriculture items = getItems();
    BlockRegistryArboriculture blocks = getBlocks();
    blocks.treeChest.init();
    if (Config.enableVillagers) {
        villagerArborist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_ARBORIST, Constants.TEXTURE_SKIN_LUMBERJACK, Constants.TEXTURE_SKIN_ZOMBIE_LUMBERJACK);
        ForgeRegistries.VILLAGER_PROFESSIONS.register(villagerArborist);
        VillagerRegistry.VillagerCareer arboristCareer = new VillagerRegistry.VillagerCareer(villagerArborist, "arborist");
        arboristCareer.addTrade(1, new VillagerArboristTrades.GivePlanksForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(10, 32)), new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(1, 3), EnumGermlingType.SAPLING, 4));
        arboristCareer.addTrade(2, new VillagerArboristTrades.GivePlanksForEmeralds(new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(10, 32)), new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), items.grafterProven.getItemStack(), new EntityVillager.PriceInfo(1, 1)), new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(2, 3), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.POLLEN, 6));
        arboristCareer.addTrade(3, new VillagerArboristTrades.GiveLogsForEmeralds(new EntityVillager.PriceInfo(2, 5), new EntityVillager.PriceInfo(6, 18)), new VillagerArboristTrades.GiveLogsForEmeralds(new EntityVillager.PriceInfo(2, 5), new EntityVillager.PriceInfo(6, 18)));
        arboristCareer.addTrade(4, new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(5, 20), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.POLLEN, 10), new VillagerArboristTrades.GivePollenForEmeralds(new EntityVillager.PriceInfo(5, 20), new EntityVillager.PriceInfo(1, 1), EnumGermlingType.SAPLING, 10));
    }
}
Also used : BlockRegistryArboriculture(forestry.arboriculture.blocks.BlockRegistryArboriculture) ItemRegistryArboriculture(forestry.arboriculture.items.ItemRegistryArboriculture) VillagerTradeLists(forestry.core.utils.VillagerTradeLists) VillagerRegistry(net.minecraftforge.fml.common.registry.VillagerRegistry)

Aggregations

BlockRegistryArboriculture (forestry.arboriculture.blocks.BlockRegistryArboriculture)6 ItemRegistryArboriculture (forestry.arboriculture.items.ItemRegistryArboriculture)3 Block (net.minecraft.block.Block)2 IBlockState (net.minecraft.block.state.IBlockState)2 EnumForestryWoodType (forestry.api.arboriculture.EnumForestryWoodType)1 IWoodType (forestry.api.arboriculture.IWoodType)1 BlockArbLog (forestry.arboriculture.blocks.BlockArbLog)1 BlockFruitPod (forestry.arboriculture.blocks.BlockFruitPod)1 CommandTree (forestry.arboriculture.commands.CommandTree)1 TileFruitPod (forestry.arboriculture.tiles.TileFruitPod)1 TileSapling (forestry.arboriculture.tiles.TileSapling)1 TreeDecorator (forestry.arboriculture.worldgen.TreeDecorator)1 ItemRegistryCore (forestry.core.items.ItemRegistryCore)1 PacketFXSignal (forestry.core.network.packets.PacketFXSignal)1 VillagerTradeLists (forestry.core.utils.VillagerTradeLists)1 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 VillagerRegistry (net.minecraftforge.fml.common.registry.VillagerRegistry)1