Feature getter replacement
This commit is contained in:
parent
eb15218a62
commit
29a9c9f613
2 changed files with 15 additions and 9 deletions
|
@ -1,10 +1,17 @@
|
||||||
package ru.betterend.blocks;
|
package ru.betterend.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
import ru.betterend.blocks.basis.BlockFeatureSapling;
|
||||||
import ru.betterend.registry.FeatureRegistry;
|
import ru.betterend.registry.FeatureRegistry;
|
||||||
|
|
||||||
public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
|
public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
|
||||||
public BlockMossyGlowshroomSapling() {
|
public BlockMossyGlowshroomSapling() {
|
||||||
super(FeatureRegistry.MOSSY_GLOWSHROOM, 7);
|
super(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Feature<DefaultFeatureConfig> getFeature() {
|
||||||
|
return FeatureRegistry.MOSSY_GLOWSHROOM.getFeature();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,25 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldAccess;
|
import net.minecraft.world.WorldAccess;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
|
import net.minecraft.world.gen.feature.Feature;
|
||||||
import ru.betterend.client.ERenderLayer;
|
import ru.betterend.client.ERenderLayer;
|
||||||
import ru.betterend.client.IRenderTypeable;
|
import ru.betterend.client.IRenderTypeable;
|
||||||
import ru.betterend.registry.BlockTagRegistry;
|
import ru.betterend.registry.BlockTagRegistry;
|
||||||
import ru.betterend.util.BlocksHelper;
|
import ru.betterend.util.BlocksHelper;
|
||||||
import ru.betterend.world.features.EndFeature;
|
|
||||||
|
|
||||||
public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
|
public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
|
||||||
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 2, 4, 12, 16, 12);
|
||||||
private final EndFeature feature;
|
|
||||||
|
|
||||||
public BlockFeatureSapling(EndFeature feature) {
|
public BlockFeatureSapling() {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT)
|
||||||
.breakByHand(true)
|
.breakByHand(true)
|
||||||
.collidable(false)
|
.collidable(false)
|
||||||
.breakInstantly()
|
.breakInstantly()
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
.sounds(BlockSoundGroup.GRASS)
|
||||||
.ticksRandomly());
|
.ticksRandomly());
|
||||||
this.feature = feature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFeatureSapling(EndFeature feature, int light) {
|
public BlockFeatureSapling(int light) {
|
||||||
super(FabricBlockSettings.of(Material.PLANT)
|
super(FabricBlockSettings.of(Material.PLANT)
|
||||||
.breakByHand(true)
|
.breakByHand(true)
|
||||||
.collidable(false)
|
.collidable(false)
|
||||||
|
@ -47,9 +45,10 @@ public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizabl
|
||||||
.sounds(BlockSoundGroup.GRASS)
|
.sounds(BlockSoundGroup.GRASS)
|
||||||
.lightLevel(light)
|
.lightLevel(light)
|
||||||
.ticksRandomly());
|
.ticksRandomly());
|
||||||
this.feature = feature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract Feature<DefaultFeatureConfig> getFeature();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
|
||||||
return SHAPE;
|
return SHAPE;
|
||||||
|
@ -81,7 +80,7 @@ public class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizabl
|
||||||
@Override
|
@Override
|
||||||
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, Blocks.AIR.getDefaultState());
|
BlocksHelper.setWithoutUpdate(world, pos, Blocks.AIR.getDefaultState());
|
||||||
feature.getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, DefaultFeatureConfig.INSTANCE);
|
getFeature().generate(world, world.getChunkManager().getChunkGenerator(), random, pos, DefaultFeatureConfig.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue