DataStore#getChunkHash is publicly accessible (#943)

This commit is contained in:
Frank van der Heijden 2020-08-06 17:27:24 +02:00 committed by GitHub
parent 40ca1d756e
commit ee1a5c567b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 17 deletions

View File

@ -976,20 +976,6 @@ public class Claim
ArrayList<Long> getChunkHashes()
{
ArrayList<Long> hashes = new ArrayList<Long>();
int smallX = this.getLesserBoundaryCorner().getBlockX() >> 4;
int smallZ = this.getLesserBoundaryCorner().getBlockZ() >> 4;
int largeX = this.getGreaterBoundaryCorner().getBlockX() >> 4;
int largeZ = this.getGreaterBoundaryCorner().getBlockZ() >> 4;
for (int x = smallX; x <= largeX; x++)
{
for (int z = smallZ; z <= largeZ; z++)
{
hashes.add(DataStore.getChunkHash(x, z));
}
}
return hashes;
return DataStore.getChunkHashes(this);
}
}

View File

@ -785,17 +785,39 @@ public abstract class DataStore
}
//gets an almost-unique, persistent identifier for a chunk
static Long getChunkHash(long chunkx, long chunkz)
public static Long getChunkHash(long chunkx, long chunkz)
{
return (chunkz ^ (chunkx << 32));
}
//gets an almost-unique, persistent identifier for a chunk
static Long getChunkHash(Location location)
public static Long getChunkHash(Location location)
{
return getChunkHash(location.getBlockX() >> 4, location.getBlockZ() >> 4);
}
public static ArrayList<Long> getChunkHashes(Claim claim) {
return getChunkHashes(claim.getLesserBoundaryCorner(), claim.getGreaterBoundaryCorner());
}
public static ArrayList<Long> getChunkHashes(Location min, Location max) {
ArrayList<Long> hashes = new ArrayList<>();
int smallX = min.getBlockX() >> 4;
int smallZ = min.getBlockZ() >> 4;
int largeX = max.getBlockX() >> 4;
int largeZ = max.getBlockZ() >> 4;
for (int x = smallX; x <= largeX; x++)
{
for (int z = smallZ; z <= largeZ; z++)
{
hashes.add(getChunkHash(x, z));
}
}
return hashes;
}
/*
* Creates a claim and flags it as being new....throwing a create claim event;
*/