0 knockback was glitchy; fixed

Also attempt to fix problem when riding mobs via MobRider where mob and player end up underground after knockback; seems unsuccessful. Seeing as pigs in vanilla CraftBukkit without MobRider don't have this problem, but _do_ have the problem along with all other mobs when MobRider is loaded, I'm not bothering with this one further for now.
This commit is contained in:
Brettflan 2012-11-04 16:46:46 -06:00
parent 28e5ea7019
commit 1b696ef724
3 changed files with 10 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package com.wimbli.WorldBorder;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import org.bukkit.Server;
@ -23,6 +24,10 @@ public class BorderCheckTask implements Runnable
if (server == null)
return;
// if knockback is set to 0, simply return
if (Config.KnockBack() == 0.0)
return;
Player[] players = server.getOnlinePlayers();
for (int i = 0; i < players.length; i++){
@ -72,7 +77,7 @@ public class BorderCheckTask implements Runnable
Entity ride = player.getVehicle();
if (ride != null)
{ // vehicles need to be offset vertically and have velocity stopped
double vertOffset = ride.getLocation().getY() - loc.getY();
double vertOffset = (ride instanceof LivingEntity) ? 0 : ride.getLocation().getY() - loc.getY();
newLoc.setY(newLoc.getY() + vertOffset);
ride.setVelocity(new Vector(0, 0, 0));
ride.teleport(newLoc);

View File

@ -134,10 +134,6 @@ public class BorderData
public Location correctedPosition(Location loc, boolean round)
{
// if knockback is set to 0, simply return
if (Config.KnockBack() == 0.0)
return loc;
// if this border has a shape override set, use it
if (shapeRound != null)
round = shapeRound.booleanValue();

View File

@ -14,6 +14,10 @@ public class WBListener implements Listener
{
if (event.isCancelled()) return;
// if knockback is set to 0, simply return
if (Config.KnockBack() == 0.0)
return;
Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true);
if (newLoc != null)
event.setTo(newLoc);