mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-06-26 06:14:42 +02:00
[BLEEDING] Evolution has made pigs both wider and reach down farther.
This commit is contained in:
parent
6ff2578653
commit
b35805adc8
|
@ -22,13 +22,29 @@ import fr.neatmonster.nocheatplus.utilities.RichEntityLocation;
|
|||
|
||||
public class VehicleMoveInfo extends MoveInfo<RichEntityLocation, Entity> {
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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.<br>
|
||||
* Minimal optimizations: take block flags directly, on-ground max/min bounds, only set stairs if not on ground and not reset-condition.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user