Skip to content

Commit

Permalink
More neutral naming (rather blockMove than push).
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Nov 25, 2016
1 parent 574390f commit c477f1a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
Expand Up @@ -196,7 +196,7 @@ public static MovingConfig getConfig(final String worldName) {
public final boolean assumeSprint;
public final int speedGrace;
public final boolean enforceLocation;
public final boolean blockChangeTrackerPush;
public final boolean trackBlockMove;

// Vehicles
public final boolean vehicleEnforceLocation;
Expand Down Expand Up @@ -331,7 +331,7 @@ public MovingConfig(final ConfigFile config) {
} else {
enforceLocation = ref.decide();
}
blockChangeTrackerPush = config.getBoolean(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_ACTIVE) && config.getBoolean(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_PISTONS);
trackBlockMove = config.getBoolean(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_ACTIVE) && config.getBoolean(ConfPaths.COMPATIBILITY_BLOCKS_CHANGETRACKER_PISTONS);

traceMaxAge = config.getInt(ConfPaths.MOVING_TRACE_MAXAGE, 200);
traceMaxSize = config.getInt(ConfPaths.MOVING_TRACE_MAXSIZE, 200);
Expand Down
Expand Up @@ -423,13 +423,13 @@ else if (thisMove.from.inLiquid) { // && (Math.abs(yDistance) > 0.2 || to.isInLi
}

// Post-check recovery.
if (vDistanceAboveLimit > 0.0 && Math.abs(yDistance) <= 1.015 && cc.blockChangeTrackerPush) {
// TODO: Better place for checking for push [redesign for intermediate result objects?].
if (vDistanceAboveLimit > 0.0 && Math.abs(yDistance) <= 1.015 && cc.trackBlockMove) {
// TODO: Better place for checking for moved blocks [redesign for intermediate result objects?].
// Vertical push/pull.
double[] pushResult = getPushResultVertical(yDistance, from, to, data);
if (pushResult != null) {
vAllowedDistance = pushResult[0];
vDistanceAboveLimit = pushResult[1];
double[] blockMoveResult = getBlockMoveResult(yDistance, from, to, data);
if (blockMoveResult != null) {
vAllowedDistance = blockMoveResult[0];
vDistanceAboveLimit = blockMoveResult[1];
}
}
// Push/pull sideways.
Expand Down Expand Up @@ -639,7 +639,7 @@ else if (resetFrom) {
* @param data
* @return
*/
private double[] getPushResultVertical(final double yDistance, final PlayerLocation from, final PlayerLocation to, final MovingData data) {
private double[] getBlockMoveResult(final double yDistance, final PlayerLocation from, final PlayerLocation to, final MovingData data) {
/*
* TODO: Once horizontal push is allowed too, a maxIdEntry has to be
* passed as argument and data.updateBlockChangeReference has to be
Expand All @@ -655,21 +655,21 @@ private double[] getPushResultVertical(final double yDistance, final PlayerLocat
// Extreme case: 1.51 blocks up (details pending).
|| yDistance <= 1.015 && to.getY() - to.getBlockY() < 0.015)) {
// TODO: Other conditions? [some will be in passable later].
final BlockChangeEntry entryYPos = from.getBlockChangeIdPush(blockChangeTracker, data.blockChangeRef, Direction.Y_POS, Math.min(yDistance, 1.0));
final BlockChangeEntry entryYPos = from.matchBlockChange(blockChangeTracker, data.blockChangeRef, Direction.Y_POS, Math.min(yDistance, 1.0));
if (entryYPos != null) {
data.updateBlockChangeReference(entryYPos, to);
tags.add("push_y_pos");
tags.add("blkmv_y_pos");
final double maxDistYPos = yDistance; //1.0 - (from.getY() - from.getBlockY()); // TODO: Margin ?
return new double[]{maxDistYPos, 0.0};
}
}
// Push (/pull) down.
else if (yDistance < 0.0 && yDistance >= -1.0) {
// TODO: Other conditions? [some will be in passable later].
final BlockChangeEntry entryYNeg = from.getBlockChangeIdPush(blockChangeTracker, data.blockChangeRef, Direction.Y_NEG, -yDistance);
final BlockChangeEntry entryYNeg = from.matchBlockChange(blockChangeTracker, data.blockChangeRef, Direction.Y_NEG, -yDistance);
if (entryYNeg != null) {
data.updateBlockChangeReference(entryYNeg, to);
tags.add("push_y_neg");
tags.add("blkmv_y_neg");
final double maxDistYNeg = yDistance; // from.getY() - from.getBlockY(); // TODO: Margin ?
return new double[]{maxDistYNeg, 0.0};
}
Expand Down
Expand Up @@ -1012,7 +1012,8 @@ public int ensureChunksLoaded(final double xzMargin) {
}

/**
* Check for push using the full bounding box (pistons). The given
* Check for tracked block changes, having moved a block into a certain
* direction, using the full bounding box (pistons). The given
* BlockChangeReference is not changed, it has to be updated externally.
*
* @param blockChangeTracker
Expand All @@ -1026,7 +1027,7 @@ public int ensureChunksLoaded(final double xzMargin) {
* @return A matching BlockChangeEntry with the minimal id. If no entry was
* found, null is returned.
*/
public BlockChangeEntry getBlockChangeIdPush(final BlockChangeTracker blockChangeTracker, final BlockChangeReference ref, final Direction direction, final double coverDistance) {
public BlockChangeEntry matchBlockChange(final BlockChangeTracker blockChangeTracker, final BlockChangeReference ref, final Direction direction, final double coverDistance) {
final int tick = TickTask.getTick();
final UUID worldId = world.getUID();
final int iMinX = Location.locToBlock(minX);
Expand Down Expand Up @@ -1070,7 +1071,7 @@ public boolean isBlockIntersecting(final int x, final int y, final int z) {
}

/**
* Test if a block fully pushed into that direction can push the player by
* Test if a block fully moved into that direction can move the player by
* coverDistance.
*
* @param x
Expand Down

0 comments on commit c477f1a

Please sign in to comment.