From aa163aa6f1737181174a407a2f8ba49fa4123593 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Fri, 5 Feb 2016 22:24:56 +1100 Subject: [PATCH] Added wisteria generation --- .../biome/overworld/BiomeGenLushSwamp.java | 2 +- .../biome/overworld/BiomeGenMysticGrove.java | 2 +- .../biome/overworld/BiomeGenOminousWoods.java | 2 +- .../BiomeGenTemperateRainforest.java | 2 +- .../biome/overworld/BiomeGenWetland.java | 2 +- .../overworld/BiomeGenWisteriaMeadow.java | 3 +- .../biome/vanilla/BiomeExtSwampland.java | 2 +- .../feature/tree/GeneratorBasicTree.java | 74 +++++++++++-------- .../feature/tree/GeneratorBayouTree.java | 7 +- .../world/feature/tree/GeneratorBigTree.java | 7 +- .../world/feature/tree/GeneratorBulbTree.java | 9 ++- .../world/feature/tree/GeneratorBush.java | 7 +- .../world/feature/tree/GeneratorHugeTree.java | 4 +- .../feature/tree/GeneratorMahoganyTree.java | 10 ++- .../feature/tree/GeneratorMegaJungleTree.java | 7 +- .../world/feature/tree/GeneratorPineTree.java | 7 +- .../feature/tree/GeneratorProfileTree.java | 7 +- .../feature/tree/GeneratorRedwoodTree.java | 7 +- .../feature/tree/GeneratorTaigaTree.java | 7 +- .../world/feature/tree/GeneratorTreeBase.java | 26 ++++++- .../feature/tree/GeneratorTwigletTree.java | 7 +- 21 files changed, 125 insertions(+), 76 deletions(-) diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenLushSwamp.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenLushSwamp.java index 622ee29f2..4a2f0ecfd 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenLushSwamp.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenLushSwamp.java @@ -82,7 +82,7 @@ public class BiomeGenLushSwamp extends BOPBiome // trees & logs GeneratorWeighted treeGenerator = new GeneratorWeighted(9); this.addGenerator("trees", GeneratorStage.TREE, treeGenerator); - treeGenerator.add("swamp", 5, (new GeneratorBasicTree.Builder()).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BOPBlocks.ivy.getDefaultState()).create()); + treeGenerator.add("swamp", 5, (new GeneratorBasicTree.Builder()).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BOPBlocks.ivy.getDefaultState()).create()); // grasses GeneratorWeighted grassGenerator = new GeneratorWeighted(5.0F); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenMysticGrove.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenMysticGrove.java index cd305ed70..c0de9d345 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenMysticGrove.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenMysticGrove.java @@ -78,7 +78,7 @@ public class BiomeGenMysticGrove extends BOPBiome // trees & logs GeneratorWeighted treeGenerator = new GeneratorWeighted(10); this.addGenerator("trees", GeneratorStage.TREE, treeGenerator); - treeGenerator.add("flowering_vine", 2, (new GeneratorBasicTree.Builder()).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BOPBlocks.flower_vine.getDefaultState()).create()); + treeGenerator.add("flowering_vine", 2, (new GeneratorBasicTree.Builder()).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BOPBlocks.flower_vine.getDefaultState()).create()); treeGenerator.add("magic", 9, (new GeneratorBasicTree.Builder()).log(BOPWoods.MAGIC).leaves(BOPTrees.MAGIC).create()); treeGenerator.add("jacaranda", 1, (new GeneratorBasicTree.Builder()).minHeight(4).maxHeight(7).log(BOPWoods.JACARANDA).leaves(BOPTrees.JACARANDA).create()); treeGenerator.add("oak_large", 3, (new GeneratorBigTree.Builder()).create()); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOminousWoods.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOminousWoods.java index ecb50856e..cc9d82508 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOminousWoods.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenOminousWoods.java @@ -80,7 +80,7 @@ public class BiomeGenOminousWoods extends BOPBiome // trees & logs GeneratorWeighted treeGenerator = new GeneratorWeighted(9); this.addGenerator("trees", GeneratorStage.TREE, treeGenerator); - treeGenerator.add("umbran_moss", 4, (new GeneratorBasicTree.Builder()).log(BOPWoods.UMBRAN).leaves(BOPTrees.UMBRAN).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BOPBlocks.tree_moss.getDefaultState()).create()); + treeGenerator.add("umbran_moss", 4, (new GeneratorBasicTree.Builder()).log(BOPWoods.UMBRAN).leaves(BOPTrees.UMBRAN).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BOPBlocks.tree_moss.getDefaultState()).create()); treeGenerator.add("umbran_spruce", 5, (new GeneratorTaigaTree.Builder()).log(BOPWoods.UMBRAN).leaves(BOPTrees.UMBRAN).maxHeight(20).create()); // TODO: implement pine cones treeGenerator.add("dead_tree", 3, (new GeneratorBigTree.Builder()).minHeight(5).maxHeight(12).foliageHeight(0).foliageDensity(0.5D).log(BOPWoods.DEAD).leaves(Blocks.air.getDefaultState()).create()); treeGenerator.add("mega_umbran", 4, (new GeneratorTaigaTree.Builder()).log(BOPWoods.UMBRAN).leaves(BOPTrees.UMBRAN).minHeight(20).maxHeight(30).trunkWidth(2).create()); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenTemperateRainforest.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenTemperateRainforest.java index 2c5a3052a..2341abbb2 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenTemperateRainforest.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenTemperateRainforest.java @@ -66,7 +66,7 @@ public class BiomeGenTemperateRainforest extends BOPBiome treeGenerator.add("small_cedar", 3, (new GeneratorTaigaTree.Builder()).log(BlockPlanks.EnumType.OAK).leaves(BlockPlanks.EnumType.OAK).minHeight(5).maxHeight(15).create()); treeGenerator.add("cedar", 5, (new GeneratorTaigaTree.Builder()).log(BlockPlanks.EnumType.OAK).leaves(BlockPlanks.EnumType.OAK).minHeight(20).maxHeight(40).create()); treeGenerator.add("oak_bush", 5, (new GeneratorBush.Builder()).maxHeight(2).create()); - treeGenerator.add("willow", 1, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); + treeGenerator.add("willow", 1, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); // other plants this.addGenerator("shrubs", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(0.6F).with(BOPPlants.SHRUB).create()); diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWetland.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWetland.java index 5103b2653..81cffe15d 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWetland.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWetland.java @@ -74,7 +74,7 @@ public class BiomeGenWetland extends BOPBiome // trees & logs GeneratorWeighted treeGenerator = new GeneratorWeighted(7); this.addGenerator("trees", GeneratorStage.TREE, treeGenerator); - treeGenerator.add("willow", 3, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); + treeGenerator.add("willow", 3, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); treeGenerator.add("spruce", 5, (new GeneratorTaigaTree.Builder()).maxHeight(13).create()); // TODO: implement pine cones // grasses diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWisteriaMeadow.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWisteriaMeadow.java index 5ca11de7a..8232a9262 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWisteriaMeadow.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWisteriaMeadow.java @@ -13,6 +13,7 @@ import biomesoplenty.api.block.BOPBlocks; import biomesoplenty.common.block.BlockBOPCoral; import biomesoplenty.common.block.BlockBOPDoublePlant; import biomesoplenty.common.block.BlockBOPLilypad; +import biomesoplenty.common.block.BlockBOPPlant; import biomesoplenty.common.entities.EntityButterfly; import biomesoplenty.common.entities.EntitySnail; import biomesoplenty.common.enums.BOPClimates; @@ -45,7 +46,7 @@ public class BiomeGenWisteriaMeadow extends BOPBiome this.spawnableCreatureList.add(new SpawnListEntry(EntityButterfly.class, 6, 2, 4)); //trees - this.addGenerator("trees", GeneratorStage.TREE, (new GeneratorBasicTree.Builder()).amountPerChunk(1.0F).minHeight(6).maxHeight(10).minLeavesRadius(2).create()); + this.addGenerator("trees", GeneratorStage.TREE, (new GeneratorBasicTree.Builder()).amountPerChunk(1.0F).minHeight(6).maxHeight(10).hanging(BlockBOPPlant.paging.getVariantState(BOPPlants.WISTERIA)).maxLeavesRadius(2).hangingChance(0.75F).create()); // grasses GeneratorWeighted grassGenerator = new GeneratorWeighted(5.0F); diff --git a/src/main/java/biomesoplenty/common/biome/vanilla/BiomeExtSwampland.java b/src/main/java/biomesoplenty/common/biome/vanilla/BiomeExtSwampland.java index 02e7b99cc..a968cdb7b 100644 --- a/src/main/java/biomesoplenty/common/biome/vanilla/BiomeExtSwampland.java +++ b/src/main/java/biomesoplenty/common/biome/vanilla/BiomeExtSwampland.java @@ -36,7 +36,7 @@ public class BiomeExtSwampland extends ExtendedBiomeWrapper // trees GeneratorWeighted treeGenerator = new GeneratorWeighted(0.5F); this.addGenerator("trees", GeneratorStage.TREE, treeGenerator); - treeGenerator.add("willow", 1, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).minLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); + treeGenerator.add("willow", 1, (new GeneratorBasicTree.Builder()).log(BOPWoods.WILLOW).leaves(BOPTrees.WILLOW).minHeight(8).maxHeight(12).maxLeavesRadius(2).vine(BlockBOPLeaves.paging.getVariantState(BOPTrees.WILLOW).withProperty(BlockLeaves.DECAYABLE, Boolean.valueOf(false))).leavesOffset(0).create()); // grasses GeneratorWeighted grassGenerator = new GeneratorWeighted(1.2F); diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java index 6da467485..81ce75f68 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java @@ -45,19 +45,21 @@ public class GeneratorBasicTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = null; this.minHeight = 4; this.maxHeight = 7; this.leafLayers = 4; this.leavesOffset = 1; - this.minLeavesRadius = 1; + this.maxLeavesRadius = 1; this.leavesLayerHeight = 2; this.placeVinesOn = BlockQueries.air; + this.hangingChance = 0.0F; } @Override public GeneratorBasicTree create() { - return new GeneratorBasicTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, false, this.leafLayers, this.leavesOffset, this.minLeavesRadius, this.leavesLayerHeight, this.placeVinesOn); + return new GeneratorBasicTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, false, this.leafLayers, this.leavesOffset, this.maxLeavesRadius, this.leavesLayerHeight, this.placeVinesOn, this.hangingChance); } } @@ -65,38 +67,43 @@ public class GeneratorBasicTree extends GeneratorTreeBase { protected int leafLayers; protected int leavesOffset; - protected int minLeavesRadius; + protected int maxLeavesRadius; protected int leavesLayerHeight; protected IBlockPosQuery placeVinesOn; + protected float hangingChance; public T leafLayers(int a) {this.leafLayers = a; return this.self();} public T leavesOffset(int a) {this.leavesOffset = a; return this.self();} public T leavesLayerHeight(int a) {this.leavesLayerHeight = a; return this.self();} - public T minLeavesRadius(int a) {this.minLeavesRadius = a; return this.self();} + public T maxLeavesRadius(int a) {this.maxLeavesRadius = a; return this.self();} public T placeVinesOn(IBlockPosQuery a) {this.placeVinesOn = a; return this.self();} public T placeVinesOn(String a) throws BlockQueryParseException {this.placeVinesOn = BlockQuery.parseQueryString(a); return this.self();} public T placeVinesOn(Block a) {this.placeVinesOn = new BlockQueryBlock(a); return this.self();} public T placeVinesOn(IBlockState a) {this.placeVinesOn = new BlockQueryState(a); return this.self();} public T placeVinesOn(Material... a) {this.placeVinesOn = new BlockQueryMaterial(a); return this.self();} + + public T hangingChance(float a) {this.hangingChance = a; return this.self();} } protected boolean updateNeighbours; protected int leafLayers; protected int leavesOffset; - protected int minLeavesRadius; + protected int maxLeavesRadius; protected int leavesLayerHeight; protected IBlockPosQuery placeVinesOn; + protected float hangingChance; - public GeneratorBasicTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, boolean updateNeighbours, int leafLayers, int leavesOffset, int minLeavesRadius, int leavesLayerHeight, IBlockPosQuery placeVinesOn) + public GeneratorBasicTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, boolean updateNeighbours, int leafLayers, int leavesOffset, int maxLeavesRadius, int leavesLayerHeight, IBlockPosQuery placeVinesOn, float hangingChance) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.updateNeighbours = updateNeighbours; this.leavesOffset = leavesOffset; this.leafLayers = leafLayers; - this.minLeavesRadius = minLeavesRadius; + this.maxLeavesRadius = maxLeavesRadius; this.leavesLayerHeight = leavesLayerHeight; this.placeVinesOn = placeVinesOn; + this.hangingChance = hangingChance; } @Override @@ -169,7 +176,7 @@ public class GeneratorBasicTree extends GeneratorTreeBase int currentLayer = y - (pos.getY() + height); //Uses integer division truncation (-3 / 2 = -1, -2 / 2 = -1) to reduce //the radius closer to the top of the tree. (2, 2, 1, 1) - int leavesRadius = this.minLeavesRadius - currentLayer / this.leavesLayerHeight; + int leavesRadius = this.maxLeavesRadius - currentLayer / this.leavesLayerHeight; for (int x = pos.getX() - leavesRadius; x <= pos.getX() + leavesRadius; x++) { @@ -203,7 +210,7 @@ public class GeneratorBasicTree extends GeneratorTreeBase int currentLayer = y - (pos.getY() + height); //Uses integer division truncation (-3 / 2 = -1, -2 / 2 = -1) to reduce //the radius closer to the top of the tree. (3, 3, 2, 2) - int leavesRadius = (this.minLeavesRadius + this.leavesOffset) - currentLayer / this.leavesLayerHeight; + int leavesRadius = (this.maxLeavesRadius + this.leavesOffset) - currentLayer / this.leavesLayerHeight; for (int x = pos.getX() - leavesRadius; x <= pos.getX() + leavesRadius; x++) { @@ -243,6 +250,9 @@ public class GeneratorBasicTree extends GeneratorTreeBase } } } + + //Generate fruit or any other blocks that may hang off of the tree + if (this.hanging != null) this.generateHanging(world, pos, height); return true; } @@ -267,28 +277,27 @@ public class GeneratorBasicTree extends GeneratorTreeBase if (this.replace.matches(world, blockpos2)) { this.setBlockAndNotifyAdequately(world, start.up(layer), this.log); - - //If vines are enabled, randomly cover the sides of the trunk with vines from the bottom up - /*if (this.vine != null && layer > 0) + } + } + } + + protected void generateHanging(World world, BlockPos start, int height) + { + //Generate below the bottom layer of leaves + int y = start.getY() + (height - this.leafLayers); + + for (int x = start.getX() - maxLeavesRadius; x <= start.getX() + maxLeavesRadius; x++) + { + for (int z = start.getZ() - maxLeavesRadius; z <= start.getZ() + maxLeavesRadius; z++) + { + BlockPos hangingPos = new BlockPos(x, y, z); + + System.out.println(hangingPos); + + if (!world.isAirBlock(hangingPos.up()) && world.rand.nextFloat() <= this.hangingChance) { - if (random.nextInt(3) > 0 && this.placeVinesOn.matches(world, pos.add(-1, layer, 0))) - { - this.setBlockAndNotifyAdequately(world, pos.add(-1, layer, 0), this.getVineStateForSide(EnumFacing.EAST)); - } - - if (random.nextInt(3) > 0 && this.placeVinesOn.matches(world, pos.add(1, layer, 0))) - { - this.setBlockAndNotifyAdequately(world, pos.add(1, layer, 0), this.getVineStateForSide(EnumFacing.WEST)); - } - if (random.nextInt(3) > 0 && this.placeVinesOn.matches(world, pos.add(0, layer, -1))) - { - this.setBlockAndNotifyAdequately(world, pos.add(0, layer, -1), this.getVineStateForSide(EnumFacing.SOUTH)); - } - if (random.nextInt(3) > 0 && this.placeVinesOn.matches(world, pos.add(0, layer, 1))) - { - this.setBlockAndNotifyAdequately(world, pos.add(0, layer, 1), this.getVineStateForSide(EnumFacing.NORTH)); - } - }*/ + this.setHanging(world, hangingPos); + } } } } @@ -340,5 +349,8 @@ public class GeneratorBasicTree extends GeneratorTreeBase this.log = conf.getBlockState("logState", this.log); this.leaves = conf.getBlockState("leavesState", this.leaves); this.vine = conf.getBlockState("vineState", this.vine); + this.hanging = conf.getBlockState("hangingState", this.hanging); + + this.hangingChance = conf.getFloat("hangingChance", this.hangingChance); } } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBayouTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBayouTree.java index 167d978e9..d7f6f24a5 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBayouTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBayouTree.java @@ -54,6 +54,7 @@ public class GeneratorBayouTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = Blocks.vine.getDefaultState(); + this.hanging = null; this.minHeight = 8; this.maxHeight = 18; this.minLeavesRadius = 2; @@ -65,7 +66,7 @@ public class GeneratorBayouTree extends GeneratorTreeBase @Override public GeneratorBayouTree create() { - return new GeneratorBayouTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, this.minLeavesRadius, this.leavesGradient, this.vineAttempts, this.maxVineLength, this.rootsReplace); + return new GeneratorBayouTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, this.minLeavesRadius, this.leavesGradient, this.vineAttempts, this.maxVineLength, this.rootsReplace); } } @@ -76,9 +77,9 @@ public class GeneratorBayouTree extends GeneratorTreeBase private int maxVineLength; private IBlockPosQuery rootsReplace; - public GeneratorBayouTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, int minLeavesRadius, int leavesGradient, int vineAttempts, int maxVineLength, IBlockPosQuery rootsReplace) + public GeneratorBayouTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, int minLeavesRadius, int leavesGradient, int vineAttempts, int maxVineLength, IBlockPosQuery rootsReplace) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.minLeavesRadius = minLeavesRadius; this.leavesGradient = leavesGradient; this.vineAttempts = vineAttempts; diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java index 5435e1b71..1827a565d 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java @@ -52,6 +52,7 @@ public class GeneratorBigTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = null; this.minHeight = 5; this.maxHeight = 17; @@ -69,7 +70,7 @@ public class GeneratorBigTree extends GeneratorTreeBase @Override public GeneratorBigTree create() { - return new GeneratorBigTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, this.trunkWidth, this.foliageHeight, this.foliageDensity, false); + return new GeneratorBigTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, this.trunkWidth, this.foliageHeight, this.foliageDensity, false); } } @@ -94,9 +95,9 @@ public class GeneratorBigTree extends GeneratorTreeBase private List foliageCoords; - public GeneratorBigTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, int trunkWidth, int foliageHeight, double foliageDensity, boolean updateNeighbours) + public GeneratorBigTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, int trunkWidth, int foliageHeight, double foliageDensity, boolean updateNeighbours) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.foliageHeight = foliageHeight; this.foliageDensity = foliageDensity; this.trunkWidth = trunkWidth; diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBulbTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBulbTree.java index 55128803e..13a7368c3 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBulbTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBulbTree.java @@ -34,20 +34,21 @@ public class GeneratorBulbTree extends GeneratorTreeBase this.replace = BlockQueries.airOrLeaves; this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); - this.vine = null; + this.vine = null; + this.hanging = null; } @Override public GeneratorBulbTree create() { - return new GeneratorBulbTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight); + return new GeneratorBulbTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight); } } - public GeneratorBulbTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) + public GeneratorBulbTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } public boolean setCocoa(World world, BlockPos pos, EnumFacing side) diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java index a5afa0657..c7e36561f 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java @@ -33,18 +33,19 @@ public class GeneratorBush extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = null; } @Override public GeneratorBush create() { - return new GeneratorBush(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight); + return new GeneratorBush(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight); } } - public GeneratorBush(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) + public GeneratorBush(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } @Override diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorHugeTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorHugeTree.java index 63cc5f8d0..fcb931647 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorHugeTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorHugeTree.java @@ -20,8 +20,8 @@ import net.minecraft.world.World; public abstract class GeneratorHugeTree extends GeneratorTreeBase { - protected GeneratorHugeTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + protected GeneratorHugeTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } protected int chooseHeight(Random rand) diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMahoganyTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMahoganyTree.java index 8d12cadfd..e9e4a30d1 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMahoganyTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMahoganyTree.java @@ -34,25 +34,27 @@ public class GeneratorMahoganyTree extends GeneratorBasicTree this.log = BlockBOPLog.paging.getVariantState(BOPWoods.MAHOGANY); this.leaves = BlockBOPLeaves.paging.getVariantState(BOPTrees.MAHOGANY); this.vine = null; + this.hanging = null; this.minHeight = 10; this.maxHeight = 15; this.leafLayers = 4; this.leavesOffset = 1; - this.minLeavesRadius = 1; + this.maxLeavesRadius = 1; this.leavesLayerHeight = 1; this.placeVinesOn = BlockQueries.air; + this.hangingChance = 0.0F; } @Override public GeneratorMahoganyTree create() { - return new GeneratorMahoganyTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, false, this.leafLayers, this.leavesOffset, this.minLeavesRadius, this.leavesLayerHeight, this.placeVinesOn); + return new GeneratorMahoganyTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, false, this.leafLayers, this.leavesOffset, this.maxLeavesRadius, this.leavesLayerHeight, this.placeVinesOn, this.hangingChance); } } - public GeneratorMahoganyTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, boolean updateNeighbours, int leafLayers, int leavesOffset, int minLeavesRadius, int leavesLayerHeight, IBlockPosQuery placeVinesOn) + public GeneratorMahoganyTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, boolean updateNeighbours, int leafLayers, int leavesOffset, int minLeavesRadius, int leavesLayerHeight, IBlockPosQuery placeVinesOn, float hangingChance) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight, updateNeighbours, leafLayers, leavesOffset, minLeavesRadius, leavesLayerHeight, placeVinesOn); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight, updateNeighbours, leafLayers, leavesOffset, minLeavesRadius, leavesLayerHeight, placeVinesOn, hangingChance); } @Override diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMegaJungleTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMegaJungleTree.java index 9b6eb36db..2f0a75070 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMegaJungleTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorMegaJungleTree.java @@ -35,18 +35,19 @@ public class GeneratorMegaJungleTree extends GeneratorHugeTree this.log(BlockPlanks.EnumType.JUNGLE); this.leaves(BlockPlanks.EnumType.JUNGLE); this.vine = Blocks.vine.getDefaultState(); + this.hanging = null; } @Override public GeneratorMegaJungleTree create() { - return new GeneratorMegaJungleTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight); + return new GeneratorMegaJungleTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight); } } - protected GeneratorMegaJungleTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) + protected GeneratorMegaJungleTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorPineTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorPineTree.java index 32b3a7870..3bd1335cb 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorPineTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorPineTree.java @@ -35,18 +35,19 @@ public class GeneratorPineTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = hanging; } @Override public GeneratorPineTree create() { - return new GeneratorPineTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight); + return new GeneratorPineTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight); } } - public GeneratorPineTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) + public GeneratorPineTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorProfileTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorProfileTree.java index 37b1f6bf4..7f44572a1 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorProfileTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorProfileTree.java @@ -38,21 +38,22 @@ public class GeneratorProfileTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = null; this.profile = TreeProfile.POPLAR; } @Override public GeneratorProfileTree create() { - return new GeneratorProfileTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, this.profile); + return new GeneratorProfileTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, this.profile); } } protected TreeProfile profile; - public GeneratorProfileTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, TreeProfile profile) + public GeneratorProfileTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, TreeProfile profile) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.profile = profile; } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorRedwoodTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorRedwoodTree.java index c933fa865..a86fdae6e 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorRedwoodTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorRedwoodTree.java @@ -40,19 +40,20 @@ public class GeneratorRedwoodTree extends GeneratorTreeBase this.log = BlockBOPLog.paging.getVariantState(BOPWoods.REDWOOD); this.leaves = BlockBOPLeaves.paging.getVariantState(BOPTrees.REDWOOD); this.vine = null; + this.hanging = null; } @Override public GeneratorRedwoodTree create() { - return new GeneratorRedwoodTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight); + return new GeneratorRedwoodTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight); } } - protected GeneratorRedwoodTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) + protected GeneratorRedwoodTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); } public boolean canPlaceHere(World world, BlockPos pos, int height, int radius) diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTaigaTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTaigaTree.java index 364c7eef5..f36fe103b 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTaigaTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTaigaTree.java @@ -42,21 +42,22 @@ public class GeneratorTaigaTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE); this.leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.SPRUCE); this.vine = Blocks.vine.getDefaultState(); + this.hanging = null; this.trunkWidth = 1; } @Override public GeneratorTaigaTree create() { - return new GeneratorTaigaTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, this.trunkWidth); + return new GeneratorTaigaTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, this.trunkWidth); } } private int trunkWidth; - public GeneratorTaigaTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, int trunkWidth) + public GeneratorTaigaTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, int trunkWidth) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.trunkWidth = trunkWidth; } diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java index 90ebfb47e..b3c261706 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTreeBase.java @@ -46,17 +46,19 @@ public abstract class GeneratorTreeBase extends BOPGeneratorBase protected IBlockState log; protected IBlockState leaves; protected IBlockState vine; + protected IBlockState hanging; protected int minHeight; protected int maxHeight; protected IProperty logAxisProperty; - protected GeneratorTreeBase(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight) { + protected GeneratorTreeBase(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight) { super(amountPerChunk); this.placeOn = placeOn; this.replace = replace; this.log = log; this.leaves = leaves; this.vine = vine; + this.hanging = hanging; this.minHeight = minHeight; this.maxHeight = maxHeight; this.logAxisProperty = GeneratorUtils.getAxisProperty(log); @@ -69,6 +71,7 @@ public abstract class GeneratorTreeBase extends BOPGeneratorBase protected IBlockState log; protected IBlockState leaves; protected IBlockState vine; + protected IBlockState hanging; protected int minHeight; protected int maxHeight; @@ -120,6 +123,18 @@ public abstract class GeneratorTreeBase extends BOPGeneratorBase } return this.self(); } + public T hanging(IBlockState a) + { + if (a == null) + { + this.hanging = null; + } + else + { + this.hanging = a; + } + return this.self(); + } public T minHeight(int a) {this.minHeight = a; return this.self();} public T maxHeight(int a) {this.maxHeight = a; return this.self();} @@ -175,4 +190,13 @@ public abstract class GeneratorTreeBase extends BOPGeneratorBase return setOne; } + public boolean setHanging(World world, BlockPos pos) + { + if (this.hanging == null) {return false;} + if (this.replace.matches(world, pos)) + { + world.setBlockState(pos, this.hanging, 2); + } + return false; + } } \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTwigletTree.java b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTwigletTree.java index 7f4a0d8fd..23099101c 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTwigletTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorTwigletTree.java @@ -39,22 +39,23 @@ public class GeneratorTwigletTree extends GeneratorTreeBase this.log = Blocks.log.getDefaultState(); this.leaves = Blocks.leaves.getDefaultState(); this.vine = null; + this.hanging = null; this.leafChanceEven = 0.2F; this.leafChanceOdd = 0.9F; } @Override public GeneratorTwigletTree create() { - return new GeneratorTwigletTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.minHeight, this.maxHeight, this.leafChanceEven, this.leafChanceOdd); + return new GeneratorTwigletTree(this.amountPerChunk, this.placeOn, this.replace, this.log, this.leaves, this.vine, this.hanging, this.minHeight, this.maxHeight, this.leafChanceEven, this.leafChanceOdd); } } private float leafChanceEven; private float leafChanceOdd; - public GeneratorTwigletTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, int minHeight, int maxHeight, float leafChanceEven, float leafChanceOdd) + public GeneratorTwigletTree(float amountPerChunk, IBlockPosQuery placeOn, IBlockPosQuery replace, IBlockState log, IBlockState leaves, IBlockState vine, IBlockState hanging, int minHeight, int maxHeight, float leafChanceEven, float leafChanceOdd) { - super(amountPerChunk, placeOn, replace, log, leaves, vine, minHeight, maxHeight); + super(amountPerChunk, placeOn, replace, log, leaves, vine, hanging, minHeight, maxHeight); this.leafChanceEven = leafChanceEven; this.leafChanceOdd = leafChanceOdd; }