Use CustomBlockEntityType
With the CustomBlockEntityType class provided by the MModding Library, registering a new BlockEntityType is more simple.
Create your BlockEntity class
public class MModdingBlockEntity extends BlockEntity {
public MModdingBlockEntity(BlockPos pos, BlockState state) {
super(NOTHING, pos, state);
}
}
"NOTHING" is not permanent, we will replace it later.
Create and register your BlockEntityType
In your BlockEntityTypes class :
public class BlockEntityTypes {
public static final CustomBlockEntityType<TestBlockEntity> TEST = new CustomBlockEntityType<>(MModdingBlockEntity::new, BLOCK)
.createAndRegister(new Identifier("mmodding_exemple_mod", "testBlockEntityType"));
}
Update your BlockEntity class
Replace "NOTHING" by your BlockEntityType :
public class MModdingBlockEntity extends BlockEntity {
public MModdingBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.TEST.getBlockEntityTypeIfCreated(), pos, state);
}
}
Last updated