make FeatureSaplingBlock extend SaplingBlock

This commit is contained in:
CoolMineman 2021-05-07 19:38:36 -05:00
parent 9e3c7fc0be
commit 406e3648cb
No known key found for this signature in database
GPG key ID: AD76E368E7380CE5
3 changed files with 12 additions and 10 deletions

0
gradlew vendored Normal file → Executable file
View file

View file

@ -27,6 +27,7 @@ public class TenaneaFlowersBlock extends VineBlock implements IColorProvider {
@Override @Override
public BlockColor getProvider() { public BlockColor getProvider() {
return (state, world, pos, tintIndex) -> { return (state, world, pos, tintIndex) -> {
if (pos == null) pos = BlockPos.ZERO;
long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY(); long i = (MHelper.getRandom(pos.getX(), pos.getZ()) & 63) + pos.getY();
double delta = i * 0.1; double delta = i * 0.1;
int index = MHelper.floor(delta); int index = MHelper.floor(delta);

View file

@ -15,7 +15,7 @@ import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
@ -24,14 +24,15 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import ru.betterend.client.render.ERenderLayer; import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable; import ru.betterend.interfaces.IRenderTypeable;
import ru.betterend.patterns.BlockPatterned;
import ru.betterend.patterns.Patterns; import ru.betterend.patterns.Patterns;
import ru.betterend.registry.EndTags; import ru.betterend.registry.EndTags;
public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements BonemealableBlock, IRenderTypeable { public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTypeable, BlockPatterned {
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12); private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
public FeatureSaplingBlock() { public FeatureSaplingBlock() {
super(FabricBlockSettings.of(Material.PLANT) super(null, FabricBlockSettings.of(Material.PLANT)
.breakByHand(true) .breakByHand(true)
.collidable(false) .collidable(false)
.instabreak() .instabreak()
@ -40,7 +41,7 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Bo
} }
public FeatureSaplingBlock(int light) { public FeatureSaplingBlock(int light) {
super(FabricBlockSettings.of(Material.PLANT) super(null, FabricBlockSettings.of(Material.PLANT)
.breakByHand(true) .breakByHand(true)
.collidable(false) .collidable(false)
.luminance(light) .luminance(light)
@ -69,21 +70,21 @@ public abstract class FeatureSaplingBlock extends BlockBaseNotFull implements Bo
return state; return state;
} }
@Override
public boolean isValidBonemealTarget(BlockGetter world, BlockPos pos, BlockState state, boolean isClient) {
return true;
}
@Override @Override
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) { public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(16) == 0; return random.nextInt(16) == 0;
} }
@Override @Override
public void performBonemeal(ServerLevel world, Random random, BlockPos pos, BlockState state) { public void advanceTree(ServerLevel world, BlockPos pos, BlockState blockState, Random random) {
getFeature().place(world, world.getChunkSource().getGenerator(), random, pos, null); getFeature().place(world, world.getChunkSource().getGenerator(), random, pos, null);
} }
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
this.tick(state, world, pos, random);
}
@Override @Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) { public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
super.tick(state, world, pos, random); super.tick(state, world, pos, random);