package com.irtimaled.bbor.client.providers;
-import com.irtimaled.bbor.client.PlayerCoords;
+import com.irtimaled.bbor.client.Player;
import com.irtimaled.bbor.common.BoundingBoxType;
import com.irtimaled.bbor.common.Dimensions;
import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
import java.util.concurrent.ConcurrentHashMap;
public class CustomBoxProvider implements IBoundingBoxProvider<BoundingBoxCuboid> {
- private static Map<Integer, Map<Integer, BoundingBoxCuboid>> dimensionCache = buildDimensionCache();
+ private static final Map<Integer, Map<Integer, BoundingBoxCuboid>> dimensionCache = buildDimensionCache();
private static Map<Integer, Map<Integer, BoundingBoxCuboid>> buildDimensionCache() {
Map<Integer, Map<Integer, BoundingBoxCuboid>> map = new HashMap<>();
}
public static void add(Coords minCoords, Coords maxCoords) {
- int dimensionId = PlayerCoords.getDimensionId();
+ int dimensionId = Player.getDimensionId();
int cacheKey = getHashKey(minCoords, maxCoords);
BoundingBoxCuboid cuboid = BoundingBoxCuboid.from(minCoords, maxCoords, BoundingBoxType.Custom);
getCache(dimensionId).put(cacheKey, cuboid);
}
- public static void remove(Coords minCoords, Coords maxCoords) {
- int dimensionId = PlayerCoords.getDimensionId();
+ public static boolean remove(Coords minCoords, Coords maxCoords) {
+ int dimensionId = Player.getDimensionId();
int cacheKey = getHashKey(minCoords, maxCoords);
- getCache(dimensionId).remove(cacheKey);
+ return getCache(dimensionId).remove(cacheKey) != null;
}
public static void clear() {