Jump to content

Custom Entity Child size?


daveash

Recommended Posts

I have got my custom spider working and I'm tweaking the AI and child code.  The spider behaves like a wolf and protects the player.  The problem I have is when I breed him, I know how to make it breed a normal spider entity, which the code considers a child, even though the model is an adult (which originally was done for a test.)  How do I make this a smaller sized child spider?  Here's my code for the createChild and I know why it creates the normal spider, but I don't know how to change it to make a smaller version of my spider.

 

    @Nullable
    @Override
    public AgeableEntity createChild(AgeableEntity ageable) {

        OrangeSpiderEntity entity = new OrangeSpiderEntity(RaydenhallEntities.ORANGE_SPIDER_ENTITY.get(), this.world);

        entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(this.getPosX(), this.getPosY(), this.getPosZ())),
        SpawnReason.BREEDING, (ILivingEntityData) null, (CompoundNBT) null);

        UUID uuid = this.getOwnerId();
        if (uuid != null) {
            entity.setOwnerId(uuid);
            entity.setTamed(true);
        }

        return entity;
    }

 

This code basically makes the adult looking spider, sets owner and spawns it in.  How do I make a smaller version of the OrangeSpiderEntity?

Link to comment
Share on other sites

I was using the WolfEntity as an example for my spider.  My model exports from BlockBench, so it inheirits from EntityModel.  I switched my Spider model and implemented the methods to AgeableModel but could not access childBodyScale since it is private (I think I'd also need childHeadScale).  I'm using 1.16.

The wolfEntity class of the Model for that matter doesn't seem to have a scaling step to make the wolf appear as a child.  I'm sure it does, but I haven't found it yet.

Link to comment
Share on other sites

27 minutes ago, daveash said:

I switched my Spider model and implemented the methods to AgeableModel but could not access childBodyScale since it is private (I think I'd also need childHeadScale).  I'm using 1.16.

If it is unchanged from 1.15, then you can specify the childBodyScale in the constructor of AgeableModel.

Link to comment
Share on other sites

In fact, it's really simple. The problem is that your model inheirits from EntityModel. So first extends with AgeableModel :

public class YourModel<T extends YourEntity> extends AgeableModel<T>

 

Then, delete your render method and add :

@Override
protected Iterable<ModelRenderer> getHeadParts() {
	return ImmutableList.of(this.head);
}

@Override
protected Iterable<ModelRenderer> getBodyParts() {
	return ImmutableList.of(this.body, this.legBackRight, this.legBackLeft, this.legFrontRight, this.legFrontLeft);
}

 

The AgeableModel class will render automatically your mob and scale it correctly if it's a baby.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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