use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees-BYG by DynamicTreesTeam.
the class RedwoodLogic method selectNewDirection.
@Override
public Direction selectNewDirection(GrowthLogicKitConfiguration configuration, DirectionSelectionContext context) {
final Species species = context.species();
final GrowSignal signal = context.signal();
Direction newDir = super.selectNewDirection(configuration, context);
int signalY = signal.delta.getY();
int treeHash = CoordUtils.coordHashCode(signal.rootPos, 2);
int canopyHeight = species.getLowestBranchHeight() + treeHash % 8 + configuration.get(HEIGHT_OF_CANOPY);
float bottomSlope = 1 + (treeHash % 10) / (float) 0xFFF;
if (signal.isInTrunk() && newDir != Direction.UP) {
// Turned out of trunk
if (signalY < canopyHeight)
signal.energy = 3;
else {
signal.energy += 2;
signal.energy /= 3.2f;
float maxEnergy = Math.max(2, Math.min(8.2f, (signalY - canopyHeight) * bottomSlope));
signal.energy = Math.min(maxEnergy, signal.energy);
}
}
return newDir;
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees-BYG by DynamicTreesTeam.
the class TaperedWitheredOakLogic method populateDirectionProbabilityMap.
@Override
public int[] populateDirectionProbabilityMap(GrowthLogicKitConfiguration configuration, DirectionManipulationContext context) {
final Species species = context.species();
final World world = context.world();
final GrowSignal signal = context.signal();
final int[] probMap = context.probMap();
final int radius = context.radius();
final BlockPos pos = context.pos();
Direction originDir = signal.dir.getOpposite();
int treeHash = CoordUtils.coordHashCode(signal.rootPos, 2);
// Alter probability map for direction change
// Down is always disallowed for jungle
probMap[0] = 0;
probMap[1] = signal.isInTrunk() ? species.getUpProbability() : 1;
probMap[2] = probMap[3] = probMap[4] = probMap[5] = 0;
int lowestBranch = species.getLowestBranchHeight();
int height = lowestBranch * 2 + ((treeHash % 7829) % 3);
if (signal.delta.getY() >= height) {
probMap[2] = probMap[3] = probMap[4] = // Only allow turns when we aren't in the trunk(or the branch is not a twig)
probMap[5] = !signal.isInTrunk() || radius > 1 ? 2 : 0;
// Disable the direction we came from
probMap[originDir.ordinal()] = 0;
// Favor current travel direction
probMap[signal.dir.ordinal()] += signal.isInTrunk() ? 0 : signal.numTurns == 1 ? 2 : 1;
} else if (signal.delta.getY() == lowestBranch) {
if (!signal.isInTrunk()) {
probMap[1] = (signal.energy >= 2) ? 0 : 1;
probMap[2] = probMap[3] = probMap[4] = probMap[5] = (signal.energy >= 3) ? 0 : 1;
probMap[originDir.ordinal()] = 1;
} else {
int sideHash = treeHash % 16;
probMap[2] = sideHash % 2 < 1 ? 1 : 0;
probMap[3] = sideHash % 4 < 2 ? 1 : 0;
probMap[4] = sideHash % 8 < 4 ? 1 : 0;
probMap[5] = sideHash < 8 ? 1 : 0;
}
}
// Disable the direction we came from
probMap[originDir.ordinal()] = 0;
// Favor current travel direction
probMap[signal.dir.ordinal()] += signal.isInTrunk() ? 0 : signal.numTurns == 1 ? 2 : 1;
return probMap;
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees-BYG by DynamicTreesTeam.
the class TaperedWitheredOakLogic method selectNewDirection.
@Override
public Direction selectNewDirection(GrowthLogicKitConfiguration configuration, DirectionSelectionContext context) {
final Species species = context.species();
final GrowSignal signal = context.signal();
Direction newDir = super.selectNewDirection(configuration, context);
if (signal.delta.getY() == species.getLowestBranchHeight() && signal.isInTrunk() && // Turned out of trunk
newDir != Direction.UP)
signal.energy = 5;
return newDir;
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees-BYG by DynamicTreesTeam.
the class DiagonalPalmFamily method createBranchBlock.
@Override
protected BranchBlock createBranchBlock() {
final BasicBranchBlock branch = new BasicBranchBlock(this.getProperties()) {
@Override
public GrowSignal growIntoAir(World world, BlockPos pos, GrowSignal signal, int fromRadius) {
final Species species = signal.getSpecies();
final DynamicLeavesBlock leaves = species.getLeavesBlock().orElse(null);
if (leaves != null) {
if (fromRadius == getFamily().getPrimaryThickness()) {
// If we came from a twig (and we're not a stripped branch) then just make some leaves
if (isNextToBranch(world, pos, signal.dir.getOpposite())) {
signal.success = false;
return signal;
}
signal.success = leaves.growLeavesIfLocationIsSuitable(world, species.getLeavesProperties(), pos.above(), 0);
if (signal.success)
return leaves.branchOut(world, pos, signal);
} else {
// Otherwise make a proper branch
return leaves.branchOut(world, pos, signal);
}
} else {
// If the leaves block is null, the branch grows directly without checking for leaves requirements
if (isNextToBranch(world, pos, signal.dir.getOpposite())) {
signal.success = false;
return signal;
}
setRadius(world, pos, getFamily().getPrimaryThickness(), null);
signal.radius = getFamily().getSecondaryThickness();
signal.success = true;
}
return signal;
}
};
if (this.isFireProof())
branch.setFireSpreadSpeed(0).setFlammability(0);
return branch;
}
use of com.ferreusveritas.dynamictrees.trees.Species in project DynamicTrees by DynamicTreesTeam.
the class ModRecipes method register.
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void register(RegistryEvent.Register<IRecipe> event) {
IForgeRegistry<IRecipe> registry = event.getRegistry();
ModItems.dendroPotion.registerRecipes(registry);
// Create a dirt bucket from dirt and a bucket
GameRegistry.addShapelessRecipe(new ResourceLocation(ModConstants.MODID, "dirtbucket"), null, new ItemStack(ModItems.dirtBucket), Ingredient.fromItem(Items.BUCKET), Ingredient.fromItem(Item.getItemFromBlock(Blocks.DIRT)));
// Create a seed <-> sapling exchange for the 6 vanilla tree types
for (BlockPlanks.EnumType woodType : BlockPlanks.EnumType.values()) {
Species species = TreeRegistry.findSpecies(new ResourceLocation(ModConstants.MODID, woodType.getName().replace("_", "")));
ItemStack saplingStack = new ItemStack(Blocks.SAPLING, 1, woodType.getMetadata());
ItemStack seedStack = species.getSeedStack(1);
createDirtBucketExchangeRecipes(saplingStack, seedStack, true);
}
// Create an apple seed from an apple and dirt bucket
if (ModConfigs.enableAppleTrees) {
createDirtBucketExchangeRecipes(new ItemStack(Items.APPLE), TreeRegistry.findSpecies(new ResourceLocation(ModConstants.MODID, "apple")).getSeedStack(1), false);
}
}
Aggregations