Block constructors refactoring and fixes
This commit is contained in:
parent
3dacd0727f
commit
f8eb65d600
18 changed files with 161 additions and 113 deletions
|
@ -30,7 +30,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BasePathBlock extends BaseBlockNotFull {
|
||||
private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 15, 16);
|
||||
|
||||
|
@ -56,11 +55,13 @@ public class BasePathBlock extends BaseBlockNotFull {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockM
|
|||
}
|
||||
|
||||
public BaseRotatedPillarBlock(Block block) {
|
||||
super(FabricBlockSettings.copyOf(block));
|
||||
this(FabricBlockSettings.copyOf(block));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,10 +64,7 @@ public class BaseSignBlock extends SignBlock implements BlockModelProvider, Cust
|
|||
|
||||
public BaseSignBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(1.0F, 1.0F).noCollission().noOcclusion(), WoodType.OAK);
|
||||
this.registerDefaultState(this.stateDefinition.any()
|
||||
.setValue(ROTATION, 0)
|
||||
.setValue(FLOOR, false)
|
||||
.setValue(WATERLOGGED, false));
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(ROTATION, 0).setValue(FLOOR, false).setValue(WATERLOGGED, false));
|
||||
this.parent = source;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public BaseStairsBlock(Block source) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.sounds.SoundEvents;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class BaseStoneButtonBlock extends BaseButtonBlock {
|
||||
|
||||
public BaseStoneButtonBlock(Block source) {
|
||||
super(source, FabricBlockSettings.copyOf(source).noOcclusion(), false);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
@ -29,7 +30,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseTrapdoorBlock extends TrapDoorBlock implements RenderLayerProvider, BlockModelProvider {
|
||||
public BaseTrapdoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion());
|
||||
this(FabricBlockSettings.copyOf(source).strength(3.0F, 3.0F).noOcclusion());
|
||||
}
|
||||
|
||||
public BaseTrapdoorBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
@ -15,22 +14,25 @@ import net.minecraft.world.level.material.Fluids;
|
|||
import net.minecraft.world.level.material.Material;
|
||||
|
||||
public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock implements LiquidBlockContainer {
|
||||
|
||||
public BaseUnderwaterWallPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseUnderwaterWallPlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseUnderwaterWallPlantBlock(Properties settings) {
|
||||
|
|
|
@ -50,12 +50,18 @@ public class BaseVineBlock extends BaseBlockNotFull implements RenderLayerProvid
|
|||
}
|
||||
|
||||
public BaseVineBlock(int light, boolean bottomOnly) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> bottomOnly ? state.getValue(SHAPE) == TripleShape.BOTTOM ? light : 0 : light)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseVineBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(SHAPE, TripleShape.BOTTOM));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
public BaseWallBlock(Block source) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package ru.bclib.blocks;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
|
@ -29,32 +28,32 @@ import java.util.EnumMap;
|
|||
|
||||
public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
||||
private static final EnumMap<Direction, VoxelShape> SHAPES = Maps.newEnumMap(ImmutableMap.of(
|
||||
Direction.NORTH,
|
||||
Block.box(1, 1, 8, 15, 15, 16),
|
||||
Direction.SOUTH,
|
||||
Block.box(1, 1, 0, 15, 15, 8),
|
||||
Direction.WEST,
|
||||
Block.box(8, 1, 1, 16, 15, 15),
|
||||
Direction.EAST,
|
||||
Block.box(0, 1, 1, 8, 15, 15)
|
||||
Direction.NORTH, Block.box(1, 1, 8, 15, 15, 16),
|
||||
Direction.SOUTH, Block.box(1, 1, 0, 15, 15, 8),
|
||||
Direction.WEST, Block.box(8, 1, 1, 16, 15, 15),
|
||||
Direction.EAST, Block.box(0, 1, 1, 8, 15, 15)
|
||||
));
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public BaseWallPlantBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseWallPlantBlock(int light) {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseWallPlantBlock(Properties settings) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.sounds.SoundEvents;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class BaseWoodenButtonBlock extends BaseButtonBlock {
|
||||
|
||||
public BaseWoodenButtonBlock(Block source) {
|
||||
super(source, FabricBlockSettings.copyOf(source).strength(0.5F, 0.5F).noOcclusion(), true);
|
||||
}
|
||||
|
|
|
@ -4,18 +4,27 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class FeatureHangingSaplingBlock extends FeatureSaplingBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||
public FeatureHangingSaplingBlock() {
|
||||
super();
|
||||
|
||||
public FeatureHangingSaplingBlock(Function<BlockState, Feature<?>> featureSupplier) {
|
||||
super(featureSupplier);
|
||||
}
|
||||
|
||||
public FeatureHangingSaplingBlock(int light) {
|
||||
super(light);
|
||||
public FeatureHangingSaplingBlock(Function<BlockState, Feature<?>> featureSupplier, int light) {
|
||||
super(light, featureSupplier);
|
||||
}
|
||||
|
||||
public FeatureHangingSaplingBlock(BlockBehaviour.Properties properties, Function<BlockState, Feature<?>> featureSupplier) {
|
||||
super(properties, featureSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package ru.bclib.blocks;
|
|||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import ru.bclib.api.TagAPI;
|
||||
|
@ -10,29 +11,37 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
|
||||
public class SimpleLeavesBlock extends BaseBlockNotFull implements RenderLayerProvider {
|
||||
public SimpleLeavesBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.color(color)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
|
||||
TagAPI.addTags(this, TagAPI.BLOCK_LEAVES);
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.LEAVES)
|
||||
.strength(0.2F)
|
||||
.color(color)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false)
|
||||
);
|
||||
}
|
||||
|
||||
public SimpleLeavesBlock(MaterialColor color, int light) {
|
||||
super(FabricBlockSettings.of(Material.LEAVES)
|
||||
.luminance(light)
|
||||
.color(color)
|
||||
.strength(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false));
|
||||
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.LEAVES)
|
||||
.luminance(light)
|
||||
.color(color)
|
||||
.strength(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.noOcclusion()
|
||||
.isValidSpawn((state, world, pos, type) -> false)
|
||||
.isSuffocating((state, world, pos) -> false)
|
||||
.isViewBlocking((state, world, pos) -> false)
|
||||
);
|
||||
}
|
||||
|
||||
public SimpleLeavesBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
// TODO handle all tags instead of adding them like this
|
||||
TagAPI.addTags(this, TagAPI.BLOCK_LEAVES);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LiquidBlockContainer;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
|
@ -50,11 +51,12 @@ public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterlogg
|
|||
private static final VoxelShape[] SHAPES;
|
||||
|
||||
public StalactiteBlock(Block source) {
|
||||
super(FabricBlockSettings.copy(source).noOcclusion());
|
||||
this.registerDefaultState(getStateDefinition().any()
|
||||
.setValue(SIZE, 0)
|
||||
.setValue(IS_FLOOR, true)
|
||||
.setValue(WATERLOGGED, false));
|
||||
this(FabricBlockSettings.copy(source).noOcclusion());
|
||||
}
|
||||
|
||||
public StalactiteBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(getStateDefinition().any().setValue(SIZE, 0).setValue(IS_FLOOR, true).setValue(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,25 +36,28 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock, LiquidBlockContainer {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
public UnderwaterPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public UnderwaterPlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public UnderwaterPlantBlock(Properties settings) {
|
||||
|
@ -62,6 +65,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
Vec3 vec3d = state.getOffset(view, pos);
|
||||
return SHAPE.move(vec3d.x, vec3d.y, vec3d.z);
|
||||
|
@ -73,6 +77,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
state = world.getBlockState(pos);
|
||||
|
@ -82,6 +87,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
protected abstract boolean isTerrain(BlockState state);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (!canSurvive(state, world, pos)) {
|
||||
world.destroyBlock(pos, true);
|
||||
|
@ -144,6 +150,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return Fluids.WATER.getSource(false);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ru.bclib.blocks;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.WorldGenLevel;
|
||||
|
@ -18,12 +17,14 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
|||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public UnderwaterPlantWithAgeBlock() {
|
||||
super(FabricBlockSettings.of(Material.WATER_PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
super(
|
||||
FabricBlockSettings
|
||||
.of(Material.WATER_PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.randomTicks()
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
@ -28,26 +29,32 @@ import ru.bclib.interfaces.RenderLayerProvider;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements RenderLayerProvider {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
||||
|
||||
public UpDownPlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
this(FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public UpDownPlantBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
protected abstract boolean isTerrain(BlockState state);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
BlockState up = world.getBlockState(pos.above());
|
||||
|
@ -59,6 +66,7 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements Rende
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (!canSurvive(state, world, pos)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
|
|
|
@ -2,12 +2,12 @@ package ru.bclib.blocks;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
@ -16,14 +16,20 @@ import java.util.List;
|
|||
|
||||
public abstract class WallMushroomBlock extends BaseWallPlantBlock {
|
||||
public WallMushroomBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.AXES)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.destroyTime(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.sound(SoundType.WOOD)
|
||||
.noCollission());
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.destroyTime(0.2F)
|
||||
.sound(SoundType.GRASS)
|
||||
.sound(SoundType.WOOD)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public WallMushroomBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue