Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to be able to draw any humanoid mob or player in my custom screen but only the head of it, as opposed to the entire model.

I ideally would like to avoid having to create entirely new model resources just for this as I plan to be able to swap out any kind of humanoid mob/player skin easily.

I did see that net.minecraft.client.model.HumanoidModel.bodyParts() exists, but I want to exhaust other options before trying to modify existing entity model resources (which could potentially affect in-world rendering too, but I'm not sure).

  • Author

What I can roughly gather from renderEntityInInventory is its grabbing the model rendering data, applying gui-specific configs like disabling shadows and setting a constant rotation, rendering it and then resetting those configs. I don't really understand the matrix and quaternion math here though and I hope that it's not necessary to. I don't see anything inside of EntityRenderDispatcher or the LivingEntity that can directly modify model part visibilities though unless I'm missing something?

As for RenderPlayerEvent.Pre, do you mean the event itself has methods/data I need to adjust to control model visibilities or that this is simply the event to call my 'renderHead' function in once written?

  • Author

Ok cool so I managed to set visibility flags in RenderLivingEvent for any mob I need (note 'Unit' right now consists of Zombies, Skeletons and Creepers in my project):

    public static void onRenderLivingEntity(RenderLivingEvent.Pre<? extends LivingEntity, ? extends Model> evt) {
        LivingEntity entity = evt.getEntity();
        Model model = evt.getRenderer().getModel();

        if (entity instanceof Unit) {
            if (entity instanceof Creeper) {
                ((CreeperModel) model).root().visible = false;
            }
            else {
                ((HumanoidModel) model).body.visible = false;
            }
        }
    }

Skeletons and zombies work fine and I assume I can extend this to all humanoid mobs with maybe some small edge cases. However, the problem is creepers. They don't seem to have a head, instead only one ModelPart: 'root'. Setting this invisible makes the entire creeper invisible. Is there any way to actually separate the visibility of the creeper's head from the rest of the model?

  • 1 month later...
  • Author

Returning to this issue since I never actually solved it...

Seems that once the root ModelPart of any HierarchicalModel is set invisible, all of its child parts also are made invisible. Since the root of Creepers and spiders are also theirs torsos, this means I can't set the torso invisible without also making the head invisible.

Is there a way to separate the visibility of the root from its children?

EDIT: I've upped to 1.18.2 since I originally posted this

Edited by SoLegendary
version up

  • Author

Creepers only have the following parts:

   public final ModelPart root;
   public final ModelPart head;
   public final ModelPart rightHindLeg;
   public final ModelPart leftHindLeg;
   public final ModelPart rightFrontLeg;
   public final ModelPart leftFrontLeg;

Their torso section IS the root. This is what it looks like when I set everything except the head and root invisible:

GUjQQ9c.png

  • Author

Ok actually, found the solution, for some reason there's no direct variable set for the body, instead I had to access it via:

((CreeperModel) model).root.getChild("body").visible = false;

Thanks for the help, finally resolved this :)

  • Author

Ok unfortunately it looks like held items and armour are still being rendered

For example, rendering a skeleton model with all but its head made invisible with the above code looks like this:


VLGyR1u.png

How can I also made these invisible?

  • Author

What's the correct type for the variable that stores the layers (for the restoring step)?

I'm declaring it as:

List<RenderLayer<? extends LivingEntity, ? extends EntityModel<? extends LivingEntity>>> hudSelectedLayers = null;

I use the same type arguments for the LivingEntityRenderer itself and it seems to work fine, but not for the layers.

But when I try to assign LivingEntityRenderer.layers to it I get this error:

error: incompatible types: List<RenderLayer<CAP#1,CAP#2>> cannot be converted to List<RenderLayer<? extends Entity,? extends Model>>
            hudSelectedLayers = evt.getRenderer().layers;
                                                 ^
  where CAP#1,CAP#2 are fresh type-variables:
    CAP#1 extends LivingEntity from capture of ? extends LivingEntity
    CAP#2 extends EntityModel<CAP#1> from capture of ? extends Model

 

  • 3 weeks later...
  • Author

Sorry to resurrect this again, but I'm having issues specifically with IllagerModel, where for some reason setting the visibility of all the ModelParts except for the head and root does not result in the arms being made invisible:

XwOgDTZ.png

This is my code to set the visibility of all parts of a model except the head (so far only doing humanoids and hierarchicals, slowly extending to more mtypes):

    private void setNonHeadModelVisibility(Model model, boolean visibility) {

        if (model instanceof HumanoidModel) {
            ((HumanoidModel) model).hat.visible = visibility;
            ((HumanoidModel) model).body.visible = visibility;
            ((HumanoidModel) model).rightArm.visible = visibility;
            ((HumanoidModel) model).leftArm.visible = visibility;
            ((HumanoidModel) model).rightLeg.visible = visibility;
            ((HumanoidModel) model).leftLeg.visible = visibility;
        }
        else if (model instanceof HierarchicalModel) {

            ModelPart root = ((HierarchicalModel) model).root();
            ModelPart head = root.getChild("head");

            root.children.forEach((String name, ModelPart modelPart) -> {
                if (!modelPart.equals(head))
                    modelPart.visible = visibility;
            });
        }
    }

This code works so far for villagers, zombies, skeletons, creepers and spiders with no issue (and I'm sure many other mobs I've yet to check).

Thanks again for all the help with this feature so far!

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.