Options
All
  • Public
  • Public/Protected
  • All
Menu

Module to register custom block entity types and assign them for specific blocks.

Unlike InnerCore's TileEntity, these entities are registered as vanilla tile types like chest, hopper, brewing stand, furnace etc., via native code.

A block entity type must be represented by a non-abstract Java class inherited from vsdum.kex.modules.tileentity.BlockActor (despite the latter class doesn't have any abstract methods required to implement).

After creating a tile entity class, register the numeric ID for it using TileEntityModule.registerTileEntityType method. You must store the returned value in order to use it later for the blocks that will have this tile entity type.

So, for example:

package visualstudiodan.test;

import vsdum.kex.modules.TileEntityModule;
import vsdum.kex.modules.tileentity.BlockActor;
import vsdum.kex.util.mcmath.BlockPos;

public class TestTile extends BlockActor {
public static final int TYPE = TileEntityModule.registerTileEntityType("test_tile", TestTile::new);
public TestTile(long ptr, int type, BlockPos blockPos) {
super(ptr, type, blockPos);
}
}

Then in JS/TS:

const TEST_TILE_TYPE = WRAP_JAVA("visualstudiodan.test.TestTile").TYPE;
IDRegistry.genBlockID("testBlock");
Block.createBlock("testBlock", [{...}]);
KEX.TileEntityModule.registerForBlock(BlockID.testBlock, TEST_TILE_TYPE);
since

4.0

Index

Functions

  • registerForBlock(blockID: number, type: number): void
  • Assigns the custom native block entity type by its given numeric ID, to the block by its given numeric ID. It means every time the block with given ID is placed, a tile of type of given ID will be created for this block, also calling a TileEntityCreationCallback you specified while registering this block entity type.

    since

    4.0

    Parameters

    • blockID: number
    • type: number

    Returns void

  • Registers new custom native block entity type

    since

    4.0

    Parameters

    • typeName: any_string

      unique string identifier of the new block entity type, traditionally in snake case

    • callback: TileEntityCreationCallback

      function that will be called every time the custom tile is about to be created, and must return the Java wrapper object of the tile

    Returns number

    generated numeric ID for the created block entity type. Should be stored somewhere in your code in order to assign this type for a block later using registerForBlock.

Generated using TypeDoc