Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've been trying to register my cart entity to `RenderingRegistry`but I have been receiving errors I am having a hard time understanding.

 

I register my entity renderer like this:

    public static void registerRenderers(final FMLClientSetupEvent event) {
        RenderingRegistry.registerEntityRenderingHandler(AllEntities.MINER_CART_ENTITY.get(), MinerModuleCartRenderer::new);
    }

and this is my MinerModuleCartRenderer:

@OnlyIn(Dist.CLIENT)
public class MinerModuleCartRenderer<T extends AbstractMinecartEntity> extends EntityRenderer<T> {

    private static final ResourceLocation MINER_TEXTURE = new ResourceLocation(MODID + ":textures/entity/miner_cart_module.png");
    private final EntityModel<T> modelCartModule = new MinerCartModuleModel<>();

    public MinerModuleCartRenderer(EntityRendererManager renderManager) {
        super(renderManager);
    }

    public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
  	// [...] long code copied from MinecartRenderer directly
    }

    public ResourceLocation getEntityTexture(T entity) {
        return MINER_TEXTURE;
    }

    protected void renderBlockState(T entity, float partialTicks, BlockState state, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
        Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY);
    }
}

but I get this error:

Bad return type in method reference: cannot convert com.than00ber.gameoflife.client.renderer.entity.MinerModuleCartRenderer<T> to net.minecraft.client.renderer.entity.EntityRenderer<? super ?>

(I get the same error when trying to register Minecraft's `MinercartRenderer` like this)

 

I've looked into Minecraft 's source code and noticed that it registers its entity renderers like this:

   public <T extends Entity> void register(EntityType<T> entityTypeIn, EntityRenderer<? super T> entityRendererIn) {
      this.renderers.put(entityTypeIn, entityRendererIn);
   }

but Forge with `IRenderFactory`:

    public static <T extends Entity> void registerEntityRenderingHandler(EntityType<T> entityClass, IRenderFactory<? super T> renderFactory)
    {
        INSTANCE.entityRenderers.put(entityClass, renderFactory);
    }

so I implemented `IRenderFactorty` in `MinerModuleCartRenderer` to see if it makes a difference but to no avail; the error stays the same.

 

Any idea why that is and how can I solve this?

 

Now I know this is more of Java error but I figured I'll get a better shot here since people have prior knowledge. 

I made something similar to your code and it seems to work, so the problem appears with some code not posted

Edited by lupicus

  • Author

I was able to solve the issue by rewriting all classes (must have gotten a class extending the wrong thing I think) but why shouldn't I use @OnlyIn on the renderers? Isn't it just client-side?

Edit: Should I remove all @OnlyIn?

Edited by than00ber1

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.