Potential fix(es) for flying after respawning

This commit is contained in:
Evenprime 2011-06-30 13:30:00 +02:00
parent 61d89d78d8
commit a4bb515ee0
3 changed files with 18 additions and 15 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 1.06
version: 1.06a
softdepend: [ Permissions, CraftIRC ]

View File

@ -392,7 +392,7 @@ public class MovingCheck extends Check {
final Location l = data.lastLocation;
// Player is currently changing worlds
if(l.getWorld() != from.getWorld()) {
if(!l.getWorld().equals(from.getWorld())) {
return true;
}
@ -462,7 +462,7 @@ public class MovingCheck extends Check {
if(!event.isCancelled()) {
data.lastLocation = event.getTo();
data.jumpPhase = 0;
data.setBackPoint = event.getTo();
data.setBackPoint = event.getTo().clone();
}
}
@ -472,7 +472,8 @@ public class MovingCheck extends Check {
*/
public void respawned(PlayerRespawnEvent event) {
MovingData data = MovingData.get(event.getPlayer());
data.lastLocation = event.getRespawnLocation(); // We expect the player to be there next
data.lastLocation = event.getRespawnLocation();
data.setBackPoint = event.getRespawnLocation().clone();
}
/**
@ -525,12 +526,15 @@ public class MovingCheck extends Check {
double y = data.setBackPoint.getY();
// search for the first solid block up to 5 blocks below the setbackpoint and teleport the player there
for(int i = 0; i < 20; i++) {
int i = 0;
for(; i < 20; i++) {
if(playerIsOnGround(data.setBackPoint, -0.5*i) != MovingData.NONSOLID) {
y -= 0.5*i;
break;
}
}
y -= 0.5*i;
data.setBackPoint.setY(y);
// Remember the location we send the player to, to identify teleports that were started by us
data.teleportTo = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch());

View File

@ -16,11 +16,11 @@ public class MovingData {
public double horizFreedom = 0.0D;
public double vertFreedom = 0.0D;
public int vertFreedomCounter = 0;
// setbackpoint is a recommendation - try to teleport to first solid block below it
// for better effect
public Location setBackPoint = null;
public int summaryTask = -1;
public Level highestLogLevel = null;
public double maxYVelocity = 0.0D;
@ -46,18 +46,18 @@ public class MovingData {
public static final int LADDER = 4; // 0x00000100
public static final int FENCE = 8; // 0x00001000
// Until I can think of a better way to determine if a block is solid or not, this is what I'll do
public static final int types[] = new int[256];
static {
// Find and define properties of all blocks
for(int i = 0; i < types.length; i++) {
// Everything is considered nonsolid at first
types[i] = NONSOLID;
if(Block.byId[i] != null) {
if(Block.byId[i].material.isSolid()) {
// solid blocks like STONE, CAKE, TRAPDOORS
@ -69,12 +69,12 @@ public class MovingData {
}
}
}
// Special types just for me
types[Material.LADDER.getId()]= LADDER | SOLID;
types[Material.FENCE.getId()]= FENCE | SOLID;
}
public static MovingData get(final Player p) {
final NoCheatData data = NoCheatData.getPlayerData(p);
@ -86,5 +86,4 @@ public class MovingData {
return data.moving;
}
}