Jump to content

Recommended Posts

Posted

Hello everyone!

I've created some Entities before and I also got them to work somehow, but I still don't know what the methods used for Entity registration do exactly. Also I'm unsure which are necessary and which aren't.

 

These are the methods I'm curious about:

 

EntityRegistry.findGlobalUniqueEntityId()
//Question here: Where is this used during registration?

EntityRegistry.registerGlobalEntityID(entityClass, entityName, id)
//Question here: Necessary at all? What should the ID be?

EntityRegistry.registerModEntity(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates)
//Question here: What do the parameters tracking range, update frequency and sends velocity updates do?

EntityList.addMapping(entityClass, entityName, ID)
//Question here: Which ID do I need to use?

 

I know, most of the questions seem to be noobish, but I'm quite unsure, especially because it seems like Entities use a lot of different IDs (Mod internal, Global, ...)

 

Maybe, anyone can present me a list of methods that needs to be called in order to register an Entity proprely.

Posted

You should only use:

EntityRegistry.registerModEntity(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates)

 

trackingRange is the range in meters (blocks) at which this entity's data will be sent to players around.

updateFrequency is time in ticks this entity will be sending position updates (movement and few more values probably).

Note: You should use 3 as default.

sendVelocityUpdates causes sending not only normal update packets, but velocity aswell:

if (this.sendVelocityUpdates)
                {
                    double d0 = this.trackedEntity.motionX - this.lastTrackedEntityMotionX;
                    double d1 = this.trackedEntity.motionY - this.lastTrackedEntityMotionY;
                    double d2 = this.trackedEntity.motionZ - this.motionZ;
                    double d3 = 0.02D;
                    double d4 = d0 * d0 + d1 * d1 + d2 * d2;

                    if (d4 > d3 * d3 || d4 > 0.0D && this.trackedEntity.motionX == 0.0D && this.trackedEntity.motionY == 0.0D && this.trackedEntity.motionZ == 0.0D)
                    {
                        this.lastTrackedEntityMotionX = this.trackedEntity.motionX;
                        this.lastTrackedEntityMotionY = this.trackedEntity.motionY;
                        this.motionZ = this.trackedEntity.motionZ;
                        this.func_151259_a(new S12PacketEntityVelocity(this.trackedEntity.getEntityId(), this.lastTrackedEntityMotionX, this.lastTrackedEntityMotionY, this.motionZ));
                    }
                }

This probably smoothens movement, but idk really xD

 

Edit:

As to other stuff: (questions)

1. Nowhere, I personally think this method is useless - just look at it's code.

2. NEVER use this - use forge's version (the one mentioned at beginning of post)!

3. Told before.

4. Don't use it, again - use forge's method.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Thanks for the detailed explanation.

 

Just one addition I discovered earlier:

When registering the Entity, Forge automatically adds it to the List of summonable Entities.

If you have a "utility" Entity, something that is generated for a few seconds and vanishes again, you may not want to have it in this list.

You can do that by adding a value to the map, registering the entity and removing the value again.

EntityList.classToStringMapping.put(entityClass, "");
EntityRegistry.registerModEntity(entityClass, entityName, modID, modInstance, trackingRange, updateFrequency, sendVelocityUpdate);
EntityList.classToStringMapping.remove(entityClass);

This does not add the registered entity to the list of summonable ones.

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.