Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How do i register the renderers for my entities?


Drachenbauer
 Share

Recommended Posts

Hello

 

I have got a problem with the renderingRegistry:

 

An Entity-Class (Stella from my Angry Birds Entities):

package drachenbauer32.angrybirdsmod.entities;

import drachenbauer32.angrybirdsmod.init.AngryBirdsEntities;
import net.minecraft.entity.AgeableEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.Pose;
import net.minecraft.entity.ai.goal.LookAtGoal;
import net.minecraft.entity.ai.goal.LookRandomlyGoal;
import net.minecraft.entity.ai.goal.RandomSwimmingGoal;
import net.minecraft.entity.ai.goal.RandomWalkingGoal;
import net.minecraft.entity.ai.goal.SwimGoal;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

public class StellaEntity extends AnimalEntity
{
    @SuppressWarnings("unchecked")
    public StellaEntity(EntityType<? extends AnimalEntity> type, World worldIn)
    {
        super((EntityType<? extends AnimalEntity>) AngryBirdsEntities.STELLA, worldIn);
    }
    
    @Override
    public AgeableEntity createChild(AgeableEntity arg0)
    {
        return null;
    }
    
    @Override
    public float getEyeHeight(Pose pose)
    {
        return this.getSize(pose).height / 2;
    }
    
    @Override
    protected void registerGoals()
    {
        this.goalSelector.addGoal(0, new SwimGoal(this));
        this.goalSelector.addGoal(1, new RandomSwimmingGoal(this, 0.2d, 10));
        this.goalSelector.addGoal(2, new RandomWalkingGoal(this, 0.2d));
        this.goalSelector.addGoal(3, new LookAtGoal(this, PlayerEntity.class, 6.0F));
        this.goalSelector.addGoal(4, new LookRandomlyGoal(this));
    }
    
    @Override
    protected void registerAttributes()
    {
        super.registerAttributes();
    }
}

 

The renderer-Class for this Entity:

package drachenbauer32.angrybirdsmod.entities.renderers;

import drachenbauer32.angrybirdsmod.entities.StellaEntity;
import drachenbauer32.angrybirdsmod.entities.models.StellaModel;
import drachenbauer32.angrybirdsmod.util.Reference;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.client.renderer.entity.model.EntityModel;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;

@OnlyIn(Dist.CLIENT)
public class StellaRenderer extends MobRenderer<StellaEntity, EntityModel<StellaEntity>>
{
    private static final ResourceLocation STELLA_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/entity/stella.png");
    
    public StellaRenderer(EntityRendererManager manager)
    {
        super(manager, new StellaModel(), 0.5f);
    }
    
    @Override
    public ResourceLocation getEntityTexture(StellaEntity arg0)
    {
        return STELLA_TEXTURE;
    }
    
    public static class RenderFactory implements IRenderFactory<StellaEntity>
    {
        @Override
        public EntityRenderer<? super StellaEntity> createRenderFor(EntityRendererManager manager)
        {
            return new StellaRenderer(manager);
        }
    }
}

 

And the Model-Class:

package drachenbauer32.angrybirdsmod.entities.models;

import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;

import drachenbauer32.angrybirdsmod.entities.StellaEntity;
import net.minecraft.client.renderer.entity.model.AgeableModel;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class StellaModel<T extends StellaEntity> extends AgeableModel<T>
{
    private final ModelRenderer bone;
    private final ModelRenderer bone2;
    private final ModelRenderer bone3;
    private final ModelRenderer bone4;
    private final ModelRenderer bone5;
    
    public StellaModel()
    {
        textureWidth = 32;
        textureHeight = 16;
        
        bone = new ModelRenderer(this);
        bone.setRotationPoint(0.0F, 20.0F, 0.0F);
        bone.func_217178_a("body", -4.0F, -4.0F, -4.0F, 8, 8, 8, 0.0F, 0, 0);
        bone.func_217178_a("beak", -1-1.0F, 2.0F, -5.0F, 2, 1, 1, 0.0F, 25, 0);
        bone.func_217178_a("head_feather_1", 0.0F, -6.0F, -8.0F, 0, 2, 6, 0.0F, 10, 10);
        bone.func_217178_a("tail_feather_1", 0.0F, 1.0F, 4.0F, 0, 1, 4, 0.0F, 24, 3);
        
        bone2 = new ModelRenderer(this);
        bone2.setRotationPoint(0.0F, -4.0F, -2.0F);
        setRotationAngle(bone2, -0.5236F, 0.0F, 0.0F);
        bone.addChild(bone2);
        bone2.func_217178_a("head_feather_2", 0.0F, -2.0F, -6.0F, 0, 2, 6, 0.0F, 10, 10);

        bone3 = new ModelRenderer(this);
        bone3.setRotationPoint(0.0F, -4.0F, -2.0F);
        setRotationAngle(bone3, -1.0472F, 0.0F, 0.0F);
        bone.addChild(bone3);
        bone3.func_217178_a("head_feather_3", 0.0F, -2.0F, -6.0F, 0, 2, 8, 0.0F, 10, 10);
        
        bone4 = new ModelRenderer(this);
        bone4.setRotationPoint(0.0F, 1.0F, 4.0F);
        setRotationAngle(bone4, 0.5236F, 0.0F, 0.0F);
        bone.addChild(bone4);
        bone4.func_217178_a("tail_feather_2", 0.0F, 0.0F, 0.0F, 0, 1, 4, 0.0F, 24, 3);
        
        bone5 = new ModelRenderer(this);
        bone5.setRotationPoint(0.0F, 1.0F, 4.0F);
        setRotationAngle(bone5, -0.5236F, 0.0F, 0.0F);
        bone.addChild(bone5);
        bone5.func_217178_a("tail_feather_3", 0.0F, 0.0F, 0.0F, 0, 1, 4, 0.0F, 24, 3);
    }
    
    @Override
    protected Iterable<ModelRenderer> func_225602_a_()
    {
      //head/Main parts here 
        return ImmutableList.of(bone);
    }
    
    @Override
    protected Iterable<ModelRenderer> func_225600_b_()
    {
        return null;
    }
    
    public void render(final T stella, final float limbSwing, final float limbSwingAmount, final float ageInTicks, final float netHeadYaw, final float headPitch)
    {
        bone.rotateAngleX = headPitch * 0.017453292f;
        bone.rotateAngleY = netHeadYaw * 0.017453292f;
    }
    
    @Override
    public void func_225598_a_(MatrixStack p_225598_1_, IVertexBuilder p_225598_2_, int p_225598_3_, int p_225598_4_, float p_225598_5_, float p_225598_6_,
                               float p_225598_7_, float p_225598_8_)
    {
        // TODO Auto-generated method stub
    }
    
    @Override
    public void func_225597_a_(StellaEntity p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float netHeadYaw, float headPitch)
    {
        
    }
    
    public void setRotationAngle(ModelRenderer model, float x, float y, float z)
    {
        model.rotateAngleX = x;
        model.rotateAngleY = y;
        model.rotateAngleZ = z;
    }
}

 

My problem is about this lines (i have one for each Entity) in my RenderHandler:

RenderingRegistry.registerEntityRenderingHandler(StellaEntity.class,new StellaRenderer.RenderFactory());

In 1.14.3 it worked.

But now it says, my arguments are not compatible and wants an EntityType.

So i tried this:

RenderingRegistry.registerEntityRenderingHandler(AngryBirdsEntities.STELLA,new StellaRenderer.RenderFactory());

But id still says, my arguments are not compatible.

Then i found this format in someone´s mod (just with a turtle instead of Stella):

RenderingRegistry.registerEntityRenderingHandler(AngryBirdsEntities.STELLA,StellaRenderer::new);

But it now markes the last part (The instance of the renderer-class) of the line as an error and still keeps the other error wit not compatible.

Why do i get errors with something, that works in someone else´s Mod for the same version of minecraft?

Edited by Drachenbauer
Link to comment
Share on other sites

Show your entity type reference (if you simply used the ? wildcard for your generic parameter it obviously won’t work when you try to use it in the rendering registry call)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

6 minutes ago, Cadiboo said:

if you simply used the ? wildcard for your generic parameter it obviously won’t work when you try to use it in the rendering registry call

Just now, Drachenbauer said:

EntityType<?>

You want EntityType<YourEntity> instead

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Yes. You might want to do some research on generics one Java.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.

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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Title says it all. Ive googled this for hours and i cant find anything :(
    • Hey! I keep getting this error when I start my own Minecraft server: (Also to note: I am not very knowledge on how Java works as my servers have almost never had any type of issue) 2021-10-23 18:47:36,993 main ERROR Error processing element Queue ([Appenders: null]): CLASS_NOT_FOUND 2021-10-23 18:47:37,041 main WARN Advanced terminal features are not available in this environment 2021-10-23 18:47:37,078 main ERROR Unable to locate appender "ServerGuiConsole" for logger config "root" ←[32m[18:47:37] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 31.2.50, --fml.mcpVersion, 20200515.085601, --fml.mcVersion, 1.15.2, --fml.forgeGroup, net.minecraftforge, nogui] ←[m←[32m[18:47:37] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 5.1.2+70+master.2845bb9 starting: java version 15.0.2 by Oracle Corporation ←[m←[1;31m[18:47:37] [main/FATAL] [ne.mi.fm.lo.FMLLoader/CORE]: Access Transformer library is missing, we need this to run ←[m←[1;31m[18:47:37] [main/ERROR] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Service failed to load fml cpw.mods.modlauncher.api.IncompatibleEnvironmentException: Missing AccessTransformer, cannot run         at net.minecraftforge.fml.loading.FMLLoader.lambda$onInitialLoad$1(FMLLoader.java:104) ~[forge2.jar:31.2] {}         at java.util.Optional.orElseThrow(Optional.java:401) ~[?:?] {}         at net.minecraftforge.fml.loading.FMLLoader.onInitialLoad(FMLLoader.java:102) ~[forge2.jar:31.2] {}         at net.minecraftforge.fml.loading.FMLServiceProvider.onLoad(FMLServiceProvider.java:122) ~[forge2.jar:31.2] {}         at cpw.mods.modlauncher.TransformationServiceDecorator.onLoad(TransformationServiceDecorator.java:53) ~[modlauncher-5.1.2.jar:?] {}         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$loadTransformationServices$11(TransformationServicesHandler.java:131) ~[modlauncher-5.1.2.jar:?] {}         at java.util.HashMap$Values.forEach(HashMap.java:1067) [?:?] {}         at cpw.mods.modlauncher.TransformationServicesHandler.loadTransformationServices(TransformationServicesHandler.java:131) [modlauncher-5.1.2.jar:?] {}         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:56) [modlauncher-5.1.2.jar:?] {}         at cpw.mods.modlauncher.Launcher.run(Launcher.java:75) [modlauncher-5.1.2.jar:?] {}         at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.2.jar:?] {}         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [forge2.jar:?] {}         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [forge2.jar:?] {}         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [forge2.jar:?] {} ←[m←[1;31m[18:47:37] [main/ERROR] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Found 1 services that failed to load : [fml] ←[m←[32m[18:47:37] [main/INFO] [STDERR/]: [net.minecraftforge.server.ServerMain$Runner:runLauncher:65]: The server is missing critical libraries and cannot load. Please run the installer to correct this ←[m
    • Hi, I don't know much about Minecraft Mod programming, and I'm making a mod, I need to know how to scale the model from the adult version to the child version. I'm currently doing the mod itself by Mcreator, and modeling by Blockbench. The reproduction of this mob is done, the problem is, the child is the same size as the adult. At first I would use two different models for this animal, but researching a little, I found that there is a way to scale the model. I wanted to know how to do this. Here below is the code.  
    • When I try to load it. It starts up but none can join the server as the forge jar is corrupted some how. Believe it is a fault in the update.  
    • Sorry I didn’t explain it in much detail at first hopefully this will be much more easier to understand. I am running a 1.16.5 forge server with java 8 there is multiple errors which you can see in the paste bin right at the top. Not sure what is the problem with it I followed a YouTube video it worked for him but not for me I believe it is because it is not registering the main class which is coursing the forge not to work it has no mods at all.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.