Search in sources :

Example 46 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees-BYG by DynamicTreesTeam.

the class DTBYGRegistries method onItemsRegistry.

@SubscribeEvent
public static void onItemsRegistry(final RegistryEvent.Register<Item> event) {
    Item etherBulbs = ForgeRegistries.ITEMS.getValue(new ResourceLocation("byg", "ether_bulbs"));
    Species etherSpecies = Species.REGISTRY.get(new ResourceLocation("dtbyg", "ether"));
    ETHER_BULBS_FRUIT.setDroppedItem(new ItemStack(etherBulbs));
    if (etherSpecies.isValid())
        ETHER_BULBS_FRUIT.setSpecies(etherSpecies);
    Item greenApple = ForgeRegistries.ITEMS.getValue(new ResourceLocation("byg", "green_apple"));
    Species skyrisSpecies = Species.REGISTRY.get(new ResourceLocation("dtbyg", "skyris"));
    GREEN_APPLE_FRUIT.setDroppedItem(new ItemStack(greenApple));
    if (skyrisSpecies.isValid())
        GREEN_APPLE_FRUIT.setSpecies(skyrisSpecies);
    Item joshuaFruit = ForgeRegistries.ITEMS.getValue(new ResourceLocation("byg", "joshua_fruit"));
    Species joshuaSpecies = Species.REGISTRY.get(new ResourceLocation("dtbyg", "joshua"));
    JOSHUA_FRUIT.setDroppedItem(new ItemStack(joshuaFruit));
    if (joshuaSpecies.isValid())
        JOSHUA_FRUIT.setSpecies(joshuaSpecies);
    Item hollyBerries = ForgeRegistries.ITEMS.getValue(new ResourceLocation("byg", "holly_berries"));
    Species hollySpecies = Species.REGISTRY.get(new ResourceLocation("dtbyg", "holly"));
    HOLLY_BERRIES_FRUIT.setDroppedItem(new ItemStack(hollyBerries));
    if (hollySpecies.isValid())
        HOLLY_BERRIES_FRUIT.setSpecies(hollySpecies);
    Item baobabFruit = ForgeRegistries.ITEMS.getValue(new ResourceLocation("byg", "baobab_fruit"));
    Species baobabSpecies = Species.REGISTRY.get(new ResourceLocation("dtbyg", "baobab"));
    BAOBAB_FRUIT.setDroppedItem(new ItemStack(baobabFruit));
    if (baobabSpecies.isValid())
        BAOBAB_FRUIT.setSpecies(baobabSpecies);
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) Species(com.ferreusveritas.dynamictrees.trees.Species) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 47 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class TreeGenerator method makeTree.

public EnumGeneratorResult makeTree(World world, BiomeDataBase biomeDataBase, PoissonDisc circle, IGroundFinder groundFinder, SafeChunkBounds safeBounds) {
    // Move the circle into the "stage"
    circle.add(8, 8);
    BlockPos pos = new BlockPos(circle.x, 0, circle.z);
    Biome biome = world.getBiome(pos);
    BiomeEntry biomeEntry = biomeDataBase.getEntry(biome);
    pos = groundFinder.findGround(biomeEntry, world, pos);
    if (pos == BlockPos.ORIGIN) {
        return EnumGeneratorResult.NOGROUND;
    }
    random.setXOR(pos);
    IBlockState dirtState = world.getBlockState(pos);
    EnumGeneratorResult result = EnumGeneratorResult.GENERATED;
    SpeciesSelection speciesSelection = biomeEntry.getSpeciesSelector().getSpecies(pos, dirtState, random);
    if (speciesSelection.isHandled()) {
        Species species = speciesSelection.getSpecies();
        if (species.isValid()) {
            if (species.isAcceptableSoilForWorldgen(world, pos, dirtState)) {
                if (biomeEntry.getChanceSelector().getChance(random, species, circle.radius) == EnumChance.OK) {
                    if (species.generate(world, pos, biome, random, circle.radius, safeBounds)) {
                        result = EnumGeneratorResult.GENERATED;
                    } else {
                        result = EnumGeneratorResult.FAILGENERATION;
                    }
                } else {
                    result = EnumGeneratorResult.FAILCHANCE;
                }
            } else {
                result = EnumGeneratorResult.FAILSOIL;
            }
        } else {
            result = EnumGeneratorResult.NOTREE;
        }
    } else {
        result = EnumGeneratorResult.UNHANDLEDBIOME;
    }
    // Display wool circles for testing the circle growing algorithm
    if (ModConfigs.worldGenDebug) {
        makeWoolCircle(world, circle, pos.getY(), result, safeBounds);
    }
    // Move the circle back to normal coords
    circle.add(-8, -8);
    return result;
}
Also used : BiomeEntry(com.ferreusveritas.dynamictrees.worldgen.BiomeDataBase.BiomeEntry) Biome(net.minecraft.world.biome.Biome) IBlockState(net.minecraft.block.state.IBlockState) SpeciesSelection(com.ferreusveritas.dynamictrees.api.worldgen.BiomePropertySelectors.SpeciesSelection) BlockPos(net.minecraft.util.math.BlockPos) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 48 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class BlockBranchCactus method growSignal.

