Jump to content

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


Recommended Posts

Posted (edited)

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
Posted
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.

Posted (edited)
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
Posted (edited)
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
Posted

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

 

 

 

 

 

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Could you send a screenshot of your weapon code? Here is the one I made (for a dagger): protected static final double DAGGER_REACH_MOD = -1.5D; protected final Multimap<Attribute, AttributeModifier> defaultModifiers;     public DaggerItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) {         super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties);         this.attackDamage = (float) pAttackDamageModifier + pTier.getAttackDamageBonus();         ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();         builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", this.attackDamage, AttributeModifier.Operation.ADDITION));         builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", pAttackSpeedModifier, AttributeModifier.Operation.ADDITION));         builder.put(ForgeMod.ENTITY_REACH.get(), new AttributeModifier(ToolUtils.BASE_ATTACK_REACH_UUID, "Weapon modifier", DAGGER_REACH_MOD, AttributeModifier.Operation.ADDITION));         this.defaultModifiers = builder.build(); } @Override     public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot pEquipmentSlot) {         return pEquipmentSlot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(pEquipmentSlot);     }
    • https://images.app.goo.gl/1PxFKdxByTgkxvSu6
    • That's what we'll try out. I could never figure out how to recreate the crash, so I'll just have to wait and see.
    • Ok, I updated to the latest version and now the models are visible, the problem now is that the glowing eyes are not rendered nor any texture I render there when using shaders, even using the default Minecraft eyes RenderType, I use entityTranslucent and entityCutout, but it still won't render. Something I noticed when using shaders is that a texture, instead of appearing at the world position, would appear somewhere on the screen, following a curved path, it was strange, I haven't been able to reproduce it again. I thought it could be that since I render the texture in the AFTER ENTITIES stage which is posted after the batches used for entity rendering are finished, maybe that was the reason why the render types were not being drawn correctly, so I tried injecting code before finishing the batches but it still didn't work, plus the model was invisible when using shaders, there was a bug where if I look at the model from above it is visible but if I look at it from below it is invisible. So in summary, models are now visible but glowing eyes and textures are not rendered, that hasn't changed.
    • https://pastebin.com/99FA0zvK Attempting to run genIntellijRuns, this task fails with pasted error. IntelliJ IDEA 2024.3 (Community Edition) eclipse_adoptium-21-x86_64-os_x.2/jdk-21.0.6+7 Steps followed: Step 1: Open your command-line and browse to the folder where you extracted the zip file. Step 2: You're left with a choice. If you prefer to use Eclipse: 1. Run the following command: `./gradlew genEclipseRuns` 2. Open Eclipse, Import > Existing Gradle Project > Select Folder    or run `gradlew eclipse` to generate the project. If you prefer to use IntelliJ: 1. Open IDEA, and import project. 2. Select your build.gradle file and have it import. 3. Run the following command: `./gradlew genIntellijRuns` 4. Refresh the Gradle Project in IDEA if required.
  • Topics

×
×
  • Create New...

Important Information

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