[Tutorial] How to use the vanilla Skeleton model (with a bow) for a custom entity

Started by Azzy on

Topic category: User side tutorials

Last seen on 20:49, 23. Jun 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] How to use the vanilla Skeleton model (with a bow) for a custom entity
Fri, 06/23/2023 - 20:28 (edited)

I've been hearing about this a lot, where people have been struggling with finding the normal vanilla/forge models, then wondering how you get the items layers to display because nothing was displaying, then people doing the work in Blockbench. A lot of the stuff people mentioned got outdated as Forge itself updated, so I wanted to make this post in case it helped someone else. This tutorial covers how you can render the mob properly so it uses the vanilla/forge skeleton in-game. I dove into the Skeleton and SkeletonRenderer classes and was able to replicate how they were set up and it ended up pretty nice! 

You can also do this tutorial on pretty much any mob model, except you'd have to change some stuff up. So if you wanted the enderman model, you'd go to EndermanRenderer and look into how the layers are setup.

 

Notice: 

I am using example names below. When you lock your mob element below, you will have different file names. If your mob name is Skeleton, then your file you would want to modify would probably be SkeletonRenderer. For me, I am using CustomRenderer just for this tutorial/example, so for the sake of learning, let's assume your mob is named Custom. You will need to adjust the code to fit your file names!

 

  • Another thing. Once you finish all of this up below, you may want to set your custom entity texture. You can do this at CustomRenderer right at the top: private static final ResourceLocation SKELETON_LOCATION = new ResourceLocation("textures/entities/skeleton/skeleton.png");
  • Replace textures/entity/skeleton/skeleton.png with name_space:textures/entities/name_of_your_image.png. Replace "namespace" with your mod namespace/ID, you can find this in your workspace settings. Because we are locking the file, we can't access the traditional menu for adding textures with the program, so as long as you have your image imported within MCreator, you can use that directory within the quotations

 

Tips before proceeding

Make sure you have everything you want for your mob before proceeding. So, attributes, health, items, biome spawn weights, whatever it might be. Because we are locking the mod element, it will be moving you to code view from now on.


Secondly, you can still change this information within the "CustomEntity.java" class if you sift through it. Additionally, it is recommended to backup these files, so if you do not feel comfortable editing the code after doing this, you can simply unlock the file, make the changes, then lock and re-apply the changes for what we are doing here in this post.

 

  1. On MCreator, right-click your entity element and "Lock mod element". We need to do this cuz MCreator regenerates the file per compilation/build
  2. Now click the element, you will see that you are shown the files for it, and you can see CustomEntityRenderer.
  3. I'd open up both CustomEntityRenderer and CustomEntity, just so you have the file names there when you need to replace different references

Now, the code will be provided on pastebin for ease of read. Make sure to read the rest (as well as the comments/info in the classes that I put) after pasting everything so you can resolve errors

 Tutorial 

Once modified, please verify that you have replaced all example names with your own mob name, "CustomEntity" would be the name of your mob entity file. CustomRenderer would be the name of your mob renderer file, which are all shown when you click on the element.

 

Also, very important! Add the following lines underneath your "import" lines on the top!

import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.SkeletonModel;

These should be the only lines you have to add in your imports

 

Example for editing certain lines so you refer to your own classes

One of the lines were,

  @Override
    public ResourceLocation getTextureLocation(CustomEntity p_114482_) {
                                               ^^^^^^^^^^^^^
        return SKELETON_LOCATION;
    }

 

So verify that you are changing CustomEntity to your mob entity file name.

 

Another section was:

public class CustomEntityRenderer extends HumanoidMobRenderer<CustomEntity, SkeletonModel<CustomEntity>> {
              ^^^^^^^^^^^^^^^^^                                   ^^^^^                     ^^^^
     private static final ResourceLocation SKELETON_LOCATION = new ResourceLocation("textures/entities/skeleton/skeleton.png");

    public CustomEntityRenderer(EntityRendererProvider.Context context) {
               ^^^^^^^^^^^^
        this(context, ModelLayers.SKELETON, ModelLayers.SKELETON_INNER_ARMOR, ModelLayers.SKELETON_OUTER_ARMOR);
    }

 

I know, the up arrows are horrific, lol. But those are where you really need to replace things. You would replace CustomEntityRenderer to the name of your renderer file, replace the example names here <CustomEntity, SkeletonModel<CustomEntity> with the name of your entity file.

 

You are done though! Save the file(s) you modified & click the Regenerate code and build icon to make sure there are no compilation errors. If you do get a compilation error and cannot fix it, copy & paste the error and I can try to fix it. I hope this helps!

 

 

Extra:

  • Mob eye layer - We have modified the area that the eye layer relied upon, so follow this if you want to add an eye layer -> https://hastebin.com/share/jetalitomo.java
    • Ensure you are also importing "EyeLayer", or just make sure this is added to your imports: import net.minecraft.client.renderer.entity.layers.EyesLayer;
Edited by Azzy on Fri, 06/23/2023 - 20:28
Last seen on 01:05, 16. Jul 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're a wizard. Does this…
Thu, 06/22/2023 - 22:04

You're a wizard. Does this work with custom models as well? I've been digging through dozens of long-dead single-post forum questions about rendering armor and weapons on custom models made in BlockBench.

Last seen on 20:49, 23. Jun 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks and I'll have to look…
Fri, 06/23/2023 - 01:17

Thanks and I'll have to look into that, the code alone won't since we are replicating the forge/vanilla code for existing models, but looking into vanilla models is an excellent start into seeing how they render items to apply it on custom ones so I'll look into this tonight and dive around, im sure there's stuff on their documentation. if I can get something working on a custom BlockBench model I'll let ya know and send an update but I feel you, I was wondering the same and didn't find much. It may be somewhat straightforward from what I saw, it's just awkward for me because I have never worked with rendering or layering systems in the past and their codebase is taking some time to get acquainted to lol. Keep ya posted!

Last seen on 01:05, 16. Jul 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks. I've tried a couple…
Fri, 06/23/2023 - 14:38

Thanks. I've tried a couple of things myself like copypasting the armor layer code from the biped renderer or manually changing my custom models from type T to type M but I either get compile errors or crashes. I have no experience with Java so I can only make the barest sense of what I'm seeing, but I started looking into Twilight Forest's source code to see how they do it, and it looks like they made their own biped renderer and extend that for all their mobs.

Last seen on 20:21, 25. Nov 2023
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
hello, i tried to import and…
Thu, 09/14/2023 - 18:16

hello, i tried to import and use this but mcreator send me an error every time, do you have a solution ?

Last seen on 01:10, 5. May 2024
Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sadly doesn't seem to work…
Mon, 04/15/2024 - 02:06

Sadly doesn't seem to work. Do you have an updated method that will get this working?