Jump to content

[1.16.4] Dealing with EntityType Shennanigans


hammy3502

Recommended Posts

I'm currently working on porting a mod from 1.12 to 1.16.

 

Back in 1.12, summoning entities was seemingly quite easy, where I could create my entity object, then call world.addEntity(entity), and it would take my entity object and summon it in.

 

Now it seems in the land of 1.16, that as a result of the EntityType system(?), world.addEntity(entity) seems to completely ignore the fact I've already created an instance of my entity object and tries to make a new one using the factory. Problematically for me, I'm trying to make an entity that extends AbstractFireballEntity (as I want it to act similarly to a fireball, just with different behavior on hit, and a couple cosmetic changes) which requires me to pass in a shooter to its constructor. And for the life of me, I cannot find a way to let the Factory know what my shooter is. Could anyone guide me in the right direction?

 

Link to source repo: https://github.com/hammy3502/survival-extras-2

 

Files of note: entity.PancakeProjectile, item.PancakeBow, init.ModEntities

 

Thank you so much for any help that can be provided, and apologies if the code is a mess right now, I'm hoping to clean it up once I have most of the things from my 1.12 ported over.

Link to comment
Share on other sites

Hello, and thank you for the help!

 

I will definitely look into the incorrect registration, it looks like I'm using register() instead of registerAll() (though I should probably figure out how to use the deferred register for EntityTypes).

 

The Entity doesn't spawn on the client due to passing null in for the shooter, causing the game to fail on getting the shooter's position. What I'm stuck on is how to get a valid shooter from item.PancakeBow over to entity.PancakeProjectile. What would be the best way of going about doing this?

 

Thank you again for any help! I'll have the registration fixed as soon as I can, though I'm able to get the entity in the game (see it in /summon's TAB completion with my modid).

Edited by hammy3502
Link to comment
Share on other sites

Hello, and thank you for the help!

 

I think I'm wrapping my mind around the functions in IEntityAdditionalSpawnData, and I know I can pass the data around from there throughout the Entity class, but I'm wondering how I can get that data into the super() constructor of the entity considering the fact that Java prevents referencing "this" until after calling super(), and super() is where it fails.

 

As for the registration stuff, I'm quite confused on. I'm listening for 

RegistryEvent.Register<EntityType<?>> event

and registering there, and looking at the Forge Docs, if I understand them correctly, @ObjectHolder looks to be for already-registered objects. I'm sure I definitely don't understand this properly, I'm just confused as to how to proceed.

 

Thank you for all the help so far!

 

EDIT: Figured out how to get ahold of the data in the constructor (I used spawnEntity.getAdditionalData())

Edited by hammy3502
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.