Jump to content

Recommended Posts

Posted

Hello,

I have another issue:

In my ItemGun i have this:

 

             if (!par2World.isRemote)
             {
                 par2World.spawnEntityInWorld(new EntityBullet(par2World, ((EntityPlayer)par3Entity), 21.0F));
                 par2World.spawnEntityInWorld(new EntityNoiseLocation(par2World, ((EntityPlayer)par3Entity), this.noiseRange));
             }

 

And in my EntityBullet i have this in onUpdate:

 

     if(this.stopTick && this.doneDisplay)
     {
         int nbMs = nbTicks * 50;
         System.out.println(this.entityId + " 100 meters in " + nbMs + "ms");
         this.doneDisplay = false;
     }
    

 

this.stopTick take false when in onUpdate again:

 

if (this.inGround)
     {
         int j = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
         int k = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile);
         this.stopTick = true;
             ............
     }

 

My issue is when my bullet hit a block, this:

 

System.out.println(this.entityId + " 100 meters in " + nbMs + "ms");

 

is writting twice in consol and most of time nbMs is different (1 tick more)

 

I don't know why this is showing twice, my entity is only spawning once i think with isRemote.

 

Thanks

Posted

Hi

 

onUpdate is called both on server and client side.  Spawning an entity on the server side automatically spawns a "copy" on the client side, and onUpdate are called for both of them.

 

If you want your message on one side only, then use isRemote, like you did when spawning the bullet.

 

-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.