Rendering item on custom entity

Started by Overtek on Mon, 05/18/2020 - 17:39

Topic category: Advanced modding

Last seen on 12:13, 11. Apr 2021
Joined Oct 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Rendering item on custom entity
Mon, 05/18/2020 - 17:39

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 :)

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
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));

 

Last seen on 20:11, 1. Aug 2021
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
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?