Jump to content

[1.11.2] (UNSOLVED) Help with rendering entity in Main class.


BlockExpert
 Share

Recommended Posts

Main class code is as follows

 

Spoiler

package com.planetbravo.mainmod;

import net.minecraft.client.model.ModelWolf;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION)
public class Main {
    
    public static final String MODID = "mainmod";
    public static final String MODNAME = "ENTER MOD NAME HERE";
    public static final String VERSION = "1.0.0";
    
    @Instance
    public static Main instance = new Main();
        
    @SidedProxy(clientSide="com.planetbravo.mainmod.ClientProxy")
    public static CommonProxy proxy;

    @EventHandler
    public void preInit(FMLPreInitializationEvent e) {
        this.proxy.preInit(e);
        Register.addRecipes();
        registerEntity(EntityDogOne.class, "entitydogone");
    }

    @EventHandler
    public void init(FMLInitializationEvent e) {
        this.proxy.init(e);
    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent e) {
        this.proxy.postInit(e);
        RenderingRegistry.registerEntityRenderingHandler(EntityDogOne.class, new RenderDogOne(new ModelWolf(), 0.5F));
    }
}

 

Link to comment
Share on other sites

Rendering for your entities must be registered during pre-init. Not init and not post-init.

 

The way you are registering your renderer is deprecated and outdated. Use RenderingRegistry::registerEntityRenderingHandler(Class, IRenderFactory) instead of RenderingRegistry::registerEntityRenderingHandler(Class, Render)

 

You can't have client-side only code in your common class like that or you will crash the server. Move it to your client proxy.

Link to comment
Share on other sites

8 minutes ago, V0idWa1k3r said:

Rendering for your entities must be registered during pre-init. Not init and not post-init.

 

The way you are registering your renderer is deprecated and outdated. Use RenderingRegistry::registerEntityRenderingHandler(Class, IRenderFactory) instead of RenderingRegistry::registerEntityRenderingHandler(Class, Render)

 

You can't have client-side only code in your common class like that or you will crash the server. Move it to your client proxy.

Could you send me a fixed version or am I asking too much :P

Link to comment
Share on other sites

9 minutes ago, V0idWa1k3r said:

Rendering for your entities must be registered during pre-init. Not init and not post-init.

 

The way you are registering your renderer is deprecated and outdated. Use RenderingRegistry::registerEntityRenderingHandler(Class, IRenderFactory) instead of RenderingRegistry::registerEntityRenderingHandler(Class, Render)

 

You can't have client-side only code in your common class like that or you will crash the server. Move it to your client proxy.

I can also send my clientproxy if u need

Link to comment
Share on other sites

You are already using a proxy, so you must be aware of how to use it correctly and do not need someone else to write code for you here. 

IRenderFactory is a functional interface you can either use a lambda/method reference for or you can create your implementation of it. 

 

Can you show your RenderDogOne class? Every Render child class needs a RenderManager as a parameter and yours does not have one so I would like to see what you are passing as RenderManager in your RenderDogOne constructor's super call. This is one of the reasons to use IRenderFactory - it has RenderManager passed to it as an argument.

Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

You are already using a proxy, so you must be aware of how to use it correctly and do not need someone else to write code for you here. 

IRenderFactory is a functional interface you can either use a lambda/method reference for or you can create your implementation of it. 

 

Can you show your RenderDogOne class? Every Render child class needs a RenderManager as a parameter and yours does not have one so I would like to see what you are passing as RenderManager in your RenderDogOne constructor's super call. This is one of the reasons to use IRenderFactory - it has RenderManager passed to it as an argument.

Enjoy (No errors):

Spoiler

//Copy this code in a class called RenderDogOne
package com.planetbravo.mainmod;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelWolf;
import net.minecraft.client.renderer.entity.RenderWolf;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.util.ResourceLocation;

public class RenderDogOne extends RenderWolf {

    private static final ResourceLocation textureLocation = new ResourceLocation(
            Main.MODID + ":" + "textures/entities/entitydogone.png");
    
    public RenderDogOne(ModelWolf model, float shadowSize) {
        super(Minecraft.getMinecraft().getRenderManager());
    }

    @Override
    protected void preRenderCallback(EntityWolf entitylivingbaseIn, float partialTickTime) {
        super.preRenderCallback(entitylivingbaseIn, partialTickTime);
        float scale = 1.0F;
        GL11.glScalef(scale, scale, scale);
    }

    @Override
    protected ResourceLocation getEntityTexture(EntityWolf par1Entity) {
        return textureLocation;
    }
}

 

Link to comment
Share on other sites

2 minutes ago, V0idWa1k3r said:

You are already using a proxy, so you must be aware of how to use it correctly and do not need someone else to write code for you here. 

IRenderFactory is a functional interface you can either use a lambda/method reference for or you can create your implementation of it. 

 

Can you show your RenderDogOne class? Every Render child class needs a RenderManager as a parameter and yours does not have one so I would like to see what you are passing as RenderManager in your RenderDogOne constructor's super call. This is one of the reasons to use IRenderFactory - it has RenderManager passed to it as an argument.

Also registerEntityRenderingHandler when used gives me this error (plus strikeout):

 

the method registerEntityRenderingHandler(Class<? extends Entity>, Render<? extends Entity>) in the type RenderingRegistry is not applicable for the arguments (Class<EntityDogOne>, Class<RenderDogOne>)

 

Also

 

 
void net.minecraftforge.fml.client.registry.RenderingRegistry.registerEntityRenderingHandler(Class<? extends Entity> entityClass, Render<? extends Entity> renderer)

 

 

Deprecated. use the factory version during Preinitialization. TODO Will be removed in 1.11.

Register an entity rendering handler. This will, after mod initialization, be inserted into the main render map for entities. Call this during Initialization phase.

Parameters:
entityClass
renderer

 

 

Link to comment
Share on other sites

1 minute ago, BlockExpert said:

the method registerEntityRenderingHandler(Class<? extends Entity>, Render<? extends Entity>) in the type RenderingRegistry is not applicable for the arguments (Class<EntityDogOne>, Class<RenderDogOne>)

Like V0idWa1k3r said, there are two versions of this method. You need to use the version which takes an Entity Class and an IRenderFactory as parameters.

 

Your RenderDogOne constructor should take a RenderManager parameter and pass this to super, instead of using Minecraft.getMinecraft().getRenderManager(). Then you can use this constructor for your IRenderFactory by passing the RenderManager from the IRenderFactory to the constructor and returning the new instance.

Link to comment
Share on other sites

2 minutes ago, BlockExpert said:

the method registerEntityRenderingHandler(Class<? extends Entity>, Render<? extends Entity>) in the type RenderingRegistry is not applicable for the arguments (Class<EntityDogOne>, Class<RenderDogOne>)

 

Why are you passing a class as a second argument? You need to pass an implementation of IRenderFactory, not a class.

2 minutes ago, BlockExpert said:

Also

--snip--

You have quoted the javadocs for the method you are currently using(the one that takes a class and Render as arguments). As you've quoted it is marked as deprecated and is TODO-ed to be removed.

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

 Share



×
×
  • Create New...

Important Information

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