Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

TileEntity in multiple blocks [1.16.5]

Recommended Posts

I was creating a block that is bigger than 1x1x1 with a custom tile entity.
When i place the block, a part of the struct is spawned around (for now 1 single block above) and the tile entity is copied in the other position of the struct, but it result to be null.

Here is the code:

The Central Block:

public class ColossalChest extends BaseChestBlock {

    protected static final int SIZE = 5;

    public ColossalChest() {
        super(Block.Properties.of(Material.METAL), BaseChestTileEntityType.COLOSSAL_CHEST::get);

    public void playerWillDestroy(World world, BlockPos pos, BlockState state, PlayerEntity player) {
        super.playerWillDestroy(world, pos, state, player);
        destroyStructure(world, pos);

    private static final BlockState AIR = Blocks.AIR.defaultBlockState();

    private void destroyStructure(World world, BlockPos pos) {
        final BlockState STRUCT_BLOCK = com.ike.tenchest.Blocks.COLOSSAL_CHEST_PART.get().defaultBlockState();
        world.setBlockAndUpdate(pos, AIR);
        world.setBlockEntity(pos, null);
        BlockPos above = pos.above();
        if (world.getBlockState(above).equals(STRUCT_BLOCK))
            destroyStructure(world, above);
        BlockPos west = pos.west();
        if (world.getBlockState(west).equals(STRUCT_BLOCK))
            destroyStructure(world, west);
        BlockPos east = pos.east();
        if (world.getBlockState(east).equals(STRUCT_BLOCK))
            destroyStructure(world, east);
        BlockPos south = pos.south();
        if (world.getBlockState(south).equals(STRUCT_BLOCK))
            destroyStructure(world, south);
        BlockPos north = pos.north();
        if (world.getBlockState(north).equals(STRUCT_BLOCK))
            destroyStructure(world, north);
        BlockPos below = pos.below();
        if (world.getBlockState(below).equals(STRUCT_BLOCK))
            destroyStructure(world, below);

    public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
        if (entity instanceof PlayerEntity) {
            placeStructure(world, pos);
        super.setPlacedBy(world, pos, state, entity, stack);

    private void placeStructure(World world, BlockPos center) {
        final BlockState STRUCT_BLOCK = com.ike.tenchest.Blocks.COLOSSAL_CHEST_PART.get().defaultBlockState();
        TileEntity blockEntity = world.getBlockEntity(center);
        BlockPos above = center.above();
        world.setBlockAndUpdate(above, STRUCT_BLOCK);
        world.setBlockEntity(above, blockEntity);

    public boolean hasTileEntity(BlockState state) {
        return true;

    public TileEntity createTileEntity(BlockState state, IBlockReader world) {
        return new ColossalChestTileEntity();

And the Block of the struct: 

public class ColossalChestPart extends Block {

    public ColossalChestPart() {
        super(AbstractBlock.Properties.of(Material.BARRIER).strength(-1.0F, 3600000.8F).noDrops().noOcclusion());

    public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTrace) {
        if (world.isClientSide) {
            return ActionResultType.SUCCESS;
        } else {
            INamedContainerProvider inamedcontainerprovider = this.getMenuProvider(state, world, pos);
            if (inamedcontainerprovider != null) {
                PiglinTasks.angerNearbyPiglins(player, true);
            return ActionResultType.CONSUME;

    public INamedContainerProvider getMenuProvider(BlockState state, World world, BlockPos pos) {
        TileEntity entity = world.getBlockEntity(pos);
        return entity instanceof INamedContainerProvider ? (INamedContainerProvider) entity : null;

    public boolean propagatesSkylightDown(BlockState p_200123_1_, IBlockReader p_200123_2_, BlockPos p_200123_3_) {
        return true;

    public BlockRenderType getRenderShape(BlockState p_149645_1_) {
        return BlockRenderType.INVISIBLE;

    public float getShadeBrightness(BlockState p_220080_1_, IBlockReader p_220080_2_, BlockPos p_220080_3_) {
        return 1.0F;

In the getMenuProvider function of the ColossalChestPart the TileEntity result to be Null.

Link to post
Share on other sites

How can I make multiple blocks interact with a single main TileEntity?
Maybe I could create a TileEntity for the ColossalChestPart to which I pass the main TileEntity?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • The durability of my custom Item goes down only for a second then goes back to where it was before I clicked. I'd really appreciate if someone can point me in the right direction to get this working. @Override public ActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) { ItemStack stack = playerEntity.getItemInHand(hand); if (!world.isClientSide) { ItemStack newStack = new ItemStack(stack.getItem()); newStack.setDamageValue(stack.getDamageValue() + 1); return ActionResult.success(newStack); } else return super.use(world, playerEntity, hand); }
    • biome.getRegistryName().equals(Biomes.SWAMP.location())  
    • Java 16 is not yet supported.
    • It is about the Java version. You cannot use Java 16. 
    • C:\Users\rauno\OneDrive\Töölaud\Uus kaust>java -Xmx2048M -Xms2048M -jar forgeserver.jar nogui 2021-06-21 10:09:17,374 main WARN Advanced terminal features are not available in this environment [10:09:17] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.0, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [10:09:17] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 16.0.1 by Oracle Corporation Exception in thread "main" java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x29f69090) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x29f69090         at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:41)         at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)         at cpw.mods.modlauncher.SecureJarHandler.<clinit>(SecureJarHandler.java:41)         at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)         at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)         at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)         at cpw.mods.modlauncher.Launcher.<init>(Launcher.java:55)         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\rauno\OneDrive\Töölaud\Uus kaust>PAUSE is it saying for me when i am first opening it 
  • Topics

  • Who's Online (See full list)

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.