mirror of
https://github.com/Brettflan/WorldBorder.git
synced 2024-11-29 13:36:17 +01:00
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:
parent
28e5ea7019
commit
1b696ef724
@ -3,6 +3,7 @@ package com.wimbli.WorldBorder;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -23,6 +24,10 @@ public class BorderCheckTask implements Runnable
|
|||||||
if (server == null)
|
if (server == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// if knockback is set to 0, simply return
|
||||||
|
if (Config.KnockBack() == 0.0)
|
||||||
|
return;
|
||||||
|
|
||||||
Player[] players = server.getOnlinePlayers();
|
Player[] players = server.getOnlinePlayers();
|
||||||
|
|
||||||
for (int i = 0; i < players.length; i++){
|
for (int i = 0; i < players.length; i++){
|
||||||
@ -72,7 +77,7 @@ public class BorderCheckTask implements Runnable
|
|||||||
Entity ride = player.getVehicle();
|
Entity ride = player.getVehicle();
|
||||||
if (ride != null)
|
if (ride != null)
|
||||||
{ // vehicles need to be offset vertically and have velocity stopped
|
{ // 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);
|
newLoc.setY(newLoc.getY() + vertOffset);
|
||||||
ride.setVelocity(new Vector(0, 0, 0));
|
ride.setVelocity(new Vector(0, 0, 0));
|
||||||
ride.teleport(newLoc);
|
ride.teleport(newLoc);
|
||||||
|
@ -134,10 +134,6 @@ public class BorderData
|
|||||||
|
|
||||||
public Location correctedPosition(Location loc, boolean round)
|
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 this border has a shape override set, use it
|
||||||
if (shapeRound != null)
|
if (shapeRound != null)
|
||||||
round = shapeRound.booleanValue();
|
round = shapeRound.booleanValue();
|
||||||
|
@ -14,6 +14,10 @@ public class WBListener implements Listener
|
|||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
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);
|
Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true);
|
||||||
if (newLoc != null)
|
if (newLoc != null)
|
||||||
event.setTo(newLoc);
|
event.setTo(newLoc);
|
||||||
|
Loading…
Reference in New Issue
Block a user