Jump to content

Recommended Posts

Posted

Hello everyone,

I've made a "onPlayerTick" function which is working great but i've got a little problem.

private void onPlayerTick(EntityPlayer player) {
	ItemStack plate = player.getCurrentItemOrArmor(3);

	if (plate != null) {
		if (plate.getItem() == Items.jetpack) {
			if(player.isJumping){
				player.worldObj.spawnParticle("heart", player.posX, player.posY - 1, player.posZ, 0.0D, 0.0D, 0.0D);
				player.motionY += .15F;
			}
		}
	}
}

On singleplayer the particle work correctly but on multiplayer, the other players cant see it. Any solutions?

Posted

can you check that other players see "isJumping" as a good value, this might not be updated through all the clients :\

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

So in the "onWorldTick" i do something like that ?

for (Entity e : world.getEntities()){
    if (e instanceof EntityPlayer) {
        if (e.getArmor(3) != null & e.getArmor(3).getID() == Items.plate & e.isJumping)[
             //Show particle
        }
    }
}

Posted

no, you use System.out.println() to check wether or not the variable "isJumping" is true for other players when a player is jumping, like i said this variable might not necessarelly be synchronized with all the clients

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Where am I supposed to write this? Because onPlayerTick seems only tick the client player :S (But its in the ServerTickHandler)

 

I've got another problem. I rewrited the mod because I changed computer and forget to save it -_-

But the coremod doesnt work. Its written this in the log:

2013-08-17 19:59:21 [iNFO] [ForgeModLoader] FML has found a non-mod file KnuxCore.jar in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.

And the variable isJumping now return ALWAYS false. :(

Thats what currently has the tick

public void playerTick(EntityPlayer player) {
		ItemStack is = player.getCurrentArmor(2);
		if(is != null){
			if (is.getItem() == Items.jetpack){
				System.out.println("isJumping: " + player.isJumping);
			}
		}
}

And my console is spammed with "isJumping: false" when i am ingame, both if i jump or not

Posted

Yes I know, but if i do this, the client will be kicked because "Flight is not enabled", doesnt it ?

And for the particle I probably should do that. Let me try

Posted

All you need is isJumping set to true at some point.

The rest you can handle with packets if needed.

 

Edit: You can use LivingJumpEvent instead of a TickHandler, too.

Posted

This event seems not to work. It happens when player is on ground then jump, but when its in the air, the event is no longer called, even if the keyboard stay pressed :(

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.