Tree grow from sapling. Not correctly though (

This commit is contained in:
drcrazy 2019-03-17 21:39:07 +03:00
parent 704ad8df07
commit 1c86c6c031
2 changed files with 56 additions and 12 deletions

View file

@ -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
// }
// }
}

View file

@ -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<NoFeatureConfig> getTreeFeature(Random random) {
return new RubberTreeFeature();
}
}