Jump to content

Recommended Posts

Posted

Hi, I just created a custom projectile which works fine on singleplayer and functions in multiplayer, however in multiplayer other nearby players cannot see this projectile (they can still get hit and hurt by it).

 

Do I need to implement custom packets for each entity I implement, or should this be done automatically.

 

creating the hook: (EntityHook extends throwable)

EntityHook hook = new EntityHook(par2World, par3EntityPlayer);
par2World.spawnEntityInWorld(hook);

 

I have registered the renderer int he client proxy:

 

RenderingRegistry.registerEntityRenderingHandler(EntityHook.class, new RenderHook());

 

And also I registered the entity:

 

EntityRegistry.registerGlobalEntityID(EntityHook.class, "Hook", EntityRegistry.findGlobalUniqueEntityId());

 

So is there something I've missed? Would really appreciate some help.

Posted

Are you sure you are spawning the new projectile on the server? Check this by implementing the follow check:

 

if(!par2World.isRemote){
    EntityHook hook = new EntityHook(par2World, par3EntityPlayer);
    par2World.spawnEntityInWorld(hook);
}

Posted

Thanks, just made the change.

 

Implemented the check and now even the player shooting the projectile cannot see it. This seems to suggest that no clients are getting notified about the projectile by the server. Any ideas for how to correct this?

 

Projectiles function mostly, although the pull mechanic is now not working. (Is minecraft movement handled clientside???)

Posted

I believe that movement is done through the server, then rendered through the client. Not sure if that was the question. I think you may need to use a packet to handle the spawning, anyways check if the entity is spawned correctly by adding this code to the update method:

 

if(!this.worldObj.isRemote){
    System.out.println("[server] Ticked on server.");
}

If you see this message in the console, then you for sure will know that the entity is spawned on the server side.

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.