Various fixes

This commit is contained in:
Aleksey 2021-06-22 16:05:46 +03:00
parent dccb49f51c
commit 7d79452220
52 changed files with 130 additions and 101 deletions

View file

@ -1,5 +1,6 @@
package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag;
@ -26,13 +27,13 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
private NonNullList<ItemStack> inventory;
private int viewerCount;
private BaseBarrelBlockEntity(BlockEntityType<?> type) {
super(type);
private BaseBarrelBlockEntity(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) {
super(type, blockPos, blockState);
this.inventory = NonNullList.withSize(27, ItemStack.EMPTY);
}
public BaseBarrelBlockEntity() {
this(BaseBlockEntities.BARREL);
public BaseBarrelBlockEntity(BlockPos blockPos, BlockState blockState) {
this(BaseBlockEntities.BARREL, blockPos, blockState);
}
public CompoundTag save(CompoundTag tag) {
@ -44,8 +45,8 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
return tag;
}
public void load(BlockState state, CompoundTag tag) {
super.load(state, tag);
public void load(CompoundTag tag) {
super.load(tag);
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
if (!this.tryLoadLootTable(tag)) {
ContainerHelper.loadAllItems(tag, this.inventory);
@ -97,10 +98,7 @@ public class BaseBarrelBlockEntity extends RandomizableContainerBlockEntity {
public void tick() {
if (level != null) {
int x = worldPosition.getX();
int y = worldPosition.getY();
int z = worldPosition.getZ();
viewerCount = ChestBlockEntity.getOpenCount(level, this, x, y, z);
viewerCount = ChestBlockEntity.getOpenCount(level, worldPosition);
if (viewerCount > 0) {
scheduleUpdate();
} else {

View file

@ -1,10 +1,12 @@
package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.registry.BaseBlockEntities;
public class BaseChestBlockEntity extends ChestBlockEntity {
public BaseChestBlockEntity() {
super(BaseBlockEntities.CHEST);
public BaseChestBlockEntity(BlockPos blockPos, BlockState blockState) {
super(BaseBlockEntities.CHEST, blockPos, blockState);
}
}

View file

@ -1,5 +1,6 @@
package ru.bclib.blockentities;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
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.item.crafting.RecipeType;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import ru.bclib.registry.BaseBlockEntities;
public class BaseFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
public BaseFurnaceBlockEntity() {
super(BaseBlockEntities.FURNACE, RecipeType.SMELTING);
public BaseFurnaceBlockEntity(BlockPos blockPos, BlockState blockState) {
super(BaseBlockEntities.FURNACE, blockPos, blockState, RecipeType.SMELTING);
}
protected Component getDefaultName() {

View file

@ -38,6 +38,7 @@ public class DynamicBlockEntityType<T extends BlockEntity> extends BlockEntityTy
}
@FunctionalInterface
public
interface BlockEntitySupplier<T extends BlockEntity> {
T create(BlockPos blockPos, BlockState blockState);
}