mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Merge pull request #1357 from jippi/fix-explore-cache
ExploreRegion: Fix encoding X and Z
This commit is contained in:
commit
41df0ea794
@ -10,7 +10,7 @@ public class ExploreRegion {
|
||||
int x;
|
||||
int z;
|
||||
|
||||
private final Map<Short, ExploreChunk> chunks = new HashMap<>();
|
||||
private final Map<Long, ExploreChunk> chunks = new HashMap<>();
|
||||
|
||||
public ExploreRegion(int x, int z) {
|
||||
this.x = x;
|
||||
@ -21,7 +21,7 @@ public class ExploreRegion {
|
||||
chunks.put(getPlace(x, z), chunk);
|
||||
}
|
||||
|
||||
public Map<Short, ExploreChunk> getChunks() {
|
||||
public Map<Long, ExploreChunk> getChunks() {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
@ -33,43 +33,23 @@ public class ExploreRegion {
|
||||
return getChunk(getPlace(chunk));
|
||||
}
|
||||
|
||||
public ExploreChunk getChunk(short place) {
|
||||
public ExploreChunk getChunk(long place) {
|
||||
return chunks.get(place);
|
||||
}
|
||||
|
||||
private static short getPlace(Chunk chunk) {
|
||||
private static long getPlace(Chunk chunk) {
|
||||
return getPlace(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
private static short getPlace(int x, int z) {
|
||||
return (short) ((x - ((x >> 5) * 32)) + ((z - ((z >> 5) * 32)) * 32));
|
||||
private static long getPlace(int x, int z) {
|
||||
return (((long) x) << 32) | (z & 0xffffffff);
|
||||
}
|
||||
|
||||
public int getChunkX(short place) {
|
||||
int endX = place % 32;
|
||||
|
||||
if (x < 0)
|
||||
endX = -endX;
|
||||
|
||||
endX = x * 32 + endX;
|
||||
|
||||
if (endX < 0) {
|
||||
endX += 32;
|
||||
public int getChunkX(long place) {
|
||||
return (int)(place >> 32);
|
||||
}
|
||||
|
||||
return endX;
|
||||
}
|
||||
|
||||
public int getChunkZ(short place) {
|
||||
int endZ = (place - (place % 32)) / 32;
|
||||
if (z < 0)
|
||||
endZ = -endZ;
|
||||
endZ = z * 32 + endZ;
|
||||
|
||||
if (endZ < 0) {
|
||||
endZ += 32;
|
||||
}
|
||||
|
||||
return endZ;
|
||||
public int getChunkZ(long place) {
|
||||
return (int) place;
|
||||
}
|
||||
}
|
||||
|
@ -2465,7 +2465,7 @@ public abstract class JobsDAO {
|
||||
|
||||
int id = jobsWorld == null ? 0 : jobsWorld.getId();
|
||||
if (id != 0)
|
||||
for (Entry<Short, ExploreChunk> oneChunk : region.getValue().getChunks().entrySet()) {
|
||||
for (Entry<Long, ExploreChunk> oneChunk : region.getValue().getChunks().entrySet()) {
|
||||
ExploreChunk chunk = oneChunk.getValue();
|
||||
if (chunk.getDbId() != -1)
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user