Jump to content

[Solved][1.15.2] Cannot access com.mojang.datafixers.types.Type (registering TileEntityType)


Orionss

Recommended Posts

Hello, I have troubles while trying to register a new TileEntityType.

I get the error :

Cannot access com.mojang.datafixers.types.Type

for this sample :

        @SubscribeEvent
        public static void onTileEntitiesTypeRegistry(final RegistryEvent.Register<TileEntityType<?>> entitiesRegistryEvent) {
            TileEntityType<?> type = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay).build(null);
            entitiesRegistryEvent.getRegistry().register(e);
        }

 

I get the error on the first line of the function, where type is initialized.

My TileEntity :

public class NIHayTileEntity extends TileEntity {
    public NIHayTileEntity() {
        super(NatureImprovedMod.tileEntityNIHay);
    }
}

 

I've taken the example of the FurnaceTileEntity, but it seems that ITileEntityProvider was marked as deprecated. I can't figure why.

public class NIHayBlock extends Block implements ITileEntityProvider {

    public NIHayBlock() {
        super(Properties.create(Material.LEAVES).sound(SoundType.PLANT).hardnessAndResistance(0.25f));
    }

    @Override
    public TileEntity createNewTileEntity(IBlockReader worldIn) {
        return new NIHayTileEntity();
    }
}

 

Can you help me please ?

 

Addendum :

image.png.4f822364d7c32a92c2bf2147296e0eca.png

Edited by Orionss
Link to comment
Share on other sites

8 minutes ago, Orionss said:

TileEntityType<?> type = TileEntityType.Builder.create(NIHayTileEntity::new, blockNIHay).build(null);

I don't see anything wrong with this line except you are not giving it a registry name.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

I don't see anything wrong with this line except you are not giving it a registry name.

Yeah, I think it can be done in a second time. (it doesn't change anything if I do it anyway)

 

I would like to know if this is normal that ITileEntityProvider is seen as deprecated ? What should I use then ?

Edited by Orionss
Link to comment
Share on other sites

Hi

There's a working example of TileEntities in this project, it might give you some clues.

https://github.com/TheGreyGhost/MinecraftByExample (see mbe20, mbe21)

 

Cheers

 TGG

 

PS

@Deprecated //Forge: Do not use, use BlockState.hasTileEntity/Block.createTileEntity instead
public interface ITileEntityProvider {
   @Nullable
   TileEntity createNewTileEntity(IBlockReader worldIn);
}

 

Link to comment
Share on other sites

2 hours ago, TheGreyGhost said:

Hi

There's a working example of TileEntities in this project, it might give you some clues.

https://github.com/TheGreyGhost/MinecraftByExample (see mbe20, mbe21)

 

Cheers

 TGG

 

PS


@Deprecated //Forge: Do not use, use BlockState.hasTileEntity/Block.createTileEntity instead
public interface ITileEntityProvider {
   @Nullable
   TileEntity createNewTileEntity(IBlockReader worldIn);
}

 

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

image.thumb.png.b554bd52f1e0c043ced7f666377433ec.png

 

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);

 

Edited by Orionss
Link to comment
Share on other sites

Hi

Glad you resolved it.  I haven't see that problem before.

 

BTW I'd recommend that you move from "recommended" to "latest".  There are very many old mappings in recommended that are all fixed in "latest", it makes the vanilla code much easier to understand.  It won't stop modders from using your code with "recommended".

When using IDEA you'll probably need to manually exclude the older library from the project, otherwise every time you search for a method it will give two results- one from the old library and one from the newer.  I think this is because of the Forge gradle code but I haven't figured out exactly why.

 

-TGG

 

 

 

 

 

 

 

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.