CC-Tweaked/projects/common/src/main/java/dan200/computercraft/shared/common/AbstractContainerBlockEntit...

35 lines
1.2 KiB
Java

// SPDX-FileCopyrightText: 2022 The CC: Tweaked Developers
//
// SPDX-License-Identifier: MPL-2.0
package dan200.computercraft.shared.common;
import dan200.computercraft.shared.container.BasicContainer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
/**
* A {@link BlockEntity} which exposes an inventory.
*/
public abstract class AbstractContainerBlockEntity extends BaseContainerBlockEntity implements BasicContainer {
protected AbstractContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
@Override
protected final Component getDefaultName() {
return Component.translatable(getBlockState().getBlock().getDescriptionId());
}
@Override
public boolean stillValid(Player player) {
return Container.stillValidBlockEntity(this, player);
}
}