Jump to content

Recommended Posts

Posted (edited)

I have this problem where (as far as I could deduct from debugging) a entity from my mod gets summoned into the server world, but the client world didn't recieve that entity.

The symptom of that problem is that the entity can't get rendered .

  Reveal hidden contents

My entity is a simple descendant (class name: io.github.keheck.mobfighters.entity.MobBall) of the net.minecraft.entity.ProjectileItemEntity class that only implements the onImpact(net.minecraft.util.math.RayTraceResult) method like this:

@Override
@SuppressWarnings("NullableProblems")
protected void onImpact(RayTraceResult result)
{
    if(!world.isRemote())
        this.remove();
}

The other methods overriden are the remove() method, which only loggs the death and then removes the entity as normal, and two methods that return an Item and ItemStack respectively, so not really, if at all, connected to my problem.

 

I did some more digging while writing this, and it seems like the root of the problem lies in the method "net.minecraft.client.network.play.ClientPlayNetHandler#handleSpawnObject(net.minecraft.network.play.server.SSpawnObjectPacket)"

Here it is:

  Reveal hidden contents

 

As one might notice, this method compares the EntityType in the recieved packet with every vanilla EntityType, and if it finds a match, an Entity instance is created by using a constructor of the according class. But since the EntityType of my mob is not equal to any of the listed EntityTypes in that method, it gets assigned to null and because of that doesn't get added to the ClientWorld (see bottom of the method).

This is how I register my entity and the renderer, respectively:

  Reveal hidden contents

 

If you want to explore my project yourself, I have a repository on github (it needs to be setup though, see README.md). The latest log can be found here.

 

The question that arises now: How can I [make Minecraft] add the entity to the ClientWorld instance as well? (if the problem is that simple to solve...)

 

Edited by Keheck
fixed typo
Posted
  On 4/5/2020 at 10:34 PM, Keheck said:

Note: Idk why the hidden contents are so long...

Expand  

Because of WYSIWYG copy pasting, probably.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 4/5/2020 at 10:30 PM, Keheck said:

How can I [make Minecraft] add the entity to the ClientWorld instance as well?

Expand  

You need to override Entity::createSpawnPacket and inside use NetworkHooks.getEntitySpawningPacket. I believe this is automatically handled for LivingEntity subclasses. But I'm unsure.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 4/5/2020 at 10:59 PM, Keheck said:

What?

Expand  

When you copy from a location that has WYSIWYG font support, the forum gobbles up that extra formatting information (and promptly adds 4000 pixels of extra white space).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
  On 4/6/2020 at 1:02 AM, Animefan8888 said:

You need to override Entity::createSpawnPacket and inside use NetworkHooks.getEntitySpawningPacket. I believe this is automatically handled for LivingEntity subclasses. But I'm unsure.

Expand  

Yes, that was it! Thank you, now I can go and run into new problems as I move on :D

Edited by Keheck

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.