From 910086f1117b911a9842a443faacec020090e8ce Mon Sep 17 00:00:00 2001 From: Cheeserolls Date: Sun, 7 Jun 2015 23:09:01 +0100 Subject: [PATCH] Provide shortcut methods for building trees with vanilla logs and leaves --- .../feature/tree/GeneratorBasicTree.java | 25 +++++++++++++++++++ .../world/feature/tree/GeneratorBigTree.java | 25 +++++++++++++++++++ .../world/feature/tree/GeneratorBush.java | 25 +++++++++++++++++++ 3 files changed, 75 insertions(+) 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 aade9b4c7..71a4c4952 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBasicTree.java @@ -11,6 +11,11 @@ package biomesoplenty.common.world.feature.tree; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.BlockNewLeaf; +import net.minecraft.block.BlockNewLog; +import net.minecraft.block.BlockOldLeaf; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockSapling; import net.minecraft.block.BlockVine; import net.minecraft.block.material.Material; @@ -49,8 +54,28 @@ public class GeneratorBasicTree extends BOPGeneratorBase public Builder maxHeight(int a) {this.maxHeight = a; return this;} public Builder log(IBlockState a) {this.log = a; return this;} public Builder log(BOPWoods a) {this.log = BlockBOPLog.paging.getVariantState(a); return this;} + public Builder log(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, a); + } else { + this.log = Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, a); + } + return this; + } public Builder leaves(IBlockState a) {this.leaves = a; return this;} public Builder leaves(BOPTrees a) {this.leaves = BlockBOPLeaves.paging.getVariantState(a); return this;} + public Builder leaves(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, a); + } else { + this.leaves = Blocks.leaves2.getDefaultState().withProperty(BlockNewLeaf.VARIANT, a); + } + return this; + } public Builder vine(IBlockState a) {this.vine = a; return this;} 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 a048b48ae..879c2f5b5 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBigTree.java @@ -14,6 +14,11 @@ import java.util.Random; import org.apache.commons.lang3.tuple.Pair; import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockNewLeaf; +import net.minecraft.block.BlockNewLog; +import net.minecraft.block.BlockOldLeaf; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -51,9 +56,29 @@ public class GeneratorBigTree extends BOPGeneratorBase public Builder minHeight(int a) {this.minHeight = a; return this;} public Builder maxHeight(int a) {this.maxHeight = a; return this;} public Builder log(IBlockState a) {this.log = a; return this;} + public Builder log(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, a); + } else { + this.log = Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, a); + } + return this; + } public Builder log(BOPWoods a) {this.log = BlockBOPLog.paging.getVariantState(a); return this;} public Builder leaves(IBlockState a) {this.leaves = a; return this;} public Builder leaves(BOPTrees a) {this.leaves = BlockBOPLeaves.paging.getVariantState(a); return this;} + public Builder leaves(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, a); + } else { + this.leaves = Blocks.leaves2.getDefaultState().withProperty(BlockNewLeaf.VARIANT, a); + } + return this; + } @Override public GeneratorBigTree create() 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 2a326cf03..76db46856 100644 --- a/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java +++ b/src/main/java/biomesoplenty/common/world/feature/tree/GeneratorBush.java @@ -11,6 +11,11 @@ package biomesoplenty.common.world.feature.tree; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.BlockNewLeaf; +import net.minecraft.block.BlockNewLog; +import net.minecraft.block.BlockOldLeaf; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -37,8 +42,28 @@ public class GeneratorBush extends BOPGeneratorBase public Builder amountPerChunk(float a) {this.amountPerChunk = a; return this;} public Builder log(IBlockState a) {this.log = a; return this;} public Builder log(BOPWoods a) {this.log = BlockBOPLog.paging.getVariantState(a); return this;} + public Builder log(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.log = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, a); + } else { + this.log = Blocks.log2.getDefaultState().withProperty(BlockNewLog.VARIANT, a); + } + return this; + } public Builder leaves(IBlockState a) {this.leaves = a; return this;} public Builder leaves(BOPTrees a) {this.leaves = BlockBOPLeaves.paging.getVariantState(a); return this;} + public Builder leaves(BlockPlanks.EnumType a) + { + if (a.getMetadata() < 4) + { + this.leaves = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, a); + } else { + this.leaves = Blocks.leaves2.getDefaultState().withProperty(BlockNewLeaf.VARIANT, a); + } + return this; + } @Override public GeneratorBush create()