Allowing an entity with custom model to hold an item

Started by _Ness on

Topic category: Advanced modding

Joined Oct 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Allowing an entity with custom model to hold an item

Hi, I'm trying to allow my custom model mob to display the item in its hand, I know this was possible in previous versions, but I can't figure out what lines of the code I need to mess with in order for this to work, can anyone help me please ? Thanks in advance.

Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't think this is…
Wed, 07/01/2020 - 19:21

I don't think this is currently possible.

Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you can do it in a fake way…
Wed, 07/01/2020 - 19:22

you can do it in a fake way by adding the sword or whatever you want in it's hand, however you need a different mob for each item it holds

Joined Feb 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
oops.  clarification: add…
Wed, 07/01/2020 - 19:23

oops.  clarification: add the item in the hand while modeling.

Joined Oct 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I see what you mean, I'm…
Thu, 07/02/2020 - 10:51

I see what you mean, I'm gonna do it if it really doesn't work, but I was looking at this video https://youtu.be/IMvHFad8dsU , and thought it could be replicable in recent versions...

Joined Apr 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
has a fix been found for…
Thu, 10/22/2020 - 01:33

has a fix been found for custom entity holding a weapon been found?

 

Joined May 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you could somehow rip the…
Tue, 08/20/2024 - 01:59

if you could somehow rip the held item models from say the allay or zombie maybe you could append them to the entity? idk that probably requires typing out scripts instead of procedure blocks. I don't know java code so excuse my lack of knowledge.

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I know how, but it requires…
Sun, 09/29/2024 - 16:39

I know how, but it requires code:

1. Make your model class implement the ArmedModel interface like so: 

public class YourModel extends EntityModel<YourEntity> implements ArmedModel

2. Add these methods to the bottom of your class (make sure they’re still within the last closing brace and also not inside any other methods)

private ModelPart getArm(HumanoidArm arm) {
       return (arm == HumanoidArm.LEFT) ? this.left_arm : this.right_arm;
   }

    @Override
   public void translateToHand(HumanoidArm arm, PoseStack stack) {
       getArm(arm).translateAndRotate(stack);
   }

3. In the getArm method, replace left_arm and right_arm with the names of your arm variables (assuming that’s not what they are already)


NOTE: I think this only works with human-ish models (things like zombies, skeletons, etc). If you have a model with arms sized/positioned very differently you’ll probably need custom positioning code, though I’m not sure as I’ve never tried with non human-isn models. No harm in trying yourself though


Feel free to ask me further questions :)

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Shoot I forgot something: 4…
Sun, 09/29/2024 - 17:17

Shoot I forgot something:

4. Go into the entity’s renderer and add this to the constructor under the call to super:

this.addLayer(new ItemInHandLayer<>(this));

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could you make a video…
Tue, 10/08/2024 - 01:47

Could you make a video tutorial showing how to do this, or at least some images showing where to insert the code, seeing as how whenever I try to do this, the client always ends up with one error or another?

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Gonna be honest: I’ve never…
Wed, 10/09/2024 - 01:39

Gonna be honest: I’ve never used mcreator for anything other than a terrible ruby mod I made like 3 years ago lol.

I believe I’ve seen a video tutorial on this at some point but I can’t find it now unfortunately

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@a_random_someone is there…
Fri, 12/13/2024 - 02:19

@a_random_someone is there any way you can send images with the code highlighted? im having a lot of trouble with the placement