Rendering item on custom entity

Started by Overtek on

Topic category: Advanced modding

Active 1 year ago
Joined Oct 2014
Points:
741

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 7
Rendering item on custom entity

Hello anyone know how to render item on custom entity ? I don't thing it's possible with mcreator or blockbench and I need to go to the code but I don't know how to do that. If anyone can help me it would be nice :)

Active 4 years ago
Joined Sep 2019
Points:
973

User statistics:

  • Modifications: 1
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 507
Yep super simple in code…
Sun, 05/31/2020 - 03:56

Yep super simple in code. Are you using a biped entity?

To place items in your entities Equipment Slots use the snipped below in your entity class,

    @Override
    public void onAddedToWorld() {
        super.onAddedToWorld();
        this.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(YourItem));
        this.setItemStackToSlot(EquipmentSlotType.HEAD, new ItemStack(YourItem));
    }

To render it on the entity, though, use the snippet below in the entity render class,

        this.addLayer(new HeldItemLayer<>(this));
        this.addLayer(new BipedArmorLayer(this, new BipedModel(0.5f), new BipedModel(1.0f)));
        this.addLayer(new ElytraLayer<>(this));

 

Active 2 years ago
Joined Nov 2018
Points:
970

User statistics:

  • Modifications: 0
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 572
Am I supposed to extend…
Tue, 08/25/2020 - 19:46

Am I supposed to extend something because the addLayer method isn't recognised?

Does the model have to be biped?

Active 1 year ago
Joined May 2020
Points:
645

User statistics:

  • Modifications: 0
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 32
Is this still working?
Tue, 12/06/2022 - 04:57

Is this still working?