diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/VehicleMoveInfo.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/VehicleMoveInfo.java index 7944fb0e..a1d546fb 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/VehicleMoveInfo.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/VehicleMoveInfo.java @@ -22,13 +22,29 @@ import fr.neatmonster.nocheatplus.utilities.RichEntityLocation; public class VehicleMoveInfo extends MoveInfo { + /** Add to fullWidth for the bounding box. */ + private double extendFullWidth = 0.0; + public VehicleMoveInfo(final MCAccess mcAccess){ super(mcAccess, new RichEntityLocation(mcAccess, null), new RichEntityLocation(mcAccess, null)); } @Override - protected void set(RichEntityLocation rLoc, Location loc, Entity entity, double yOnGround) { - rLoc.set(loc, entity, yOnGround); + protected void set(final RichEntityLocation rLoc, final Location loc, final Entity entity, final double yOnGround) { + if (getExtendFullWidth() > 0.0) { + final MCAccess mcAccess = from.getMCAccess(); + rLoc.set(loc, entity, mcAccess.getWidth(entity) + getExtendFullWidth(), mcAccess.getHeight(entity), yOnGround); + } else { + rLoc.set(loc, entity, yOnGround); + } + } + + public double getExtendFullWidth() { + return extendFullWidth; + } + + public void setExtendFullWidth(double extendFullWidth) { + this.extendFullWidth = extendFullWidth; } } diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleChecks.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleChecks.java index 6f36b228..116ff200 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleChecks.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleChecks.java @@ -357,7 +357,15 @@ public class VehicleChecks extends CheckListener { final Location useFrom = LocUtil.set(useLoc1, world, firstPastMove.toIsValid ? firstPastMove.to : firstPastMove.from); final Location useTo = vehicleLocation; // Initialize moveInfo. - moveInfo.set(vehicle, useFrom, useTo, cc.yOnGround); + if (vehicleType == EntityType.PIG) { + // TODO: Special cases by config rather. + // TODO: Likely will fail with passable. + moveInfo.setExtendFullWidth(0.52); + } + // TODO: Test yOnGround at 0.13 instead of xz-margin + moveInfo.set(vehicle, useFrom, useTo, + vehicleType == EntityType.PIG ? Math.max(0.13, cc.yOnGround) : cc.yOnGround); // TODO: Extra config. + moveInfo.setExtendFullWidth(0.0); // TODO: Check consistency for given/set and log debug/warnings if necessary (to = vehicleLocation? from = firstPastMove). // Check coordinates, just in case. if (checkIllegal(moveInfo.from, moveInfo.to)) { diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java index c50ec792..5100a80c 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/vehicle/VehicleEnvelope.java @@ -307,10 +307,12 @@ public class VehicleEnvelope extends Check { } } else if (vehicle instanceof Horse) { + // TODO: Climbable? checkDetails.simplifiedType = EntityType.HORSE; checkDetails.canJump = checkDetails.canStepUpBlock = true; } else if (vehicle instanceof Pig) { + // TODO: Climbable! checkDetails.simplifiedType = EntityType.PIG; checkDetails.canJump = false; checkDetails.canStepUpBlock = true; 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 7f57f1a6..955c341c 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/MCAccess.java @@ -66,7 +66,7 @@ public interface MCAccess { public double getHeight(Entity entity); /** - * Return some width. + * Return some width (rather the full bounding box width). * @param entity * @return */ diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index d557b436..16d081d6 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -114,6 +114,14 @@ public class PlayerLocation extends RichEntityLocation { throw new UnsupportedOperationException("Set must specify an instance of Player."); } + /** + * Not supported. + */ + @Override + public void set(Location location, Entity entity, double fullWidth, double fullHeight, double yOnGround) { + throw new UnsupportedOperationException("Set must specify an instance of Player."); + } + /** * Set cached info according to other.
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition. diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/RichEntityLocation.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/RichEntityLocation.java index 4c266eba..b9f7578b 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/RichEntityLocation.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/RichEntityLocation.java @@ -234,7 +234,7 @@ public class RichEntityLocation extends RichBoundsLocation { * @param yOnGround */ public void set(final Location location, final Entity entity, final double yOnGround) { - doSet(location, entity, mcAccess.getHeight(entity), yOnGround); + doSet(location, entity, mcAccess.getWidth(entity), mcAccess.getHeight(entity), yOnGround); } /** @@ -247,10 +247,25 @@ public class RichEntityLocation extends RichBoundsLocation { * @param yOnGround */ public void set(final Location location, final Entity entity, double fullHeight, final double yOnGround) { - doSet(location, entity, fullHeight, yOnGround); + doSet(location, entity, mcAccess.getWidth(entity), fullHeight, yOnGround); } - protected void doSet(final Location location, final Entity entity, double fullHeight, final double yOnGround) { + /** + * + * @param location + * @param entity + * @param fullWidth + * Override the bounding box width (full width). + * @param fullHeight + * Allows to specify eyeHeight here. Currently might be + * overridden by eyeHeight, if that is greater. + * @param yOnGround + */ + public void set(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) { + doSet(location, entity, fullWidth, fullHeight, yOnGround); + } + + protected void doSet(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) { if (entity instanceof LivingEntity) { isLiving = true; eyeHeight = ((LivingEntity) entity).getEyeHeight(); @@ -260,11 +275,11 @@ public class RichEntityLocation extends RichBoundsLocation { isLiving = false; eyeHeight = fullHeight; } - super.set(location, mcAccess.getWidth(entity), fullHeight, yOnGround); this.entity = entity; this.width = mcAccess.getWidth(entity); this.height = mcAccess.getHeight(entity); standsOnEntity = false; + super.set(location, fullWidth, fullHeight, yOnGround); } /**