[BLEEDING] First attempt to make slime blocks work.

This commit is contained in:
asofold 2014-12-10 00:45:08 +01:00
parent a51965c57d
commit 3eab23ae92
27 changed files with 2957 additions and 2787 deletions

View File

@ -324,6 +324,11 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
}
}
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.NO; // Assumption.
}
// @Override
// public void correctDirection(Player player) {
// // TODO: Consider using reflection (detect CraftPlayer, access EntityPlayer + check if possible (!), use flags for if valid or invalid.)

View File

@ -156,13 +156,18 @@ public class MCAccessCB2512 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -156,13 +156,18 @@ public class MCAccessCB2545 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -157,13 +157,18 @@ public class MCAccessCB2602 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -158,13 +158,18 @@ public class MCAccessCB2645 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -160,13 +160,18 @@ public class MCAccessCB2691 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -159,13 +159,18 @@ public class MCAccessCB2763 implements MCAccess{
}
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -153,13 +153,18 @@ public class MCAccessCB2794 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -154,13 +154,18 @@ public class MCAccessCB2808 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -155,13 +155,18 @@ public class MCAccessCB2882 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -155,13 +155,18 @@ public class MCAccessCB2922 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -155,13 +155,18 @@ public class MCAccessCB3026 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -174,13 +174,18 @@ public class MCAccessCB3043 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -176,13 +176,18 @@ public class MCAccessCB3100 implements MCAccess{
return mat.hasGravity();
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.MAYBE;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -176,6 +176,11 @@ public class MCAccessCBDev implements MCAccess{
return mat.hasGravity();
}
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.YES;
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();

View File

@ -9,6 +9,7 @@ import org.bukkit.command.CommandMap;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.bukkit.MCAccessBukkit;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -53,4 +54,9 @@ public class MCAccessGlowstone extends MCAccessBukkit{
((GlowPlayer) player).damage(damage, DamageCause.FALL);
}
@Override
public AlmostBoolean dealFallDamageFiresAnEvent() {
return AlmostBoolean.YES; // Assumption (it's native access).
}
}

View File

