Knux14 Posted August 14, 2013 Posted August 14, 2013 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? Quote
hydroflame Posted August 16, 2013 Posted August 16, 2013 can you check that other players see "isJumping" as a good value, this might not be updated through all the clients :\ Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Knux14 Posted August 16, 2013 Author Posted August 16, 2013 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 } } } Quote
hydroflame Posted August 16, 2013 Posted August 16, 2013 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 Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Knux14 Posted August 17, 2013 Author Posted August 17, 2013 Where am I supposed to write this? Because onPlayerTick seems only tick the client player (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 Quote
Knux14 Posted August 17, 2013 Author Posted August 17, 2013 onPlayerTick is in the tick handler which is registred with TickRegistry.registerTick(new TickHandlerServer(), Side.SERVER); Quote
GotoLink Posted August 17, 2013 Posted August 17, 2013 You know you can register ticks on client side too, don't you ? Quote
Knux14 Posted August 17, 2013 Author Posted August 17, 2013 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 Quote
GotoLink Posted August 17, 2013 Posted August 17, 2013 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. Quote
Knux14 Posted August 18, 2013 Author Posted August 18, 2013 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 Quote
Recommended Posts
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.