Don't use ContainerBlock as the subclass due to it using the createNewTileEntity

This commit is contained in:
alexbegt committed 2020-03-18 11:59:13 -04:00
1 parent 84b5537285
commit 224f10e3a6
1 file changed
+17 -2
@@ -3,11 +3,11 @@ package slimeknights.mantle.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.ContainerBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
@@ -19,8 +19,9 @@ import net.minecraft.world.World;
import slimeknights.mantle.tileentity.InventoryTileEntity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class InventoryBlock extends ContainerBlock {
public abstract class InventoryBlock extends Block {
protected InventoryBlock(Block.Properties builder) {
super(builder);
@@ -91,4 +92,18 @@ public abstract class InventoryBlock extends ContainerBlock {
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public boolean eventReceived(BlockState state, World worldIn, BlockPos pos, int id, int param) {
super.eventReceived(state, worldIn, pos, id, param);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity != null && tileentity.receiveClientEvent(id, param);
}
@Override
@Nullable
public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof INamedContainerProvider ? (INamedContainerProvider)tileentity : null;
}
}