Update dependencies, use more descriptive record
This commit is contained in:
3 files changed
+31
-10
No files matched your search
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.lishid.openinv.search.bucket;
|
||||
|
||||
import com.github.jikoo.planarwrappers.tuple.Pair;
|
||||
import com.lishid.openinv.search.match.MatchResult;
|
||||
import com.lishid.openinv.search.match.Matchable;
|
||||
import java.util.ArrayList;
|
||||
@@ -32,7 +31,7 @@ public class ChunkBucket implements SearchBucket {
|
||||
|
||||
private final World world;
|
||||
private final boolean load;
|
||||
private final List<Pair<Integer, Integer>> chunks;
|
||||
private final List<ChunkCoord> chunks;
|
||||
protected int index = -1;
|
||||
private Boolean paper = null;
|
||||
|
||||
@@ -41,27 +40,27 @@ public class ChunkBucket implements SearchBucket {
|
||||
this.load = load;
|
||||
this.chunks = new ArrayList<>();
|
||||
// Order chunks based (loosely) on proximity.
|
||||
spiralRectangle(radius, (deltaX, deltaZ) -> chunks.add(new Pair<>(chunkX + deltaX, chunkZ + deltaZ)));
|
||||
spiralRectangle(radius, (deltaX, deltaZ) -> chunks.add(new ChunkCoord(chunkX + deltaX, chunkZ + deltaZ)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Matchable next() throws IndexOutOfBoundsException {
|
||||
Pair<Integer, Integer> chunkCoords = chunks.get(++index);
|
||||
ChunkCoord chunkCoord = chunks.get(++index);
|
||||
|
||||
if (!world.isChunkGenerated(chunkCoords.getLeft(), chunkCoords.getRight())) {
|
||||
if (!world.isChunkGenerated(chunkCoord.x(), chunkCoord.z())) {
|
||||
return Matchable.EMPTY;
|
||||
}
|
||||
|
||||
if (!load && !world.isChunkLoaded(chunkCoords.getLeft(), chunkCoords.getRight())) {
|
||||
if (!load && !world.isChunkLoaded(chunkCoord.x(), chunkCoord.z())) {
|
||||
return Matchable.EMPTY;
|
||||
}
|
||||
|
||||
// If async chunk loading is not available, load chunk when checking.
|
||||
if (!isPaper()) {
|
||||
return new MatchableChunk(world, chunkCoords.getLeft(), chunkCoords.getRight());
|
||||
return new MatchableChunk(world, chunkCoord.x(), chunkCoord.z());
|
||||
}
|
||||
|
||||
CompletableFuture<Chunk> chunkAt = world.getChunkAtAsync(chunkCoords.getLeft(), chunkCoords.getRight());
|
||||
CompletableFuture<Chunk> chunkAt = world.getChunkAtAsync(chunkCoord.x(), chunkCoord.z());
|
||||
|
||||
Chunk chunk;
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2011-2021 lishid. All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.lishid.openinv.search.bucket;
|
||||
|
||||
/**
|
||||
* A data holder for chunk coordinates.
|
||||
*/
|
||||
public record ChunkCoord(int x, int z) {}
|
||||
@@ -77,7 +77,7 @@
|
||||
<artifactId>annotations</artifactId>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<scope>provided</scope>
|
||||
<version>21.0.1</version>
|
||||
<version>23.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>paper-api</artifactId>
|
||||
@@ -95,7 +95,7 @@
|
||||
<artifactId>planarwrappers</artifactId>
|
||||
<groupId>com.github.jikoo</groupId>
|
||||
<scope>compile</scope>
|
||||
<version>2.1.0</version>
|
||||
<version>2.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>openinvapi</artifactId>
|
||||
|
||||
Reference in new issue
Block a user