Tschipp Posted February 18, 2018 Posted February 18, 2018 (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 February 18, 2018 by Tschipp Quote
jabelar Posted February 18, 2018 Posted February 18, 2018 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? Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Tschipp Posted February 18, 2018 Author Posted February 18, 2018 Hmm... I've done rendering of Entities on the shoulder on Animania before, I also use RenderPlayerEvent... I think I'm just gonna modify that to my needs Quote
jabelar Posted February 18, 2018 Posted February 18, 2018 I went ahead and logged an issue, maybe someone will create a hook for this in the future. https://github.com/MinecraftForge/MinecraftForge/issues/4756 1 Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.