than00ber1 Posted June 2, 2021 Posted June 2, 2021 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. Quote
lupicus Posted June 4, 2021 Posted June 4, 2021 (edited) I made something similar to your code and it seems to work, so the problem appears with some code not posted Edited June 4, 2021 by lupicus Quote
than00ber1 Posted June 4, 2021 Author Posted June 4, 2021 (edited) 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 June 4, 2021 by than00ber1 Quote
Recommended Posts
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.