@Override
public GrowSignal growSignal(World world, BlockPos pos, GrowSignal signal) {
    if (signal.step()) {
        // This is always placed at the beginning of every growSignal function
        Species species = signal.getSpecies();
        // EnumFacing originDir = signal.dir.getOpposite(); // Direction this signal originated from
        // This must be cached on the stack for proper recursion
        EnumFacing targetDir = species.selectNewDirection(world, pos, this, signal);
        signal.doTurn(targetDir);
        BlockPos deltaPos = pos.offset(targetDir);
        IBlockState deltaState = world.getBlockState(deltaPos);
        // Pass grow signal to next block in path
        ITreePart treepart = TreeHelper.getTreePart(deltaState);
        if (treepart == this) {
            // Recurse
            signal = treepart.growSignal(world, deltaPos, signal);
        } else if (world.isAirBlock(deltaPos)) {
            signal = growIntoAir(world, deltaPos, signal, (int) signal.radius);
        }
    }
    return signal;
}
Also used : ITreePart(com.ferreusveritas.dynamictrees.api.treedata.ITreePart) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Species(com.ferreusveritas.dynamictrees.trees.Species)

Example 49 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class BlockDynamicSapling method getDrops.

@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    super.getDrops(drops, world, pos, state, fortune);
    Species species = getSpecies(world, pos, state);
    if (species != Species.NULLSPECIES) {
        drops.add(species.getSeedStack(1));
    }
}
Also used : Species(com.ferreusveritas.dynamictrees.trees.Species) TileEntitySpecies(com.ferreusveritas.dynamictrees.tileentity.TileEntitySpecies)

Example 50 with Species

use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.

the class BlockDynamicSapling method addDestroyEffects.

@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) {
    IBlockState state = world.getBlockState(pos);
    Species species = ((IExtendedBlockState) getExtendedState(state, world, pos)).getValue(SpeciesProperty.SPECIES);
    IBakedModel model = BakedModelSapling.getModelForSapling(species);
    if (!state.getBlock().isAir(state, world, pos)) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                for (int l = 0; l < 4; ++l) {
                    double d0 = ((double) j + 0.5D) / 4.0D;
                    double d1 = ((double) k + 0.5D) / 4.0D;
                    double d2 = ((double) l + 0.5D) / 4.0D;
                    ParticleDigging particle = (ParticleDigging) manager.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, Block.getStateId(state));
                    if (particle != null) {
                        particle.setParticleTexture(model.getParticleTexture());
                        particle.setBlockPos(pos);
                    }
                }
            }
        }
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ParticleDigging(net.minecraft.client.particle.ParticleDigging) Species(com.ferreusveritas.dynamictrees.trees.Species) TileEntitySpecies(com.ferreusveritas.dynamictrees.tileentity.TileEntitySpecies) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Species (com.ferreusveritas.dynamictrees.trees.Species)56 BlockPos (net.minecraft.util.math.BlockPos)24 IBlockState (net.minecraft.block.state.IBlockState)19 ItemStack (net.minecraft.item.ItemStack)12 GrowSignal (com.ferreusveritas.dynamictrees.systems.GrowSignal)9 Direction (net.minecraft.util.Direction)9 ResourceLocation (net.minecraft.util.ResourceLocation)8 World (net.minecraft.world.World)8 TileEntitySpecies (com.ferreusveritas.dynamictrees.tileentity.TileEntitySpecies)6 EnumFacing (net.minecraft.util.EnumFacing)6 MapSignal (com.ferreusveritas.dynamictrees.api.network.MapSignal)5 BlockRooty (com.ferreusveritas.dynamictrees.blocks.BlockRooty)4 ArrayList (java.util.ArrayList)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 WrongUsageException (net.minecraft.command.WrongUsageException)4 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 ITreePart (com.ferreusveritas.dynamictrees.api.treedata.ITreePart)3 BlockBonsaiPot (com.ferreusveritas.dynamictrees.blocks.BlockBonsaiPot)3 TreeFamily (com.ferreusveritas.dynamictrees.trees.TreeFamily)3