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