mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-27 14:13:11 +02:00
Add a minimized interface for the odd width and height getting.
This commit is contained in:
parent
bfc6422115
commit
7130fed017
@ -43,10 +43,10 @@ import fr.neatmonster.nocheatplus.checks.moving.velocity.FrictionAxisVelocity;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleAxisVelocity;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.velocity.SimpleEntry;
|
||||
import fr.neatmonster.nocheatplus.checks.workaround.WRPT;
|
||||
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.BlockChangeEntry;
|
||||
import fr.neatmonster.nocheatplus.compat.blocks.BlockChangeTracker.BlockChangeReference;
|
||||
import fr.neatmonster.nocheatplus.components.data.ICanHandleTimeRunningBackwards;
|
||||
import fr.neatmonster.nocheatplus.components.entity.IEntityAccessDimensions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
|
||||
import fr.neatmonster.nocheatplus.utilities.RichBoundsLocation;
|
||||
@ -1069,20 +1069,20 @@ public class MovingData extends ACheckData {
|
||||
* @param player
|
||||
* @param loc
|
||||
* @param time
|
||||
* @param mcAccess
|
||||
* @param iead
|
||||
* If null getEyeHeight and 0.3 are used (assume fake player).
|
||||
* @return Updated LocationTrace instance, for convenient use, without
|
||||
* sticking too much to MovingData.
|
||||
*/
|
||||
public LocationTrace updateTrace(final Player player, final Location loc, final long time,
|
||||
final MCAccess mcAccess) {
|
||||
final IEntityAccessDimensions iead) {
|
||||
final LocationTrace trace = getTrace(player);
|
||||
if (mcAccess == null) {
|
||||
if (iead == null) {
|
||||
// TODO: 0.3 from bukkit based default heights (needs extra registered classes).
|
||||
trace.addEntry(time, loc.getX(), loc.getY(), loc.getZ(), 0.3, player.getEyeHeight());
|
||||
}
|
||||
else {
|
||||
trace.addEntry(time, loc.getX(), loc.getY(), loc.getZ(), mcAccess.getWidth(player) / 2.0, Math.max(player.getEyeHeight(), mcAccess.getHeight(player)));
|
||||
trace.addEntry(time, loc.getX(), loc.getY(), loc.getZ(), iead.getWidth(player) / 2.0, Math.max(player.getEyeHeight(), iead.getHeight(player)));
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
@ -1094,8 +1094,8 @@ public class MovingData extends ACheckData {
|
||||
* @param cc
|
||||
*/
|
||||
public void resetTrace(final Player player, final Location loc, final long time,
|
||||
final MCAccess mcAccess, final MovingConfig cc) {
|
||||
resetTrace(player, loc, time, cc.traceMaxAge, cc.traceMaxSize, mcAccess);
|
||||
final IEntityAccessDimensions iead, final MovingConfig cc) {
|
||||
resetTrace(player, loc, time, cc.traceMaxAge, cc.traceMaxSize, iead);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1106,12 +1106,12 @@ public class MovingData extends ACheckData {
|
||||
* @param traceMergeDist
|
||||
*/
|
||||
public void resetTrace(final Player player, final Location loc, final long time,
|
||||
final int maxAge, final int maxSize, final MCAccess mcAccess) {
|
||||
final int maxAge, final int maxSize, final IEntityAccessDimensions iead) {
|
||||
if (trace != null) {
|
||||
trace.reset();
|
||||
}
|
||||
getTrace(maxAge, maxSize).addEntry(time, loc.getX(), loc.getY(), loc.getZ(),
|
||||
mcAccess.getWidth(player) / 2.0, Math.max(player.getEyeHeight(), mcAccess.getHeight(player)));
|
||||
iead.getWidth(player) / 2.0, Math.max(player.getEyeHeight(), iead.getHeight(player)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.neatmonster.nocheatplus.components.entity.IEntityAccessDimensions;
|
||||
import fr.neatmonster.nocheatplus.components.map.IGetBlockCache;
|
||||
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
|
||||
@ -38,7 +39,7 @@ import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface MCAccess extends IGetBlockCache {
|
||||
public interface MCAccess extends IGetBlockCache, IEntityAccessDimensions {
|
||||
|
||||
/**
|
||||
* Simple version identifiers, if several must be separated by '|' like "1.4.2|1.4.4|1.4.5", to indicate multiple sub-versions supported use "1.5.x", use "?" to indicate general future support.
|
||||
@ -73,16 +74,10 @@ public interface MCAccess extends IGetBlockCache {
|
||||
*/
|
||||
public BlockCache getBlockCache(World world);
|
||||
|
||||
/**
|
||||
* Get height of an entity (attack relevant, the maximal "thing" found).
|
||||
*/
|
||||
@Override
|
||||
public double getHeight(Entity entity);
|
||||
|
||||
/**
|
||||
* Return some width (rather the full bounding box width).
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public double getWidth(Entity entity);
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,29 @@
|
||||
package fr.neatmonster.nocheatplus.components.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* Somehow access entity dimensions. (MCAccess extends this for now.)
|
||||
*
|
||||
* @author asofold
|
||||
*
|
||||
*/
|
||||
public interface IEntityAccessDimensions {
|
||||
|
||||
/**
|
||||
* Return some width (rather the full bounding box width).
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public double getWidth(Entity entity);
|
||||
|
||||
/**
|
||||
* Get height of an entity (attack relevant, the maximal "thing" found).
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public double getHeight(Entity entity);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user