Hello, I'm pretty new with bukkit and tried to make a low gravity plugin Here's the code: Code:java public void Gravity(final double x, final double y, final double z, final double x1, final double y1, final double z1) { this.reloadConfig(); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){ public void run() { for(Player gravSend : Bukkit.getServer().getOnlinePlayers()) { if(!gravSend.isFlying()) { if(gravity) { if(!gravSend.isOnGround()) { if(isInRect(gravSend, new Location(gravSend.getWorld(),x,y,z), new Location(gravSend.getWorld(),x1,y1,z1))) { double currentVecX = gravSend.getVelocity().getX(); double currentVecZ = gravSend.getVelocity().getZ(); double currentVecY = gravSend.getVelocity().getY(); gravSend.setVelocity(new Vector(currentVecX * 1.1 ,currentVecY + 0.04,currentVecZ * 1.1)); } } } else { return; } } } } }, 0L, 1L); } The code is pretty simple. It just checks for a player in the region and applies a velocity. It works perfectly on my localhost test-server, but it's really laggy on a real servers! I don't know if there's a way to get rid of the jiggle but if there is please let me know!
New to bukkit API and first thing you try is velocities? That's a hard task. Also, it is laggy because you are running a repeating task every tick.
Eh, new to Bukkit- he never said to math SE_Original Like The Fancy Whale said, you're running a task every tick (there's 20 ticks in a second) that can do some pretty hefty calculations. You're checking for each player on the server (the more players the longer it takes) to see if they're within a rectangle (larger the rectangle the longer it takes), you're making multiple Location objects each tick (granted they're temporary), and then you're calculating velocities to be applied to the player. You may want to increase the time between intervals. Also, question: you only call Gravity(double, double, double, double, double, double) once right? If not, you may have multiple tasks running this which would most definitely be a huge performance hit.
Thanks for the help! I tried removing the isInRect part and replaced it with isInWorld, again works perfectly on localhost! And I think you understood it wrong, by jiggle and lag I meant the player movement! I didn't test it on the server yet because the one I test it on is not mine. And yeah i only call gravity once!
If it's not a performance hit with lag, and the player just looks "laggy", then it's due to the velocity calculations changing so quickly. Also, I'd recommend renaming that method to be using lowerCamelCase as per the Oracle's Java coding conventions (not an up to date document by the way, but this particular section has not changed as far as I know).
New to 'Bukkit' That doesn't mean new to Java. But yes... It is hard anyways ^^Also, Apply velocity (Upwards +) on Jump event.
ChipDev Not quite, you would need to check if the to y is higher than the from y. This is more specific because just checking if y isn't same means a falling player could be considered jumping.
Yes.. Thats what I meant. Your'e J.R Tolkien I'm Hemingway. (Saying I give less detail.) But also.. How is that bad if the player is falling? He wants low gravity .-.
ChipDev Perhaps, but you are contradicting yourself... While these two statements are not mutually exclusive, they are still not concordant phrases. Your first suggestion was to try and detect a player jumping (raise in y), and saying that there is nothing wrong with fall detection (lowering in y) makes no sense. I was pointing out that your statements don't exactly agree with each other.
AoH_Ruthless Oh well. Another fraise by AoH that makes me look stupid.. Lol! So yes, Apply upwards on jump, Apply slowness on fall. But also...: Like I said, I don't like to give so much detail, If you add + on jump, Then well... its obvious to - on fall.