Initial gazechecking. Seems to work very well when objects are 100% covered. Needs some more testing but first blush is 100x improvement for proximity hiding
parent
587e02713c
commit
07634a58cf
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>orebfuscator</artifactId>
|
||||
<version>4.3.0-SNAPSHOT</version>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Orebfuscator4</name>
|
||||
|
@ -130,8 +130,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -31,6 +31,7 @@ public class ProximityHiderConfig {
|
|||
private Integer y;
|
||||
private Boolean useSpecialBlock;
|
||||
private Boolean obfuscateAboveY;
|
||||
private Boolean useFastGazeCheck;
|
||||
private Integer[] proximityHiderBlockIds;
|
||||
private BlockSetting[] proximityHiderBlockSettings;
|
||||
private int[] proximityHiderBlockMatrix;
|
||||
|
@ -43,6 +44,7 @@ public class ProximityHiderConfig {
|
|||
this.y = 255;
|
||||
this.useSpecialBlock = true;
|
||||
this.obfuscateAboveY = false;
|
||||
this.useFastGazeCheck = false;
|
||||
this.proximityHiderBlockIds = defaultProximityHiderBlockIds;
|
||||
}
|
||||
|
||||
|
@ -80,6 +82,10 @@ public class ProximityHiderConfig {
|
|||
this.proximityHiderBlockSettings = baseCfg.proximityHiderBlockSettings.clone();
|
||||
}
|
||||
|
||||
if (this.useFastGazeCheck == null) {
|
||||
this.useFastGazeCheck = baseCfg.useFastGazeCheck;
|
||||
}
|
||||
|
||||
setProximityHiderBlockMatrix();
|
||||
}
|
||||
|
||||
|
@ -171,6 +177,14 @@ public class ProximityHiderConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isUseFastGazeCheck() {
|
||||
return this.useFastGazeCheck;
|
||||
}
|
||||
|
||||
public void setUseFastGazeCheck(Boolean value) {
|
||||
this.useFastGazeCheck = value;
|
||||
}
|
||||
|
||||
// Help methods
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ public class WorldReader {
|
|||
Boolean useYLocationProximity = getBoolean(sectionPath + ".ObfuscateAboveY", cfg.isObfuscateAboveY(), withSave);
|
||||
Integer[] proximityHiderBlockIds = this.materialReader.getMaterialIdsByPath(sectionPath + ".ProximityHiderBlocks", cfg.getProximityHiderBlockIds(), withSave);
|
||||
ProximityHiderConfig.BlockSetting[] proximityHiderBlockSettings = readProximityHiderBlockSettings(sectionPath + ".ProximityHiderBlockSettings", cfg.getProximityHiderBlockSettings());
|
||||
Boolean useFastGazeCheck = getBoolean(sectionPath + ".UseFastGazeCheck", cfg.isUseFastGazeCheck(), withSave);
|
||||
|
||||
cfg.setEnabled(enabled);
|
||||
cfg.setDistance(distance);
|
||||
|
@ -237,6 +238,7 @@ public class WorldReader {
|
|||
cfg.setObfuscateAboveY(useYLocationProximity);
|
||||
cfg.setProximityHiderBlockIds(proximityHiderBlockIds);
|
||||
cfg.setProximityHiderBlockSettings(proximityHiderBlockSettings);
|
||||
cfg.setUseFastGazeCheck(useFastGazeCheck);
|
||||
}
|
||||
|
||||
private ProximityHiderConfig.BlockSetting[] readProximityHiderBlockSettings(
|
||||
|
|
|
@ -145,6 +145,9 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
|
||||
ArrayList<BlockCoord> removedBlocks = new ArrayList<BlockCoord>();
|
||||
Location playerLocation = p.getLocation();
|
||||
// 4.3.1 -- GAZE CHECK
|
||||
Location playerEyes = p.getEyeLocation();
|
||||
// 4.3.1 -- GAZE CHECK END
|
||||
int minChunkX = (playerLocation.getBlockX() >> 4) - checkRadius;
|
||||
int maxChunkX = minChunkX + (checkRadius << 1);
|
||||
int minChunkZ = (playerLocation.getBlockZ() >> 4) - checkRadius;
|
||||
|
@ -167,19 +170,23 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
Location blockLocation = new Location(localPlayerInfo.getWorld(), b.x, b.y, b.z);
|
||||
|
||||
if (proximityHider.isObfuscateAboveY() || playerLocation.distanceSquared(blockLocation) < distanceSquared) {
|
||||
removedBlocks.add(b);
|
||||
|
||||
BlockState blockState = Orebfuscator.nms.getBlockState(localPlayerInfo.getWorld(), b.x, b.y, b.z);
|
||||
|
||||
if (blockState != null) {
|
||||
DeprecatedMethods.sendBlockChange(p, blockLocation, blockState);
|
||||
final BlockCoord block = b;
|
||||
final Player player = p;
|
||||
Orebfuscator.instance.runTask(new Runnable() {
|
||||
public void run() {
|
||||
Orebfuscator.nms.updateBlockTileEntity(block, player);
|
||||
}
|
||||
});
|
||||
// 4.3.1 -- GAZE CHECK
|
||||
if (!proximityHider.isUseFastGazeCheck() || doFastCheck(blockLocation, playerEyes, localPlayerInfo.getWorld())) {
|
||||
// 4.3.1 -- GAZE CHECK END
|
||||
removedBlocks.add(b);
|
||||
|
||||
BlockState blockState = Orebfuscator.nms.getBlockState(localPlayerInfo.getWorld(), b.x, b.y, b.z);
|
||||
|
||||
if (blockState != null) {
|
||||
DeprecatedMethods.sendBlockChange(p, blockLocation, blockState);
|
||||
final BlockCoord block = b;
|
||||
final Player player = p;
|
||||
Orebfuscator.instance.runTask(new Runnable() {
|
||||
public void run() {
|
||||
Orebfuscator.nms.updateBlockTileEntity(block, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +206,70 @@ public class ProximityHider extends Thread implements Runnable {
|
|||
|
||||
running = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic idea here is to take some rays from the considered block to the player's eyes, and decide if
|
||||
* any of those rays can reach the eyes unimpeded.
|
||||
*
|
||||
* @param block the starting block
|
||||
* @param eyes the destination eyes
|
||||
* @param player the player world we are testing for
|
||||
* @return true if unimpeded path, false otherwise
|
||||
*/
|
||||
private boolean doFastCheck(Location block, Location eyes, World player) {
|
||||
double ex = eyes.getX();
|
||||
double ey = eyes.getY();
|
||||
double ez = eyes.getZ();
|
||||
double x = block.getBlockX();
|
||||
double y = block.getBlockY();
|
||||
double z = block.getBlockZ();
|
||||
return // midfaces
|
||||
fastAABBRayCheck(x, y, z, x , y+0.5, z+0.5, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+0.5, y , z+0.5, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+0.5, y+0.5, z , ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+0.5, y+1.0, z+0.5, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+0.5, y+0.5, z+1.0, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+1.0, y+0.5, z+0.5, ex, ey, ez, player) ||
|
||||
// corners
|
||||
fastAABBRayCheck(x, y, z, x , y , z , ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+1, y , z , ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x , y+1, z , ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+1, y+1, z , ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x , y , z+1, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+1, y , z+1, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x , y+1, z+1, ex, ey, ez, player) ||
|
||||
fastAABBRayCheck(x, y, z, x+1, y+1, z+1, ex, ey, ez, player);
|
||||
}
|
||||
|
||||
private boolean fastAABBRayCheck(double bx, double by, double bz, double x, double y, double z, double ex, double ey, double ez, World world) {
|
||||
double fx = Math.abs(ex-x);
|
||||
double fy = Math.abs(ey-y);
|
||||
double fz = Math.abs(ez-z);
|
||||
double s = Math.max(fx, Math.max(fy, fz));
|
||||
if (s < 1) return true; // on top / inside
|
||||
|
||||
double lx, ly, lz;
|
||||
|
||||
fx = fx / s; // units of change along vector
|
||||
fy = fy / s;
|
||||
fz = fz / s;
|
||||
|
||||
while (s > 0) {
|
||||
ex -= fx; // move along vector, we start _at_ the eye and move towards b
|
||||
ey -= fy;
|
||||
ez -= fz;
|
||||
lx = Math.floor(ex);
|
||||
ly = Math.floor(ey);
|
||||
lz = Math.floor(ez);
|
||||
if (lx == bx && ly == by && lz == bz) return true; // we've reached our starting block, don't test it.
|
||||
int between = Orebfuscator.nms.getBlockId(world, (int) lx, (int) ly, (int) lz);
|
||||
if (between > 0 && !Orebfuscator.config.isBlockTransparent(between)) { // -1 is null, 0 is air, above that? check with config.
|
||||
return false; // fail on first hit, this ray is "blocked"
|
||||
}
|
||||
s--; // we stop
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void restart() {
|
||||
synchronized (thread) {
|
||||
|
|
Loading…
Reference in New Issue