Various fixes
This commit is contained in:
parent
dccb49f51c
commit
7d79452220
52 changed files with 130 additions and 101 deletions
|
@ -1,5 +1,6 @@
|
||||||
package ru.bclib.blockentities;
|
package ru.bclib.blockentities;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.core.Vec3i;
|
import net.minecraft.core.Vec3i;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -26,13 +27,13 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
private NonNullList<ItemStack> inventory;
|
private NonNullList<ItemStack> inventory;
|
||||||
private int viewerCount;
|
private int viewerCount;
|
||||||
|
|
||||||
private BaseBarrelBlockEntity(BlockEntityType<?> type) {
|
private BaseBarrelBlockEntity(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) {
|
||||||
super(type);
|
super(type, blockPos, blockState);
|
||||||
this.inventory = NonNullList.withSize(27, ItemStack.EMPTY);
|
this.inventory = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseBarrelBlockEntity() {
|
public BaseBarrelBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
this(BaseBlockEntities.BARREL);
|
this(BaseBlockEntities.BARREL, blockPos, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag save(CompoundTag tag) {
|
public CompoundTag save(CompoundTag tag) {
|
||||||
|
@ -44,8 +45,8 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(BlockState state, CompoundTag tag) {
|
public void load(CompoundTag tag) {
|
||||||
super.load(state, tag);
|
super.load(tag);
|
||||||
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
if (!this.tryLoadLootTable(tag)) {
|
if (!this.tryLoadLootTable(tag)) {
|
||||||
ContainerHelper.loadAllItems(tag, this.inventory);
|
ContainerHelper.loadAllItems(tag, this.inventory);
|
||||||
|
@ -97,10 +98,7 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
|
|
||||||
public void tick() {
|
public void tick() {
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
int x = worldPosition.getX();
|
viewerCount = ChestBlockEntity.getOpenCount(level, worldPosition);
|
||||||
int y = worldPosition.getY();
|
|
||||||
int z = worldPosition.getZ();
|
|
||||||
viewerCount = ChestBlockEntity.getOpenCount(level, this, x, y, z);
|
|
||||||
if (viewerCount > 0) {
|
if (viewerCount > 0) {
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package ru.bclib.blockentities;
|
package ru.bclib.blockentities;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.bclib.registry.BaseBlockEntities;
|
import ru.bclib.registry.BaseBlockEntities;
|
||||||
|
|
||||||
public class BaseChestBlockEntity extends ChestBlockEntity {
|
public class BaseChestBlockEntity extends ChestBlockEntity {
|
||||||
public BaseChestBlockEntity() {
|
public BaseChestBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
super(BaseBlockEntities.CHEST);
|
super(BaseBlockEntities.CHEST, blockPos, blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ru.bclib.blockentities;
|
package ru.bclib.blockentities;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
@ -7,11 +8,12 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.FurnaceMenu;
|
import net.minecraft.world.inventory.FurnaceMenu;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import ru.bclib.registry.BaseBlockEntities;
|
import ru.bclib.registry.BaseBlockEntities;
|
||||||
|
|
||||||
public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
|
public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
|
||||||
public BaseFurnaceBlockEntity() {
|
public BaseFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
super(BaseBlockEntities.FURNACE, RecipeType.SMELTING);
|
super(BaseBlockEntities.FURNACE, blockPos, blockState, RecipeType.SMELTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Component getDefaultName() {
|
protected Component getDefaultName() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityTy
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
|
public
|
||||||
interface BlockEntitySupplier<T extends BlockEntity> {
|
interface BlockEntitySupplier<T extends BlockEntity> {
|
||||||
T create(BlockPos blockPos, BlockState blockState);
|
T create(BlockPos blockPos, BlockState blockState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
|
||||||
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
public static final IntegerProperty DESTRUCTION = BlockProperties.DESTRUCTION;
|
||||||
|
|
||||||
public BaseAnvilBlock(MaterialColor color) {
|
public BaseAnvilBlock(MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.ANVIL).materialColor(color));
|
super(FabricBlockSettings.copyOf(Blocks.ANVIL).mapColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,8 +43,9 @@ public abstract class BaseAnvilBlock extends AnvilBlock implements BlockModelPro
|
||||||
super.createBlockStateDefinition(builder);
|
super.createBlockStateDefinition(builder);
|
||||||
builder.add(DESTRUCTION);
|
builder.add(DESTRUCTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack dropStack = new ItemStack(this);
|
ItemStack dropStack = new ItemStack(this);
|
||||||
int destruction = state.getValue(DESTRUCTION);
|
int destruction = state.getValue(DESTRUCTION);
|
||||||
|
|
|
@ -16,12 +16,13 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class BaseAttachedBlock extends BaseBlockNotFull {
|
public abstract class BaseAttachedBlock extends BaseBlockNotFull {
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
|
||||||
public BaseAttachedBlock(Properties settings) {
|
public BaseAttachedBlock(Properties settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.UP));
|
registerDefaultState(defaultBlockState().setValue(FACING, Direction.UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +32,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
|
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
|
||||||
BlockState blockState = this.defaultBlockState();
|
BlockState blockState = defaultBlockState();
|
||||||
LevelReader worldView = ctx.getLevel();
|
LevelReader worldView = ctx.getLevel();
|
||||||
BlockPos blockPos = ctx.getClickedPos();
|
BlockPos blockPos = ctx.getClickedPos();
|
||||||
Direction[] directions = ctx.getNearestLookingDirections();
|
Direction[] directions = ctx.getNearestLookingDirections();
|
||||||
|
@ -47,7 +48,7 @@ public abstract class BaseAttachedBlock extends BaseBlockNotFull {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||||
Direction direction = (Direction) state.getValue(FACING);
|
Direction direction = state.getValue(FACING);
|
||||||
BlockPos blockPos = pos.relative(direction.getOpposite());
|
BlockPos blockPos = pos.relative(direction.getOpposite());
|
||||||
return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES);
|
return canSupportCenter(world, blockPos, direction) || world.getBlockState(blockPos).is(BlockTags.LEAVES);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,12 @@ public class BaseBarrelBlock extends BarrelBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
return BaseBlockEntities.BARREL.create();
|
return BaseBlockEntities.BARREL.create(blockPos, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
List<ItemStack> drop = super.getDrops(state, builder);
|
List<ItemStack> drop = super.getDrops(state, builder);
|
||||||
drop.add(new ItemStack(this.asItem()));
|
drop.add(new ItemStack(this.asItem()));
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class BaseBlock extends Block implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ru.bclib.blocks;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||||
|
@ -16,11 +17,12 @@ public class BaseBlockWithEntity extends BaseEntityBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public abstract class BaseButtonBlock extends ButtonBlock implements BlockModelP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,11 @@ import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped {
|
public class BaseChainBlock extends ChainBlock implements BlockModelProvider, IRenderTyped {
|
||||||
public BaseChainBlock(MaterialColor color) {
|
public BaseChainBlock(MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.CHAIN).materialColor(color));
|
super(FabricBlockSettings.copyOf(Blocks.CHAIN).mapColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package ru.bclib.blocks;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
|
@ -33,12 +34,12 @@ public class BaseChestBlock extends ChestBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockGetter world)
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
{
|
return BaseBlockEntities.CHEST.create(blockPos, blockState);
|
||||||
return BaseBlockEntities.CHEST.create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder)
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder)
|
||||||
{
|
{
|
||||||
List<ItemStack> drop = super.getDrops(state, builder);
|
List<ItemStack> drop = super.getDrops(state, builder);
|
||||||
|
|
|
@ -28,8 +28,9 @@ public class BaseComposterBlock extends ComposterBlock implements BlockModelProv
|
||||||
public BaseComposterBlock(Block source) {
|
public BaseComposterBlock(Block source) {
|
||||||
super(FabricBlockSettings.copyOf(source));
|
super(FabricBlockSettings.copyOf(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class BaseCraftingTableBlock extends CraftingTableBlock implements BlockM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,9 @@ public class BaseCropBlock extends BasePlantBlock {
|
||||||
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return state.getValue(AGE) < 3;
|
return state.getValue(AGE) < 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
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);
|
||||||
if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) {
|
if (isBonemealSuccess(world, random, pos, state) && random.nextInt(8) == 0) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class BaseDoorBlock extends DoorBlock implements IRenderTyped, BlockModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
if (state.getValue(HALF) == DoubleBlockHalf.LOWER)
|
if (state.getValue(HALF) == DoubleBlockHalf.LOWER)
|
||||||
return Collections.singletonList(new ItemStack(this.asItem()));
|
return Collections.singletonList(new ItemStack(this.asItem()));
|
||||||
|
|
|
@ -38,6 +38,7 @@ import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 2, 4, 12, 16, 12);
|
||||||
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
|
public static final IntegerProperty ROTATION = BlockProperties.ROTATION;
|
||||||
|
@ -110,7 +111,7 @@ public abstract class BaseDoublePlantBlock extends BaseBlockNotFull implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class BaseFenceBlock extends FenceBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockGetter world) {
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
return new BaseFurnaceBlockEntity();
|
return new BaseFurnaceBlockEntity(blockPos, blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,8 +95,9 @@ public class BaseFurnaceBlock extends FurnaceBlock implements BlockModelProvider
|
||||||
public BCLRenderLayer getRenderLayer() {
|
public BCLRenderLayer getRenderLayer() {
|
||||||
return BCLRenderLayer.CUTOUT;
|
return BCLRenderLayer.CUTOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
|
List<ItemStack> drop = Lists.newArrayList(new ItemStack(this));
|
||||||
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
BlockEntity blockEntity = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class BaseGateBlock extends FenceGateBlock implements BlockModelProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider {
|
public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, BlockModelProvider {
|
||||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||||
|
@ -57,17 +58,14 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
|
||||||
stateManager.add(WATERLOGGED);
|
stateManager.add(WATERLOGGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
public VoxelShape getShape(BlockState state, BlockGetter view, BlockPos pos, CollisionContext ePos) {
|
||||||
switch (state.getValue(FACING)) {
|
return switch (state.getValue(FACING)) {
|
||||||
case SOUTH:
|
case SOUTH -> SOUTH_SHAPE;
|
||||||
return SOUTH_SHAPE;
|
case WEST -> WEST_SHAPE;
|
||||||
case WEST:
|
case EAST -> EAST_SHAPE;
|
||||||
return WEST_SHAPE;
|
default -> NORTH_SHAPE;
|
||||||
case EAST:
|
};
|
||||||
return EAST_SHAPE;
|
|
||||||
default:
|
|
||||||
return NORTH_SHAPE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) {
|
private boolean canPlaceOn(BlockGetter world, BlockPos pos, Direction side) {
|
||||||
|
@ -78,7 +76,7 @@ public class BaseLadderBlock extends BaseBlockNotFull implements IRenderTyped, B
|
||||||
@Override
|
@Override
|
||||||
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
|
||||||
Direction direction = state.getValue(FACING);
|
Direction direction = state.getValue(FACING);
|
||||||
return this.canPlaceOn(world, pos.relative(direction.getOpposite()), direction);
|
return canPlaceOn(world, pos.relative(direction.getOpposite()), direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
|
|
||||||
public BaseLeavesBlock(Block sapling, MaterialColor color) {
|
public BaseLeavesBlock(Block sapling, MaterialColor color) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||||
.materialColor(color)
|
.mapColor(color)
|
||||||
.breakByTool(FabricToolTags.HOES)
|
.breakByTool(FabricToolTags.HOES)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.breakByTool(FabricToolTags.SHEARS)
|
||||||
.breakByHand(true)
|
.breakByHand(true)
|
||||||
|
@ -41,7 +41,7 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
|
|
||||||
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
|
public BaseLeavesBlock(Block sapling, MaterialColor color, int light) {
|
||||||
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
super(FabricBlockSettings.copyOf(Blocks.OAK_LEAVES)
|
||||||
.materialColor(color)
|
.mapColor(color)
|
||||||
.luminance(light)
|
.luminance(light)
|
||||||
.breakByTool(FabricToolTags.HOES)
|
.breakByTool(FabricToolTags.HOES)
|
||||||
.breakByTool(FabricToolTags.SHEARS)
|
.breakByTool(FabricToolTags.SHEARS)
|
||||||
|
@ -55,12 +55,13 @@ public class BaseLeavesBlock extends LeavesBlock implements BlockModelProvider,
|
||||||
public BCLRenderLayer getRenderLayer() {
|
public BCLRenderLayer getRenderLayer() {
|
||||||
return BCLRenderLayer.CUTOUT;
|
return BCLRenderLayer.CUTOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
if (tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
|
int fortune = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_FORTUNE, tool);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
@ -99,7 +100,7 @@ public class BaseMetalBarsBlock extends IronBarsBlock implements BlockModelProvi
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
|
public boolean skipRendering(BlockState state, BlockState stateFrom, Direction direction) {
|
||||||
if (direction.getAxis().isVertical() && stateFrom.getBlock().is(this) && !stateFrom.equals(state)) {
|
if (direction.getAxis().isVertical() && stateFrom.getBlock() == this && !stateFrom.equals(state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return super.skipRendering(state, stateFrom, direction);
|
return super.skipRendering(state, stateFrom, direction);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.util.valueproviders.UniformInt;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||||
|
@ -26,26 +27,20 @@ public class BaseOreBlock extends OreBlock implements BlockModelProvider {
|
||||||
private final Item dropItem;
|
private final Item dropItem;
|
||||||
private final int minCount;
|
private final int minCount;
|
||||||
private final int maxCount;
|
private final int maxCount;
|
||||||
private final int experience;
|
|
||||||
|
|
||||||
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
public BaseOreBlock(Item drop, int minCount, int maxCount, int experience) {
|
||||||
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
super(FabricBlockSettings.of(Material.STONE, MaterialColor.SAND)
|
||||||
.hardness(3F)
|
.hardness(3F)
|
||||||
.resistance(9F)
|
.resistance(9F)
|
||||||
.requiresCorrectToolForDrops()
|
.requiresCorrectToolForDrops()
|
||||||
.sound(SoundType.STONE));
|
.sound(SoundType.STONE), UniformInt.of(1, experience));
|
||||||
this.dropItem = drop;
|
this.dropItem = drop;
|
||||||
this.minCount = minCount;
|
this.minCount = minCount;
|
||||||
this.maxCount = maxCount;
|
this.maxCount = maxCount;
|
||||||
this.experience = experience;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int xpOnDrop(Random random) {
|
|
||||||
return this.experience > 0 ? random.nextInt(experience) + 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.isCorrectToolForDrops(state)) {
|
if (tool != null && tool.isCorrectToolForDrops(state)) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
public abstract class BasePlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||||
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);
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ public abstract class BasePlantBlock extends BaseBlockNotFull implements IRender
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -53,8 +53,9 @@ public abstract class BasePlantWithAgeBlock extends BasePlantBlock {
|
||||||
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
public boolean isBonemealSuccess(Level world, Random random, BlockPos pos, BlockState state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
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);
|
||||||
if (random.nextInt(8) == 0) {
|
if (random.nextInt(8) == 0) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class BasePressurePlateBlock extends PressurePlateBlock implements BlockM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,9 @@ public class BaseRotatedPillarBlock extends RotatedPillarBlock implements BlockM
|
||||||
public BaseRotatedPillarBlock(Block block) {
|
public BaseRotatedPillarBlock(Block block) {
|
||||||
super(FabricBlockSettings.copyOf(block));
|
super(FabricBlockSettings.copyOf(block));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ import ru.bclib.client.models.ModelsHelper;
|
||||||
import ru.bclib.interfaces.ISpetialItem;
|
import ru.bclib.interfaces.ISpetialItem;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
public class BaseSignBlock extends SignBlock implements BlockModelProvider, ISpetialItem {
|
||||||
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
|
public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
|
||||||
public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
|
public static final BooleanProperty FLOOR = BooleanProperty.create("floor");
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class BaseSlabBlock extends SlabBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class BaseStairsBlock extends StairBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,14 @@ public class BaseStripableLogBlock extends BaseRotatedPillarBlock {
|
||||||
private final Block striped;
|
private final Block striped;
|
||||||
|
|
||||||
public BaseStripableLogBlock(MaterialColor color, Block striped) {
|
public BaseStripableLogBlock(MaterialColor color, Block striped) {
|
||||||
super(FabricBlockSettings.copyOf(striped).materialColor(color));
|
super(FabricBlockSettings.copyOf(striped).mapColor(color));
|
||||||
this.striped = striped;
|
this.striped = striped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) {
|
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
|
||||||
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);
|
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class BaseTerrainBlock extends BaseBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if (pathBlock != null && player.getMainHandItem().getItem().is(FabricToolTags.SHOVELS)) {
|
if (pathBlock != null && FabricToolTags.SHOVELS.contains(player.getMainHandItem().getItem())) {
|
||||||
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
world.setBlockAndUpdate(pos, pathBlock.defaultBlockState());
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class BaseTrapdoorBlock extends TrapDoorBlock implements IRenderTyped, Bl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ public abstract class BaseUnderwaterWallPlantBlock extends BaseWallPlantBlock im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public FluidState getFluidState(BlockState state) {
|
public FluidState getFluidState(BlockState state) {
|
||||||
return Fluids.WATER.getSource(false);
|
return Fluids.WATER.getSource(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
import ru.bclib.util.BlocksHelper;
|
import ru.bclib.util.BlocksHelper;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock {
|
||||||
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
|
||||||
private static final VoxelShape VOXEL_SHAPE = Block.box(2, 0, 2, 14, 16, 14);
|
private static final VoxelShape VOXEL_SHAPE = Block.box(2, 0, 2, 14, 16, 14);
|
||||||
|
@ -106,7 +107,7 @@ public class BaseVineBlock extends BaseBlockNotFull implements IRenderTyped, Bon
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class BaseWallBlock extends WallBlock implements BlockModelProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,11 +113,13 @@ public abstract class BaseWallPlantBlock extends BasePlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public BlockState rotate(BlockState state, Rotation rotation) {
|
public BlockState rotate(BlockState state, Rotation rotation) {
|
||||||
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
return BlocksHelper.rotateHorizontal(state, rotation, FACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public BlockState mirror(BlockState state, Mirror mirror) {
|
public BlockState mirror(BlockState state, Mirror mirror) {
|
||||||
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
return BlocksHelper.mirrorHorizontal(state, mirror, FACING);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class BaseWeightedPlateBlock extends WeightedPressurePlateBlock implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
return Collections.singletonList(new ItemStack(this));
|
return Collections.singletonList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
|
@ -36,6 +37,7 @@ import ru.bclib.client.models.PatternsHelper;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider {
|
public abstract class FeatureSaplingBlock extends SaplingBlock implements IRenderTyped, BlockModelProvider {
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped
|
||||||
public SimpleLeavesBlock(MaterialColor color) {
|
public SimpleLeavesBlock(MaterialColor color) {
|
||||||
super(FabricBlockSettings.of(Material.LEAVES)
|
super(FabricBlockSettings.of(Material.LEAVES)
|
||||||
.strength(0.2F)
|
.strength(0.2F)
|
||||||
.materialColor(color)
|
.mapColor(color)
|
||||||
.sound(SoundType.GRASS)
|
.sound(SoundType.GRASS)
|
||||||
.noOcclusion()
|
.noOcclusion()
|
||||||
.isValidSpawn((state, world, pos, type) -> false)
|
.isValidSpawn((state, world, pos, type) -> false)
|
||||||
|
@ -22,7 +22,7 @@ public class SimpleLeavesBlock extends BaseBlockNotFull implements IRenderTyped
|
||||||
public SimpleLeavesBlock(MaterialColor color, int light) {
|
public SimpleLeavesBlock(MaterialColor color, int light) {
|
||||||
super(FabricBlockSettings.of(Material.LEAVES)
|
super(FabricBlockSettings.of(Material.LEAVES)
|
||||||
.luminance(light)
|
.luminance(light)
|
||||||
.materialColor(color)
|
.mapColor(color)
|
||||||
.strength(0.2F)
|
.strength(0.2F)
|
||||||
.sound(SoundType.GRASS)
|
.sound(SoundType.GRASS)
|
||||||
.noOcclusion()
|
.noOcclusion()
|
||||||
|
|
|
@ -43,6 +43,7 @@ import ru.bclib.client.models.PatternsHelper;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped {
|
public class StalactiteBlock extends BaseBlockNotFull implements SimpleWaterloggedBlock, LiquidBlockContainer, IRenderTyped {
|
||||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||||
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
|
public static final BooleanProperty IS_FLOOR = BlockProperties.IS_FLOOR;
|
||||||
|
|
|
@ -20,13 +20,14 @@ public class StripableBarkBlock extends BaseBarkBlock {
|
||||||
private final Block striped;
|
private final Block striped;
|
||||||
|
|
||||||
public StripableBarkBlock(MaterialColor color, Block striped) {
|
public StripableBarkBlock(MaterialColor color, Block striped) {
|
||||||
super(FabricBlockSettings.copyOf(striped).materialColor(color));
|
super(FabricBlockSettings.copyOf(striped).mapColor(color));
|
||||||
this.striped = striped;
|
this.striped = striped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
if (player.getMainHandItem().getItem().is(FabricToolTags.AXES)) {
|
if (FabricToolTags.AXES.contains(player.getMainHandItem().getItem())) {
|
||||||
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
world.playSound(player, pos, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);
|
world.setBlock(pos, striped.defaultBlockState().setValue(RotatedPillarBlock.AXIS, state.getValue(RotatedPillarBlock.AXIS)), 11);
|
||||||
|
|
|
@ -37,6 +37,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer {
|
public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements IRenderTyped, BonemealableBlock, LiquidBlockContainer {
|
||||||
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);
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ public abstract class UnderwaterPlantBlock extends BaseBlockNotFull implements I
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -47,6 +47,7 @@ public abstract class UnderwaterPlantWithAgeBlock extends UnderwaterPlantBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
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);
|
||||||
if (isBonemealSuccess(world, random, pos, state)) {
|
if (isBonemealSuccess(world, random, pos, state)) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import ru.bclib.client.render.BCLRenderLayer;
|
import ru.bclib.client.render.BCLRenderLayer;
|
||||||
import ru.bclib.interfaces.IRenderTyped;
|
import ru.bclib.interfaces.IRenderTyped;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped {
|
public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRenderTyped {
|
||||||
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
private static final VoxelShape SHAPE = Block.box(4, 0, 4, 12, 16, 12);
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ public abstract class UpDownPlantBlock extends BaseBlockNotFull implements IRend
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
ItemStack tool = builder.getParameter(LootContextParams.TOOL);
|
||||||
if (tool != null && tool.getItem().is(FabricToolTags.SHEARS) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
if (tool != null && FabricToolTags.SHEARS.contains(tool.getItem()) || EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) > 0) {
|
||||||
return Lists.newArrayList(new ItemStack(this));
|
return Lists.newArrayList(new ItemStack(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package ru.bclib.client.render;
|
package ru.bclib.client.render;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
|
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
|
@ -21,18 +18,15 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.AbstractChestBlock;
|
import net.minecraft.world.level.block.*;
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.ChestBlock;
|
|
||||||
import net.minecraft.world.level.block.DoubleBlockCombiner;
|
|
||||||
import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult;
|
import net.minecraft.world.level.block.DoubleBlockCombiner.NeighborCombineResult;
|
||||||
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
import net.minecraft.world.level.block.entity.ChestBlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.LidBlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.ChestType;
|
import net.minecraft.world.level.block.state.properties.ChestType;
|
||||||
import ru.bclib.blockentities.BaseChestBlockEntity;
|
import ru.bclib.blockentities.BaseChestBlockEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChestBlockEntity> {
|
public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChestBlockEntity> {
|
||||||
private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap();
|
private static final HashMap<Block, RenderType[]> LAYERS = Maps.newHashMap();
|
||||||
|
@ -87,8 +81,8 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
||||||
public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
|
public void render(BaseChestBlockEntity entity, float tickDelta, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay) {
|
||||||
Level world = entity.getLevel();
|
Level world = entity.getLevel();
|
||||||
boolean worldExists = world != null;
|
boolean worldExists = world != null;
|
||||||
BlockState blockState = worldExists ? entity.getBlockState() : (BlockState) Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH);
|
BlockState blockState = worldExists ? entity.getBlockState() : Blocks.CHEST.defaultBlockState().setValue(ChestBlock.FACING, Direction.SOUTH);
|
||||||
ChestType chestType = blockState.hasProperty(ChestBlock.TYPE) ? (ChestType) blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE;
|
ChestType chestType = blockState.hasProperty(ChestBlock.TYPE) ? blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE;
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
if (block instanceof AbstractChestBlock) {
|
if (block instanceof AbstractChestBlock) {
|
||||||
AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block;
|
AbstractChestBlock<?> abstractChestBlock = (AbstractChestBlock<?>) block;
|
||||||
|
@ -107,7 +101,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
||||||
propertySource = DoubleBlockCombiner.Combiner::acceptNone;
|
propertySource = DoubleBlockCombiner.Combiner::acceptNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner((LidBlockEntity) entity))).get(tickDelta);
|
float pitch = ((Float2FloatFunction) propertySource.apply(ChestBlock.opennessCombiner(entity))).get(tickDelta);
|
||||||
pitch = 1.0F - pitch;
|
pitch = 1.0F - pitch;
|
||||||
pitch = 1.0F - pitch * pitch * pitch;
|
pitch = 1.0F - pitch * pitch * pitch;
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
@ -138,15 +132,11 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RenderType getChestTexture(ChestType type, RenderType[] layers) {
|
private static RenderType getChestTexture(ChestType type, RenderType[] layers) {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case LEFT:
|
case LEFT -> layers[ID_LEFT];
|
||||||
return layers[ID_LEFT];
|
case RIGHT -> layers[ID_RIGHT];
|
||||||
case RIGHT:
|
default -> layers[ID_NORMAL];
|
||||||
return layers[ID_RIGHT];
|
};
|
||||||
case SINGLE:
|
|
||||||
default:
|
|
||||||
return layers[ID_NORMAL];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) {
|
public static VertexConsumer getConsumer(MultiBufferSource provider, Block block, ChestType chestType) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class BaseDrinkItem extends ModelProviderItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
|
||||||
return ItemUtils.useDrink(world, user, hand);
|
return ItemUtils.startUsingInstantly(world, user, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,13 +41,12 @@ public class BaseDrinkItem extends ModelProviderItem {
|
||||||
stack.setCount(count);
|
stack.setCount(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user instanceof ServerPlayer) {
|
if (user instanceof ServerPlayer serverPlayerEntity) {
|
||||||
ServerPlayer serverPlayerEntity = (ServerPlayer) user;
|
|
||||||
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
|
CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayerEntity, stack);
|
||||||
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
|
serverPlayerEntity.awardStat(Stats.ITEM_USED.get(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user instanceof Player && !((Player) user).abilities.instabuild) {
|
if (user instanceof Player && !((Player) user).getAbilities().instabuild) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.renderer.block.model.BlockModel;
|
import net.minecraft.client.renderer.block.model.BlockModel;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.item.SpawnEggItem;
|
import net.minecraft.world.item.SpawnEggItem;
|
||||||
import ru.bclib.client.models.BasePatterns;
|
import ru.bclib.client.models.BasePatterns;
|
||||||
import ru.bclib.client.models.ItemModelProvider;
|
import ru.bclib.client.models.ItemModelProvider;
|
||||||
|
@ -14,7 +15,7 @@ import ru.bclib.client.models.ModelsHelper;
|
||||||
import ru.bclib.client.models.PatternsHelper;
|
import ru.bclib.client.models.PatternsHelper;
|
||||||
|
|
||||||
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
public class BaseSpawnEggItem extends SpawnEggItem implements ItemModelProvider {
|
||||||
public BaseSpawnEggItem(EntityType<?> type, int primaryColor, int secondaryColor, Properties settings) {
|
public BaseSpawnEggItem(EntityType<? extends Mob> type, int primaryColor, int secondaryColor, Properties settings) {
|
||||||
super(type, primaryColor, secondaryColor, settings);
|
super(type, primaryColor, secondaryColor, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import ru.bclib.blockentities.BaseChestBlockEntity;
|
||||||
import ru.bclib.blockentities.BaseFurnaceBlockEntity;
|
import ru.bclib.blockentities.BaseFurnaceBlockEntity;
|
||||||
import ru.bclib.blockentities.BaseSignBlockEntity;
|
import ru.bclib.blockentities.BaseSignBlockEntity;
|
||||||
import ru.bclib.blockentities.DynamicBlockEntityType;
|
import ru.bclib.blockentities.DynamicBlockEntityType;
|
||||||
|
import ru.bclib.blockentities.DynamicBlockEntityType.BlockEntitySupplier;
|
||||||
import ru.bclib.blocks.BaseBarrelBlock;
|
import ru.bclib.blocks.BaseBarrelBlock;
|
||||||
import ru.bclib.blocks.BaseChestBlock;
|
import ru.bclib.blocks.BaseChestBlock;
|
||||||
import ru.bclib.blocks.BaseFurnaceBlock;
|
import ru.bclib.blocks.BaseFurnaceBlock;
|
||||||
|
@ -24,7 +25,7 @@ public class BaseBlockEntities {
|
||||||
public static final DynamicBlockEntityType<BaseSignBlockEntity> SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new);
|
public static final DynamicBlockEntityType<BaseSignBlockEntity> SIGN = registerBlockEntityType(BCLib.makeID("sign"), BaseSignBlockEntity::new);
|
||||||
public static final DynamicBlockEntityType<BaseFurnaceBlockEntity> FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new);
|
public static final DynamicBlockEntityType<BaseFurnaceBlockEntity> FURNACE = registerBlockEntityType(BCLib.makeID("furnace"), BaseFurnaceBlockEntity::new);
|
||||||
|
|
||||||
public static <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, Supplier<? extends T> supplier) {
|
public static <T extends BlockEntity> DynamicBlockEntityType<T> registerBlockEntityType(ResourceLocation typeId, BlockEntitySupplier<? extends T> supplier) {
|
||||||
return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier));
|
return Registry.register(Registry.BLOCK_ENTITY_TYPE, typeId, new DynamicBlockEntityType<>(supplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.tags.Tag;
|
import net.minecraft.tags.Tag;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.entity.MobSpawnType;
|
import net.minecraft.world.entity.MobSpawnType;
|
||||||
import net.minecraft.world.food.FoodProperties;
|
import net.minecraft.world.food.FoodProperties;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
@ -67,7 +68,7 @@ public abstract class ItemsRegistry extends BaseRegistry<Item> {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item registerEgg(String name, EntityType<?> type, int background, int dots) {
|
public Item registerEgg(String name, EntityType<? extends Mob> type, int background, int dots) {
|
||||||
SpawnEggItem item = new BaseSpawnEggItem(type, background, dots, makeItemSettings());
|
SpawnEggItem item = new BaseSpawnEggItem(type, background, dots, makeItemSettings());
|
||||||
DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() {
|
DefaultDispenseItemBehavior behavior = new DefaultDispenseItemBehavior() {
|
||||||
public ItemStack execute(BlockSource pointer, ItemStack stack) {
|
public ItemStack execute(BlockSource pointer, ItemStack stack) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class StructureWorld {
|
||||||
|
|
||||||
public BoundingBox getBounds() {
|
public BoundingBox getBounds() {
|
||||||
if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) {
|
if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE || minZ == Integer.MAX_VALUE || maxZ == Integer.MIN_VALUE) {
|
||||||
return BoundingBox.getUnknownBox();
|
return BoundingBox.infinite();
|
||||||
}
|
}
|
||||||
return new BoundingBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15);
|
return new BoundingBox(minX << 4, minY, minZ << 4, (maxX << 4) | 15, maxY, (maxZ << 4) | 15);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue