Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
Pass through wall improvements
This change simplifies the algorithm greatly. Additionally, this fixes a bug where if standing in a non-solid block i.e. a glass pane, //thru, and the nav wand would not work.
Dieser Commit ist enthalten in:
Ursprung
a9b3fb1429
Commit
917f8a1842
@ -394,51 +394,62 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canPassThroughBlock(Location curBlock) {
|
||||||
|
BlockVector3 blockPos = curBlock.toVector().toBlockPoint();
|
||||||
|
BlockState block = curBlock.getExtent().getBlock(blockPos);
|
||||||
|
return !block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's view yaw.
|
* Advances the block target block until the current block is a wall
|
||||||
*
|
* @return true if a wall is found
|
||||||
* @return yaw
|
|
||||||
*/
|
*/
|
||||||
|
private boolean advanceToWall(TargetBlock hitBlox) {
|
||||||
@Override
|
Location curBlock;
|
||||||
public boolean passThroughForwardWall(int range) {
|
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
|
||||||
int searchDist = 0;
|
if (!canPassThroughBlock(curBlock)) {
|
||||||
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
|
|
||||||
Extent world = getLocation().getExtent();
|
|
||||||
Location block;
|
|
||||||
boolean firstBlock = true;
|
|
||||||
int freeToFind = 2;
|
|
||||||
boolean inFree = false;
|
|
||||||
|
|
||||||
while ((block = hitBlox.getNextBlock()) != null) {
|
|
||||||
boolean free = !world.getBlock(block.toVector().toBlockPoint()).getBlockType().getMaterial().isMovementBlocker();
|
|
||||||
|
|
||||||
if (firstBlock) {
|
|
||||||
firstBlock = false;
|
|
||||||
|
|
||||||
if (!free) {
|
|
||||||
--freeToFind;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++searchDist;
|
|
||||||
if (searchDist > 20) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inFree != free) {
|
|
||||||
if (free) {
|
|
||||||
--freeToFind;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeToFind == 0) {
|
|
||||||
setOnGround(block);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inFree = free;
|
hitBlox.getNextBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advances the block target block until the current block is a free
|
||||||
|
* @return true if a free spot is found
|
||||||
|
*/
|
||||||
|
private boolean advanceToFree(TargetBlock hitBlox) {
|
||||||
|
Location curBlock;
|
||||||
|
while ((curBlock = hitBlox.getCurrentBlock()) != null) {
|
||||||
|
if (canPassThroughBlock(curBlock)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
hitBlox.getNextBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean passThroughForwardWall(int range) {
|
||||||
|
TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
|
||||||
|
|
||||||
|
if (!advanceToWall(hitBlox)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!advanceToFree(hitBlox)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location foundBlock = hitBlox.getCurrentBlock();
|
||||||
|
if (foundBlock != null) {
|
||||||
|
setOnGround(foundBlock);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren