Jump to content

Recommended Posts

Posted (edited)

I wanted to make a parrot-like entity, so I made it extend EntityShoulderRiding and added the appropriate AI for it.

It does work, the entity flys towards the player and then lands on its shoulder, but the entity isn't visible and the console gets spammed with errors.

 

The errors stem from the LayerEntityOnShoulder class, where a check gets made if the entity is a parrot. If it isn't, the code just fails:

 private LayerEntityOnShoulder.DataHolder renderEntityOnShoulder(EntityPlayer p_192864_1_, @Nullable UUID p_192864_2_, NBTTagCompound p_192864_3_, RenderLivingBase <? extends EntityLivingBase > p_192864_4_, ModelBase p_192864_5_, ResourceLocation p_192864_6_, Class<?> p_192864_7_, float p_192864_8_, float p_192864_9_, float p_192864_10_, float p_192864_11_, float p_192864_12_, float p_192864_13_, float p_192864_14_, boolean p_192864_15_)
    {
        if (p_192864_2_ == null || !p_192864_2_.equals(p_192864_3_.getUniqueId("UUID")))
        {
            p_192864_2_ = p_192864_3_.getUniqueId("UUID");
            p_192864_7_ = EntityList.getClassFromName(p_192864_3_.getString("id"));

            if (p_192864_7_ == EntityParrot.class)
            {
                p_192864_4_ = new RenderParrot(this.renderManager);
                p_192864_5_ = new ModelParrot();
                p_192864_6_ = RenderParrot.PARROT_TEXTURES[p_192864_3_.getInteger("Variant")];
            }
        }

        p_192864_4_.bindTexture(p_192864_6_);
        GlStateManager.pushMatrix();
        float f = p_192864_1_.isSneaking() ? -1.3F : -1.5F;
        float f1 = p_192864_15_ ? 0.4F : -0.4F;
        GlStateManager.translate(f1, f, 0.0F);

        if (p_192864_7_ == EntityParrot.class)
        {
            p_192864_11_ = 0.0F;
        }

        p_192864_5_.setLivingAnimations(p_192864_1_, p_192864_8_, p_192864_9_, p_192864_10_);
        p_192864_5_.setRotationAngles(p_192864_8_, p_192864_9_, p_192864_11_, p_192864_12_, p_192864_13_, p_192864_14_, p_192864_1_);
        p_192864_5_.render(p_192864_1_, p_192864_8_, p_192864_9_, p_192864_11_, p_192864_12_, p_192864_13_, p_192864_14_);
        GlStateManager.popMatrix();
        return new LayerEntityOnShoulder.DataHolder(p_192864_2_, p_192864_4_, p_192864_5_, p_192864_6_, p_192864_7_);
    }

 

Is there something that forge adds that allows me to render my entity on the shoulder? Or do I have to make my own system with own AI?

Edited by Tschipp
Posted

That does seem like it is a fairly parrot-specific piece of code. Would be good to have a Forge hook, although I'm not familiar with one.

 

What would be nice is to replace the layer with a custom layer. However, that might be tricky since the render manager map and render player fields are private and/or final. If you use reflection though you might be able to figure out a way to insert your own layer. The concept would be to get access to the playerRenderer field in the Minecraft.getMinecraft().getRenderManager() and modify (again might need reflection) the list of layers by removing the entity on shoulder entry with your own.

 

Since that seems tricky, maybe you can use events instead. I think the RenderLivingEvent is cancelable so you can handle it for player entities and replace the renderer with your version of the RenderPlayer class that has your custom layer.

 

Or maybe someone has a much easier way?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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



×
×
  • Create New...

Important Information

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