#Is there a way to make a block container?
1 messages · Page 1 of 1 (latest)
Yes, you can create custom inventories for your blocks using a class inheriting ContainerInventory and using a BlockEntity holding an inventory
You can build on top of this:
public class MyBlockEntity extends BlockEntitySpawnableContainer {
@Override
protected ContainerInventory requireContainerInventory() {
return new MyInventory(this);
}
@Override
public Inventory getInventory() {
return this.inventory;
}
}
public class MyInventory extends ContainerInventory {
public MyInventory(MyBlockEntity blockEntity) {
super(blockEntity, InventoryType.INVENTORY, 27); // can also be dropper, hopper, ... - 27 for slots
}
public MyBlockEntity getHolder() {
return (MyBlockEntity) super.getHolder();
}
}
Missing here is the block itself and the inventory opening logic + stuff you may want to customize