diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java index 4f8bfe5e..4060c46f 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java @@ -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))); } /** diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java index d195f5dd..7924d8d8 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java @@ -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); /** diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/entity/IEntityAccessDimensions.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/entity/IEntityAccessDimensions.java new file mode 100644 index 00000000..b6c49ec3 --- /dev/null +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/components/entity/IEntityAccessDimensions.java @@ -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); + +}