@ -13,7 +13,7 @@ import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.ViolationData;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
import fr.neatmonster.nocheatplus.checks.moving.MovingUtil;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
@ -46,7 +46,7 @@ public class Critical extends Check {
if (mcFallDistance > 0.0 && data.debug && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) {
final MovingData mData = MovingData.getData(player);
if (MovingListener.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)) {
if (MovingUtil.shouldCheckSurvivalFly(player, mData, mCc) && CheckType.MOVING_NOFALL.isEnabled(player)) {
// TODO: Set max y in MovingListener, to be independent of sf/nofall!
player.sendMessage("Critical: fd=" + mcFallDistance + "(" + mData.noFallFallDistance +") y=" + loc.getY() + ((mData.hasSetBack() && mData.getSetBackY() < mData.noFallMaxY) ? (" jumped=" + StringUtil.fdec3.format(mData.noFallMaxY - mData.getSetBackY())): ""));
}
@ -61,7 +61,7 @@ public class Critical extends Check {
// TODO: Skip near the highest jump height (needs check if head collided with something solid, which also detects low jump).
if (dataM.sfLowJump || mcFallDistance < cc.criticalFallDistance && !BlockProperties.isResetCond(player, loc, mCc.yOnGround)) {
final MovingConfig ccM = MovingConfig.getConfig(player);
if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)) {
if (MovingUtil.shouldCheckSurvivalFly(player, dataM, ccM)) {
data.criticalVL += 1.0;
// Execute whatever actions are associated with this check and
// the violation level and find out if we should cancel the event.

View File

@ -35,7 +35,7 @@ import fr.neatmonster.nocheatplus.checks.moving.LocationTrace.TraceEntry;
import fr.neatmonster.nocheatplus.checks.moving.MediumLiftOff;
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
import fr.neatmonster.nocheatplus.checks.moving.MovingUtil;
import fr.neatmonster.nocheatplus.compat.BridgeHealth;
import fr.neatmonster.nocheatplus.components.JoinLeaveListener;
import fr.neatmonster.nocheatplus.logging.Streams;
@ -297,7 +297,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
if (hDist >= 0.23) {
// TODO: Might need to check hDist relative to speed / modifiers.
final MovingConfig mc = MovingConfig.getConfig(player);
if (now <= mData.timeSprinting + mc.sprintingGrace && MovingListener.shouldCheckSurvivalFly(player, mData, mc)){
if (now <= mData.timeSprinting + mc.sprintingGrace && MovingUtil.shouldCheckSurvivalFly(player, mData, mc)){
// Judge as "lost sprint" problem.
// TODO: What would mData.lostSprintCount > 0 mean here?
mData.lostSprintCount = 7;
@ -566,7 +566,7 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
if (damagedData.debug || mdata.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, damagedPlayer.getName() + " received knockback level: " + level);
}
MovingListener.addVelocity(damagedPlayer, mdata, mcc, dir.getX(), vy, dir.getZ());
mdata.addVelocity(damagedPlayer, mcc, dir.getX(), vy, dir.getZ());
}
/**

View File

@ -7,12 +7,15 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.access.ACheckData;
import fr.neatmonster.nocheatplus.checks.access.CheckDataFactory;
import fr.neatmonster.nocheatplus.checks.access.ICheckData;
import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.ActionAccumulator;
import fr.neatmonster.nocheatplus.utilities.ActionFrequency;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
import fr.neatmonster.nocheatplus.utilities.TickTask;
/**
* Player specific data for the moving checks.
@ -523,20 +526,12 @@ public class MovingData extends ACheckData {
horVel.add(vel);
}
/**
* Add vertical velocity (distance). <br>
* @param vel
*/
public void addVerticalVelocity(final Velocity vel) {
horVel.add(vel);
}
/**
* Remove all vertical and horizontal velocity.
*/
public void removeAllVelocity() {
horVel.clear();
// verVel.clear();
// verVel.clear();
}
/**
@ -546,7 +541,7 @@ public class MovingData extends ACheckData {
*/
public void removeInvalidVelocity(final int tick) {
horVel.removeInvalid(tick);
// verVel.removeInvalid(tick);
// verVel.removeInvalid(tick);
}
/**
@ -571,13 +566,13 @@ public class MovingData extends ACheckData {
return horVel.hasQueued();
}
// public boolean hasActiveVerVel() {
// return verVel.hasActive();
// }
// public boolean hasActiveVerVel() {
// return verVel.hasActive();
// }
// public boolean hasQueuedVerVel() {
// return verVel.hasQueued();
// }
// public boolean hasQueuedVerVel() {
// return verVel.hasQueued();
// }
/**
* Called for moving events, increase age of velocity, decrease amounts, check which entries are invalid. Both horizontal and vertical.
@ -587,7 +582,7 @@ public class MovingData extends ACheckData {
horVel.tick();
// Vertical velocity (new concept).
// verVel.tick();
// verVel.tick();
if (verticalVelocity <= 0.09D) {
verticalVelocityUsed ++;
verticalVelocityCounter--;
@ -779,4 +774,50 @@ public class MovingData extends ACheckData {
trace = null;
}
/**
* Add velocity to internal book-keeping.
* @param player
* @param data
* @param cc
* @param vx
* @param vy
* @param vz
*/
public void addVelocity(final Player player, final MovingConfig cc, final double vx, final double vy, final double vz) {
final int tick = TickTask.getTick();
removeInvalidVelocity(tick - cc.velocityActivationTicks);
if (debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " new velocity: " + vx + ", " + vy + ", " + vz);
}
boolean used = false;
if (vy > 0D) {
used = true;
if (verticalFreedom <= 0.001 && verticalVelocityCounter >= 0) {
verticalVelocity = 0;
}
verticalVelocity += vy;
verticalFreedom += verticalVelocity;
verticalVelocityCounter = Math.min(100, Math.max(verticalVelocityCounter, cc.velocityGraceTicks ) + 1 + (int) Math.round(vy * 10.0)); // 50;
verticalVelocityUsed = 0;
}
if (vx != 0.0 && vz != 0.0) {
final double newVal = Math.sqrt(vx * vx + vz * vz);
used = true;
final Velocity vel = new Velocity(tick, newVal, cc.velocityActivationCounter, Math.max(20, 1 + (int) Math.round(newVal * 10.0)));
addHorizontalVelocity(vel);
}
// Set dirty flag here.
if (used) {
sfDirty = true; // TODO: Only needed for vertical velocity? Get rid anyway :p.
sfNoLowJump = true;
}
// TODO: clear accounting here ?
}
}

View File

@ -83,65 +83,6 @@ import fr.neatmonster.nocheatplus.utilities.build.BuildParameters;
*/
public class MovingListener extends CheckListener implements TickListener, IRemoveData, IHaveCheckType, INotifyReload, INeedConfig, JoinLeaveListener{
/**
* Check if the player is to be checked by the survivalfly check.
* @param player
* @param data
* @param cc
* @return
*/
public static final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc) {
return cc.survivalFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) && !player.hasPermission(Permissions.MOVING_SURVIVALFLY) &&
(cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && !player.isFlying() && (cc.ignoreAllowFlight || !player.getAllowFlight());
}
/**
* Handle an illegal move by a player, attempt to restore a valid location.
* @param event
* @param player
* @param data
*/
public static void handleIllegalMove(final PlayerMoveEvent event, final Player player, final MovingData data)
{
// This might get extended to a check-like thing.
boolean restored = false;
final PlayerLocation pLoc = new PlayerLocation(NCPAPIProvider.getNoCheatPlusAPI().getMCAccess(), null);
// (Mind that we don't set the block cache here).
final Location loc = player.getLocation();
if (!restored && data.hasSetBack()) {
final Location setBack = data.getSetBack(loc);
pLoc.set(setBack, player);
if (!pLoc.isIllegal()) {
event.setFrom(setBack);
event.setTo(setBack);
restored = true;
}
else {
data.resetSetBack();
}
}
if (!restored) {
pLoc.set(loc, player);
if (!pLoc.isIllegal()) {
event.setFrom(loc);
event.setTo(loc);
restored = true;
}
}
pLoc.cleanup();
if (!restored) {
// TODO: reset the bounding box of the player ?
if (MovingConfig.getConfig(player).tempKickIllegal) {
NCPAPIProvider.getNoCheatPlusAPI().denyLogin(player.getName(), 24L * 60L * 60L * 1000L);
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them and deny login for 24 hours");
} else {
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them.");
}
CheckUtils.kickIllegalMove(player);
}
}
/** The instance of NoCheatPlus. */
private final Plugin plugin = Bukkit.getPluginManager().getPlugin("NoCheatPlus"); // TODO
@ -238,7 +179,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
if (Math.abs(loc.getX() - 0.5 - block.getX()) <= 1D
&& Math.abs(loc.getZ() - 0.5 - block.getZ()) <= 1D
&& loc.getY() - blockY > 0D && loc.getY() - blockY < 2D
&& (canJumpOffTop(mat) || BlockProperties.isLiquid(mat))) {
&& (MovingUtil.canJumpOffTop(mat) || BlockProperties.isLiquid(mat))) {
// The creative fly and/or survival fly check is enabled, the
// block was placed below the player and is
// solid, so do what we have to do.
@ -248,16 +189,6 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
useLoc.setWorld(null);
}
/**
* Used for a workaround that resets the set-back for the case of jumping on just placed blocks.
* @param id
* @return
*/
private static boolean canJumpOffTop(final Material blockType) {
// TODO: Test if this can be removed!
return BlockProperties.isGround(blockType) || BlockProperties.isSolid(blockType);
}
/**
* We listen to this event to prevent player from flying by sending bed leaving packets.
*
@ -288,7 +219,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final MovingData data = MovingData.getData(player);
final MovingConfig cc = MovingConfig.getConfig(player);
Location target = null;
final boolean sfCheck = shouldCheckSurvivalFly(player, data, cc);
final boolean sfCheck = MovingUtil.shouldCheckSurvivalFly(player, data, cc);
if (sfCheck) {
target = data.getSetBack(loc);
}
@ -452,7 +383,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
}
// Check for illegal move and bounding box etc.
if (moveInfo.from.isIllegal() || moveInfo.to.isIllegal()) {
handleIllegalMove(event, player, data);
MovingUtil.handleIllegalMove(event, player, data);
moveInfo.cleanup();
parkedInfo.add(moveInfo);
return;
@ -548,7 +479,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Check which fly check to use.
final boolean checkCf;
final boolean checkSf;
if (shouldCheckSurvivalFly(player, data, cc)) {
if (MovingUtil.shouldCheckSurvivalFly(player, data, cc)) {
checkCf = false;
checkSf = true;
data.adjustWalkSpeed(player.getWalkSpeed(), tick, cc.speedGrace);
@ -564,6 +495,17 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
checkCf = checkSf = false;
}
boolean checkNf = true;
if (checkSf || checkCf) {
// Check jumping on things like slime blocks.
if (to.getY() < from.getY() && player.getFallDistance() > 1f && (BlockProperties.getBlockFlags(pTo.getTypeIdBelow()) & BlockProperties.F_BOUNCE25) != 0L) {
// Apply changes to NoFall and other.
processTrampoline(player, pFrom, pTo, data, cc);
// Skip NoFall.
checkNf = false;
}
}
// Flying checks.
if (checkSf) {
// SurvivalFly
@ -587,7 +529,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Only check if passable has not already set back.
newTo = survivalFly.check(player, pFrom, pTo, data, cc, time);
}
final boolean checkNf = cc.noFallCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_NOFALL) && !player.hasPermission(Permissions.MOVING_NOFALL);
// Only check NoFall, if not already vetoed.
if (checkNf) {
checkNf = cc.noFallCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_NOFALL) && !player.hasPermission(Permissions.MOVING_NOFALL);
}
if (newTo == null) {
// Hover.
// TODO: Could reset for from-on-ground as well, for not too big moves.
@ -669,6 +614,32 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
parkedInfo.add(moveInfo);
}
private void processTrampoline(final Player player, final PlayerLocation from, final PlayerLocation to, final MovingData data, final MovingConfig cc) {
// TODO: Where to put...
// TODO: Other side conditions (fluids, web)
// TODO: Fake fall distance exploit (to bounce off slime blocks :p).
// TODO: Confine further (depends on which checks are enabled, if possible to check, e.g. noFallMaxY).
// Check for slime block below explicitly.
// The center of the player must be above the block.
if (cc.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " Trampoline effect...");
}
// TODO: Consider making this just a checking method (use result for applying effects).
// CHEATING: Add velocity.
// TODO: 1. Confine for direct use (no latency here). 2. Hard set velocity? 3.. Switch to friction based.
if (!survivalFly.isReallySneaking(player)) {
data.addVelocity(player, cc, 0.0, (double) player.getFallDistance() / 30.0, 0.0);
}
// CHEATING: Remove fall distance:
// TODO: Test under which conditions the player would still take fall damage.
// TODO: Depends on NoFall being enabled as well.
player.setFallDistance(0f);
data.noFallFallDistance = 0f;
data.noFallMaxY = 0.0;
data.noFallSkipAirCheck = true;
// (Skipping the NoFall check is necessary, because THIS move can be big.)
}
/**
*
* @param player
@ -1022,53 +993,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Process velocity.
final Vector velocity = event.getVelocity();
final MovingConfig cc = MovingConfig.getConfig(player);
addVelocity(player, data, cc, velocity.getX(), velocity.getY(), velocity.getZ());
}
/**
* Add velocity to internal book-keeping.
* @param player
* @param data
* @param cc
* @param vx
* @param vy
* @param vz
*/
public static void addVelocity(final Player player, final MovingData data, final MovingConfig cc, final double vx, final double vy, final double vz) {
final int tick = TickTask.getTick();
data.removeInvalidVelocity(tick - cc.velocityActivationTicks);
if (data.debug) {
NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, player.getName() + " new velocity: " + vx + ", " + vy + ", " + vz);
}
boolean used = false;
if (vy > 0D) {
used = true;
if (data.verticalFreedom <= 0.001 && data.verticalVelocityCounter >= 0) {
data.verticalVelocity = 0;
}
data.verticalVelocity += vy;
data.verticalFreedom += data.verticalVelocity;
data.verticalVelocityCounter = Math.min(100, Math.max(data.verticalVelocityCounter, cc.velocityGraceTicks ) + 1 + (int) Math.round(vy * 10.0)); // 50;
data.verticalVelocityUsed = 0;
}
if (vx != 0.0 && vz != 0.0) {
final double newVal = Math.sqrt(vx * vx + vz * vz);
used = true;
final Velocity vel = new Velocity(tick, newVal, cc.velocityActivationCounter, Math.max(20, 1 + (int) Math.round(newVal * 10.0)));
data.addHorizontalVelocity(vel);
}
// Set dirty flag here.
if (used) {
data.sfDirty = true; // TODO: Only needed for vertical velocity? Get rid anyway :p.
data.sfNoLowJump = true;
}
// TODO: clear accounting here ?
data.addVelocity(player, cc, velocity.getX(), velocity.getY(), velocity.getZ());
}
/**
@ -1178,7 +1103,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
return;
}
final MovingConfig cc = MovingConfig.getConfig(player);
if (event.isCancelled() || !shouldCheckSurvivalFly(player, data, cc) || !noFall.isEnabled(player)) {
if (event.isCancelled() || !MovingUtil.shouldCheckSurvivalFly(player, data, cc) || !noFall.isEnabled(player)) {
data.clearNoFallData();
return;
}
@ -1659,7 +1584,7 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
else{
if (data.sfHoverTicks > cc.sfHoverTicks) {
// Re-Check if survivalfly can apply at all.
if (shouldCheckSurvivalFly(player, data, cc)) {
if (MovingUtil.shouldCheckSurvivalFly(player, data, cc)) {
handleHoverViolation(player, loc, cc, data);
// Assume the player might still be hovering.
res = false;

View File

@ -0,0 +1,92 @@
package fr.neatmonster.nocheatplus.checks.moving;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
/**
* Static utility methods.
* @author dev1mc
*
*/
public class MovingUtil {
/**
* Check if the player is to be checked by the survivalfly check.
* @param player
* @param data
* @param cc
* @return
*/
public static final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc) {
return cc.survivalFlyCheck && !NCPExemptionManager.isExempted(player, CheckType.MOVING_SURVIVALFLY) && !player.hasPermission(Permissions.MOVING_SURVIVALFLY) &&
(cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && !player.isFlying() && (cc.ignoreAllowFlight || !player.getAllowFlight());
}
/**
* Handle an illegal move by a player, attempt to restore a valid location.
* @param event
* @param player
* @param data
*/
public static void handleIllegalMove(final PlayerMoveEvent event, final Player player, final MovingData data)
{
// This might get extended to a check-like thing.
boolean restored = false;
final PlayerLocation pLoc = new PlayerLocation(NCPAPIProvider.getNoCheatPlusAPI().getMCAccess(), null);
// (Mind that we don't set the block cache here).
final Location loc = player.getLocation();
if (!restored && data.hasSetBack()) {
final Location setBack = data.getSetBack(loc);
pLoc.set(setBack, player);
if (!pLoc.isIllegal()) {
event.setFrom(setBack);
event.setTo(setBack);
restored = true;
}
else {
data.resetSetBack();
}
}
if (!restored) {
pLoc.set(loc, player);
if (!pLoc.isIllegal()) {
event.setFrom(loc);
event.setTo(loc);
restored = true;
}
}
pLoc.cleanup();
if (!restored) {
// TODO: reset the bounding box of the player ?
if (MovingConfig.getConfig(player).tempKickIllegal) {
NCPAPIProvider.getNoCheatPlusAPI().denyLogin(player.getName(), 24L * 60L * 60L * 1000L);
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them and deny login for 24 hours");
} else {
StaticLog.logSevere("[NCP] could not restore location for " + player.getName() + ", kicking them.");
}
CheckUtils.kickIllegalMove(player);
}
}
/**
* Used for a workaround that resets the set-back for the case of jumping on just placed blocks.
* @param id
* @return
*/
public static boolean canJumpOffTop(final Material blockType) {
return BlockProperties.isGround(blockType) || BlockProperties.isSolid(blockType);
}
}

View File

@ -76,7 +76,11 @@ public class NoFall extends Check {
private void dealFallDamage(final Player player, final double damage) {
// TODO: Byte code compatibility ?
if (mcAccess.dealFallDamageFiresAnEvent().decide()) {
// TODO: Better decideOptimistically?
mcAccess.dealFallDamage(player, damage);
}
else {
final EntityDamageEvent event = BridgeHealth.getEntityDamageEvent(player, DamageCause.FALL, damage);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()){
@ -84,6 +88,8 @@ public class NoFall extends Check {
player.setLastDamageCause(event);
mcAccess.dealFallDamage(player, BridgeHealth.getDamage(event));
}
}
// TODO: let this be done by the damage event (!).
// data.clearNoFallData(); // -> currently done in the damage eventhandling method.
player.setFallDistance(0);

View File

@ -589,6 +589,15 @@ public class SurvivalFly extends Check {
return hAllowedDistance;
}
/**
* Access method from outside.
* @param player
* @return
*/
public boolean isReallySneaking(final Player player) {
return reallySneaking.contains(player.getName());
}
/**
* Check if touching the ground was lost (client did not send, or server did not put it through).
* @param player
@ -1140,6 +1149,7 @@ public class SurvivalFly extends Check {
double yMargin = cc.yOnGround;
// TODO: Might set margin higher depending on distance to 0 of block and last y distance etc.
// TODO: check with iY + 0.25 removed.
// TODO: Slime blocks ?
if (BlockProperties.isOnGround(from.getBlockCache(), Math.min(data.fromX, from.getX()) - r, iY - yMargin, Math.min(data.fromZ, from.getZ()) - r, Math.max(data.fromX, from.getX()) + r, iY + 0.25, Math.max(data.fromZ, from.getZ()) + r, 0L)) {
return applyLostGround(player, from, true, data, "interpolate");
}

View File

@ -98,6 +98,12 @@ public interface MCAccess {
public void dealFallDamage(Player player, double damage);
/**
* If dealFallDamage(Player, double) will fire a damage event.
* @return
*/
public AlmostBoolean dealFallDamageFiresAnEvent();
/**
* This may well be removed, if possible to check with Bukkit.
* @param damaged
@ -129,11 +135,11 @@ public interface MCAccess {
*/
public boolean hasGravity(Material type);
// /**
// * Correct the direction (yaw + pitch). If this can't be done lightly it should just do nothing. Check pitch and yaw before calling, use auxiliary methods from LocUtil.
// * @param player
// */
// public void correctDirection(Player player);
// /**
// * Correct the direction (yaw + pitch). If this can't be done lightly it should just do nothing. Check pitch and yaw before calling, use auxiliary methods from LocUtil.
// * @param player
// */
// public void correctDirection(Player player);
}

View File

@ -7,6 +7,7 @@ import fr.neatmonster.nocheatplus.compat.blocks.init.BlockInit;
import fr.neatmonster.nocheatplus.config.WorldConfigProvider;
import fr.neatmonster.nocheatplus.logging.StaticLog;
import fr.neatmonster.nocheatplus.utilities.BlockFlags;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
public class BlocksMC1_8 implements BlockPropertiesSetup {
@ -22,6 +23,8 @@ public class BlocksMC1_8 implements BlockPropertiesSetup {
public void setupBlockProperties(WorldConfigProvider<?> worldConfigProvider) {
// 165(SLIME_BLOCK
BlockInit.setAs(165, Material.TNT); // Full block, instant break.
// Add the bouncing flag.
BlockProperties.setBlockFlags(165, BlockProperties.getBlockFlags(165) | BlockProperties.F_BOUNCE25);
// 166(BARRIER
BlockInit.setAs(166, Material.BEDROCK); // Full block, unbreakable.

View File

@ -374,6 +374,12 @@ public class BlockProperties {
/** Fence gate style with 0x04 being fully passable. */
public static final long F_PASSABLE_X4 = 0x200000;
// TODO: Separate no fall damage flag ? [-> on ground could return "dominating" flags, or extra flags]
/** Like slime block: bounce back 25% of fall height without taking fall damage [TODO: Check/adjust]. */
public static final long F_BOUNCE25 = 0x400000;
// TODO: When flags are out, switch to per-block classes :p.
/**
* Map flag to names.
*/

View File

@ -311,10 +311,10 @@ public class PlayerLocation {
return false;
}
// TODO: ...
// final double dX = -0.10000000149011612D;
// final double dY = -0.40000000596046448D;
// final double dZ = dX;
// inLava = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ, maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_LAVA);
// final double dX = -0.10000000149011612D;
// final double dY = -0.40000000596046448D;
// final double dZ = dX;
// inLava = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ, maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_LAVA);
inLava = BlockProperties.collides(blockCache, minX, minY, minZ, maxX, maxY, maxZ, BlockProperties.F_LAVA);
}
return inLava;
@ -332,10 +332,10 @@ public class PlayerLocation {
return false;
}
// TODO: ...
// final double dX = -0.001D;
// final double dY = -0.40000000596046448D - 0.001D;
// final double dZ = dX;
// inWater = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ, maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_WATER);
// final double dX = -0.001D;
// final double dY = -0.40000000596046448D - 0.001D;
// final double dZ = dX;
// inWater = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ, maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_WATER);
inWater = BlockProperties.collides(blockCache, minX, minY, minZ, maxX, maxY, maxZ, BlockProperties.F_WATER);
}
@ -394,8 +394,8 @@ public class PlayerLocation {
}
onClimbable = (BlockProperties.getBlockFlags(getTypeId()) & BlockProperties.F_CLIMBABLE) != 0;
// TODO: maybe use specialized bounding box.
// final double d = 0.1d;
// onClimbable = BlockProperties.collides(getBlockAccess(), minX - d, minY - d, minZ - d, maxX + d, minY + 1.0, maxZ + d, BlockProperties.F_CLIMBABLE);
// final double d = 0.1d;
// onClimbable = BlockProperties.collides(getBlockAccess(), minX - d, minY - d, minZ - d, maxX + d, minY + 1.0, maxZ + d, BlockProperties.F_CLIMBABLE);
}
return onClimbable;
}
@ -487,13 +487,13 @@ public class PlayerLocation {
// TODO: BlockHeight is needed for fences, use right away (above)?
if (!BlockProperties.isPassableWorkaround(blockCache, blockX, bY, blockZ, minX - blockX, minY - yOnGround - bY, minZ - blockZ, id, maxX - minX, yOnGround, maxZ - minZ, 1.0)
|| (flags & BlockProperties.F_GROUND_HEIGHT) != 0 && BlockProperties.getGroundMinHeight(blockCache, blockX, bY, blockZ, id, bounds, flags) <= y - bY) {
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** onground SHORTCUT");
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** onground SHORTCUT");
onGround = true;
}
}
}
if (onGround == null) {
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** fetch onground std");
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** fetch onground std");
// Full on-ground check (blocks).
// Note: Might check for half-block height too (getTypeId), but that is much more seldom.
onGround = BlockProperties.isOnGround(blockCache, minX, minY - yOnGround, minZ, maxX, minY, maxZ, 0L);
@ -503,7 +503,7 @@ public class PlayerLocation {
}
if (onGround) onGroundMinY = Math.min(onGroundMinY, yOnGround);
else {
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** onground check entities");
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** onground check entities");
// TODO: further confine this ?
notOnGroundMaxY = Math.max(notOnGroundMaxY, yOnGround);
final double d1 = 0.25D;
@ -568,7 +568,7 @@ public class PlayerLocation {
if (notOnGroundMaxY >= yOnGround) return false;
}
}
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** Fetch on-ground: yOnGround=" + yOnGround + " xzM=" + xzMargin + " yM=" + yMargin + " ign=" + ignoreFlags);
// NCPAPIProvider.getNoCheatPlusAPI().getLogManager().debug(Streams.TRACE_FILE, "*** Fetch on-ground: yOnGround=" + yOnGround + " xzM=" + xzMargin + " yM=" + yMargin + " ign=" + ignoreFlags);
final boolean onGround = BlockProperties.isOnGround(blockCache, minX - xzMargin, minY - yOnGround - yMargin, minZ - xzMargin, maxX + xzMargin, minY + yMargin, maxZ + xzMargin, ignoreFlags);
if (ignoreFlags == 0) {
if (onGround) {
@ -649,7 +649,7 @@ public class PlayerLocation {
public boolean isPassable() {
if (passable == null) {
passable = BlockProperties.isPassable(blockCache, x, y, z, getTypeId());
// passable = BlockProperties.isPassableExact(blockCache, x, y, z, getTypeId());
// passable = BlockProperties.isPassableExact(blockCache, x, y, z, getTypeId());
}
return passable;
}