From 1c86c6c0311fedf9e0b31feaac6e71aafdb15293 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Sun, 17 Mar 2019 21:39:07 +0300 Subject: [PATCH] Tree grow from sapling. Not correctly though ( --- .../techreborn/blocks/BlockRubberSapling.java | 24 +++++----- .../java/techreborn/blocks/RubberTree.java | 44 +++++++++++++++++++ 2 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 src/main/java/techreborn/blocks/RubberTree.java diff --git a/src/main/java/techreborn/blocks/BlockRubberSapling.java b/src/main/java/techreborn/blocks/BlockRubberSapling.java index d317eb538..6de9b523a 100644 --- a/src/main/java/techreborn/blocks/BlockRubberSapling.java +++ b/src/main/java/techreborn/blocks/BlockRubberSapling.java @@ -42,19 +42,19 @@ import java.util.Random; public class BlockRubberSapling extends BlockSapling { public BlockRubberSapling() { - super(new SpruceTree(), Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT)); + super(new RubberTree(), Block.Properties.create(Material.PLANTS).sound(SoundType.PLANT)); } - @Override - public void grow(IWorld worldIn, BlockPos pos, IBlockState state, Random rand) { - if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(worldIn, rand, pos)) { - return; - } - worldIn.removeBlock(pos); - if (!new RubberTreeGenerator(false).growTree(worldIn, rand, pos.getX(), pos.getY(), pos.getZ())) { - worldIn.setBlockState(pos, state, 3); // Re-add the sapling if the tree - // failed to grow - } - } +// @Override +// public void grow(IWorld worldIn, BlockPos pos, IBlockState state, Random rand) { +// if (!net.minecraftforge.event.ForgeEventFactory.saplingGrowTree(worldIn, rand, pos)) { +// return; +// } +// worldIn.removeBlock(pos); +// if (!new RubberTreeGenerator(false).growTree(worldIn, rand, pos.getX(), pos.getY(), pos.getZ())) { +// worldIn.setBlockState(pos, state, 3); // Re-add the sapling if the tree +// // failed to grow +// } +// } } diff --git a/src/main/java/techreborn/blocks/RubberTree.java b/src/main/java/techreborn/blocks/RubberTree.java new file mode 100644 index 000000000..4b5e7f7c2 --- /dev/null +++ b/src/main/java/techreborn/blocks/RubberTree.java @@ -0,0 +1,44 @@ +/* + * This file is part of TechReborn, licensed under the MIT License (MIT). + * + * Copyright (c) 2018 TechReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package techreborn.blocks; + +import java.util.Random; + +import net.minecraft.block.trees.AbstractTree; +import net.minecraft.world.gen.feature.AbstractTreeFeature; +import net.minecraft.world.gen.feature.NoFeatureConfig; +import techreborn.world.feature.RubberTreeFeature; + +/** + * @author drcrazy + * + */ +public class RubberTree extends AbstractTree { + + @Override + protected AbstractTreeFeature getTreeFeature(Random random) { + return new RubberTreeFeature(); + } +}