Block constructors refactoring
This commit is contained in:
parent
d6faafd4c0
commit
3dacd0727f
18 changed files with 146 additions and 84 deletions
|
@ -15,6 +15,7 @@ import net.minecraft.world.item.PickaxeItem;
|
|||
import net.minecraft.world.level.block.AnvilBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
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.IntegerProperty;
|
||||
|
@ -40,7 +41,11 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
|
|||
public IntegerProperty durability;
|
||||
|
||||
public BaseAnvilBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.ANVIL).color(color));
|
||||
this(FabricBlockSettings.copyOf(Blocks.ANVIL).color(color));
|
||||
}
|
||||
|
||||
public BaseAnvilBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.block.BarrelBlock;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
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.storage.loot.LootContext;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
@ -40,7 +41,11 @@ import java.util.Random;
|
|||
|
||||
public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||
public BaseBarrelBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
this(FabricBlockSettings.copyOf(source).noOcclusion());
|
||||
}
|
||||
|
||||
public BaseBarrelBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.world.level.BlockGetter;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class BaseBlockNotFull extends BaseBlock {
|
||||
|
||||
public BaseBlockNotFull(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.item.Items;
|
|||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
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.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
@ -24,7 +25,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseBookshelfBlock extends BaseBlock {
|
||||
public BaseBookshelfBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
this(FabricBlockSettings.copyOf(source));
|
||||
}
|
||||
|
||||
public BaseBookshelfBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelProvider {
|
||||
|
||||
private final Block parent;
|
||||
|
||||
protected BaseButtonBlock(Block parent, Properties properties, boolean sensitive) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.ChainBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
@ -28,7 +29,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, RenderLayerProvider {
|
||||
public BaseChainBlock(MaterialColor color) {
|
||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).color(color));
|
||||
this(FabricBlockSettings.copyOf(Blocks.CHAIN).color(color));
|
||||
}
|
||||
|
||||
public BaseChainBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,6 +8,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.CraftingTableBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -23,7 +24,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockModelProvider {
|
||||
public BaseCraftingTableBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source));
|
||||
this(FabricBlockSettings.copyOf(source));
|
||||
}
|
||||
|
||||
public BaseCraftingTableBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ 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.server.level.ServerLevel;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -31,19 +30,25 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
public class BaseCropBlock extends BasePlantBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
|
||||
public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 3);
|
||||
private static final VoxelShape SHAPE = Block.box(2, 0, 2, 14, 14, 14);
|
||||
|
||||
private final Block[] terrain;
|
||||
private final Item drop;
|
||||
|
||||
public BaseCropBlock(Item drop, Block... terrain) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
this(
|
||||
FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
.noCollission(),
|
||||
drop, terrain
|
||||
);
|
||||
}
|
||||
|
||||
public BaseCropBlock(BlockBehaviour.Properties properties, Item drop, Block... terrain) {
|
||||
super(properties);
|
||||
this.drop = drop;
|
||||
this.terrain = terrain;
|
||||
this.registerDefaultState(defaultBlockState().setValue(AGE, 0));
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.util.StringRepresentable;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DoorBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
|
||||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
|
||||
|
@ -31,7 +32,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseDoorBlock extends DoorBlock implements RenderLayerProvider, BlockModelProvider {
|
||||
public BaseDoorBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion());
|
||||
this(FabricBlockSettings.copyOf(source).strength(3F, 3F).noOcclusion());
|
||||
}
|
||||
|
||||
public BaseDoorBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,28 +37,32 @@ import ru.bclib.util.BlocksHelper;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
|
||||
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
||||
|
||||
public BaseDoublePlantBlock() {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
this(
|
||||
FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.noCollission());
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseDoublePlantBlock(int light) {
|
||||
super(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
this(
|
||||
FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.WET_GRASS)
|
||||
.sound(SoundType.GRASS)
|
||||
.lightLevel((state) -> state.getValue(TOP) ? light : 0)
|
||||
.noCollission());
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BaseDoublePlantBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
this.registerDefaultState(this.stateDefinition.any().setValue(TOP, false));
|
||||
}
|
||||
|
||||
|
@ -68,6 +72,7 @@ public abstract class BaseDoublePlantBlock 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);
|
||||
|
@ -79,6 +84,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements R
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
BlockState up = world.getBlockState(pos.above());
|
||||
|
@ -94,6 +100,7 @@ public abstract class BaseDoublePlantBlock 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 (!canStayAt(state, world, pos)) {
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
|
@ -39,7 +40,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider, RenderLayerProvider {
|
||||
public BaseFurnaceBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).lightLevel(state -> state.getValue(LIT) ? 13 : 0));
|
||||
this(FabricBlockSettings.copyOf(source).lightLevel(state -> state.getValue(LIT) ? 13 : 0));
|
||||
}
|
||||
|
||||
public BaseFurnaceBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,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.LadderBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -26,7 +27,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseLadderBlock extends LadderBlock implements RenderLayerProvider, BlockModelProvider {
|
||||
public BaseLadderBlock(Block block) {
|
||||
super(FabricBlockSettings.copyOf(block).noOcclusion());
|
||||
this(FabricBlockSettings.copyOf(block).noOcclusion());
|
||||
}
|
||||
|
||||
public BaseLadderBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,7 +2,6 @@ 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.client.renderer.block.model.BlockModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -28,11 +27,10 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
|||
protected final Block sapling;
|
||||
|
||||
private static FabricBlockSettings makeLeaves(MaterialColor color) {
|
||||
return FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||
return FabricBlockSettings
|
||||
.copyOf(Blocks.OAK_LEAVES)
|
||||
.mapColor(color)
|
||||
.requiresTool()
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
.breakByTool(FabricToolTags.HOES)
|
||||
.allowsSpawning((state, world, pos, type) -> false)
|
||||
.suffocates((state, world, pos) -> false)
|
||||
.blockVision((state, world, pos) -> false);
|
||||
|
|
|
@ -12,6 +12,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.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -29,7 +30,11 @@ import java.util.Optional;
|
|||
|
||||
public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvider, RenderLayerProvider {
|
||||
public BaseMetalBarsBlock(Block source) {
|
||||
super(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion());
|
||||
this(FabricBlockSettings.copyOf(source).strength(5.0F, 6.0F).noOcclusion());
|
||||
}
|
||||
|
||||
public BaseMetalBarsBlock(BlockBehaviour.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,24 +24,38 @@ import ru.bclib.util.MHelper;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
||||
private final Item dropItem;
|
||||
private final Supplier<Item> dropItem;
|
||||
private final int minCount;
|
||||
private final int maxCount;
|
||||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
||||
public BaseOreBlock(Supplier<Item> drop, int minCount, int maxCount, int experience) {
|
||||
this(drop, minCount, maxCount, experience, 0);
|
||||
|
||||
}
|
||||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience, int miningLevel) {
|
||||
this(drop, minCount, maxCount, experience, miningLevel, FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||
public BaseOreBlock(Supplier<Item> drop, int minCount, int maxCount, int experience, int miningLevel) {
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(Material.STONE, MaterialColor.SAND)
|
||||
.requiresTool()
|
||||
.destroyTime(3F)
|
||||
.explosionResistance(9F)
|
||||
.sound(SoundType.STONE));
|
||||
.sound(SoundType.STONE),
|
||||
drop, minCount, maxCount, experience, miningLevel
|
||||
);
|
||||
}
|
||||
|
||||
public BaseOreBlock(Properties properties, Supplier<Item> drop, int minCount, int maxCount, int experience) {
|
||||
this(properties, drop, minCount, maxCount, experience, 0);
|
||||
}
|
||||
|
||||
public BaseOreBlock(Properties properties, Supplier<Item> drop, int minCount, int maxCount, int experience, int miningLevel) {
|
||||
super(makeProps(properties, miningLevel), UniformInt.of(experience>0?1:0, experience));
|
||||
this.dropItem = drop;
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
}
|
||||
|
||||
private static Properties makeProps(Properties properties, int level){
|
||||
|
@ -49,21 +63,10 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
|||
return properties;
|
||||
}
|
||||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience, Properties properties) {
|
||||
this(drop, minCount, maxCount, experience, 0, properties);
|
||||
}
|
||||
|
||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience, int miningLevel, Properties properties) {
|
||||
super(makeProps(properties, miningLevel), UniformInt.of(experience>0?1:0, experience));
|
||||
this.dropItem = drop;
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
return getDroppedItems(this, dropItem, maxCount, minCount, state, builder);
|
||||
return getDroppedItems(this, dropItem.get(), maxCount, minCount, state, builder);
|
||||
}
|
||||
|
||||
public static List<ItemStack> getDroppedItems(ItemLike block, Item dropItem, int maxCount, int minCount, BlockState state, LootContext.Builder builder) {
|
||||
|
|
|
@ -41,7 +41,6 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderLayerProvider, BonemealableBlock {
|
||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 14, 12);
|
||||
|
||||
|
@ -54,20 +53,24 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable) {
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantBlock(boolean replaceable, int light) {
|
||||
super(FabricBlockSettings.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
this(
|
||||
FabricBlockSettings
|
||||
.of(replaceable ? Material.REPLACEABLE_PLANT : Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.luminance(light)
|
||||
.sound(SoundType.GRASS)
|
||||
.noCollission());
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantBlock(Properties settings) {
|
||||
|
@ -77,6 +80,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
protected abstract boolean isTerrain(BlockState state);
|
||||
|
||||
@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);
|
||||
|
@ -88,12 +92,14 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements RenderL
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||
BlockState down = world.getBlockState(pos.below());
|
||||
return isTerrain(down);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
|
|
@ -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.Level;
|
||||
|
@ -19,12 +18,13 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
|||
public static final IntegerProperty AGE = BlockProperties.AGE;
|
||||
|
||||
public BasePlantWithAgeBlock() {
|
||||
this(FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByTool(FabricToolTags.SHEARS)
|
||||
this(
|
||||
FabricBlockSettings.of(Material.PLANT)
|
||||
.breakByHand(true)
|
||||
.sound(SoundType.GRASS)
|
||||
.randomTicks()
|
||||
.noCollission());
|
||||
.noCollission()
|
||||
);
|
||||
}
|
||||
|
||||
public BasePlantWithAgeBlock(Properties settings) {
|
||||
|
|
|
@ -65,8 +65,8 @@ public class FeatureSaplingBlock extends SaplingBlock implements RenderLayerProv
|
|||
);
|
||||
}
|
||||
|
||||
public FeatureSaplingBlock(BlockBehaviour.Properties settings, Function<BlockState, Feature<?>> featureSupplier) {
|
||||
super(null, settings);
|
||||
public FeatureSaplingBlock(BlockBehaviour.Properties properties, Function<BlockState, Feature<?>> featureSupplier) {
|
||||
super(null, properties);
|
||||
this.feature = featureSupplier;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue