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;
}
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();
}
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();
}
}
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;
}
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));
}
}
Aggregations