Jump to content

Recommended Posts

Posted

Sorry for lousy title I don't know how to put it, but basically I want to spawn an extra mob whenever one would spawn. In the LivingSpawn event, I can make it work fine if I hardcode the entity type, however I don't know how to get it to work as a general solution. new CowEntity() is good, new event.getEntity()() is not good. This is probably really simple but I've been stuck for a few days so thanks for any help

Posted

Hi

 

I had a quick look at EntityType class and this looked interesting-

 

   public static Optional<EntityType<?>> readEntityType(CompoundNBT compound) {
      return Registry.ENTITY_TYPE.getValue(new ResourceLocation(compound.getString("id")));
   }

 

i.e. you can get the EntityType from a CompoundNBT, which you can copy from your event.getEntity(), and then spawn the entity as normal

 

Haven't tried it, but it looks promising.

 

-TGG

 

 

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.