Hello and thank you for your answer.
I'm afraid that the Block class doesn't have an overridable createTileEntity function neither a hasTileEntity function as shown in your examples :
EDIT : ok, I was mispelling it. But it doesn't solve my problem with datafixers for now. I'm looking depper in your examples right now.
/**
* User: The Grey Ghost
* Date: 11/01/2015
*
* BlockTileEntityData is a ordinary solid cube with an associated TileEntity
* For background information on block see here http://greyminecraftcoder.blogspot.com.au/2014/12/blocks-18.html
*/
public class BlockTileEntityData extends Block
{
public BlockTileEntityData()
{
super(Block.Properties.create(Material.ROCK)
);
}
private final int TIMER_COUNTDOWN_TICKS = 20 * 10; // duration of the countdown, in ticks = 10 seconds
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
// Called when the block is placed or loaded client side to get the tile entity for the block
// Should return a new instance of the tile entity for the block
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {return new TileEntityData();}
// Called just after the player places a block. Start the tileEntity's timer
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityData) { // prevent a crash if not the right type, or is null
TileEntityData tileEntityData = (TileEntityData)tileentity;
tileEntityData.setTicksLeftTillDisappear(TIMER_COUNTDOWN_TICKS);
}
}
// render using a BakedModel
// not required because the default (super method) is MODEL
@Override
public BlockRenderType getRenderType(BlockState iBlockState) {
return BlockRenderType.MODEL;
}
}
Without ITileEntityProvider implementation, there is not these functions.
I'm using forge 1.15.2 31.1.0
It's not the only problem I encounter : there is a lot of "func_id_x_" functions in the API, and I don't have the setters for Block properties.
Even in the last implemented TileEntityBlocks, as the lectern, I see a use of the ITileEntityProvider, and in the net.minecraft.block code, it's not marked as deprecated.
EDIT 2 : I can see that the TileEntityType.Builder.create().build() function is marked as @NotNull
EDIT 3 : I solved the problem by adding the library Gradle: com.mojang:datafixerupper:2.0.24 to my classpath, IntelliJ didn't ask me until I decomposed the assignation in :
TileEntityType.Builder<NIHayTileEntity> builder = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay);
tileEntityNIHayBlock = builder.build(null);