]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/client/providers/CustomLineProvider.java
Tidy up constructors on simple boxes
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / providers / CustomLineProvider.java
index d7c96c04e6c5cb35d0d614193d2b40e2feb993ac..5bcbdc30d2892eee6fad06640759693b6343c0ef 100644 (file)
@@ -4,31 +4,32 @@ import com.irtimaled.bbor.client.Player;
 import com.irtimaled.bbor.client.models.BoundingBoxLine;
 import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.models.DimensionId;
 
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class CustomLineProvider implements IBoundingBoxProvider<BoundingBoxLine> {
-    private static final Map<Integer, Map<Integer, BoundingBoxLine>> dimensionCache = new HashMap<>();
+    private static final Map<DimensionId, Map<Integer, BoundingBoxLine>> dimensionCache = new HashMap<>();
 
     private static int getHashKey(Point minPoint, Point maxPoint) {
         return (31 + minPoint.hashCode()) * 31 + maxPoint.hashCode();
     }
 
-    private static Map<Integer, BoundingBoxLine> getCache(int dimensionId) {
+    private static Map<Integer, BoundingBoxLine> getCache(DimensionId dimensionId) {
         return dimensionCache.computeIfAbsent(dimensionId, i -> new ConcurrentHashMap<>());
     }
 
     public static void add(Point minPoint, Point maxPoint, Double width) {
-        int dimensionId = Player.getDimensionId();
+        DimensionId dimensionId = Player.getDimensionId();
         int cacheKey = getHashKey(minPoint, maxPoint);
         BoundingBoxLine line = BoundingBoxLine.from(minPoint, maxPoint, width, BoundingBoxType.Custom);
         getCache(dimensionId).put(cacheKey, line);
     }
 
     public static boolean remove(Point min, Point max) {
-        int dimensionId = Player.getDimensionId();
+        DimensionId dimensionId = Player.getDimensionId();
         int cacheKey = getHashKey(min, max);
         return getCache(dimensionId).remove(cacheKey) != null;
     }
@@ -38,7 +39,7 @@ public class CustomLineProvider implements IBoundingBoxProvider<BoundingBoxLine>
     }
 
     @Override
-    public Iterable<BoundingBoxLine> get(int dimensionId) {
+    public Iterable<BoundingBoxLine> get(DimensionId dimensionId) {
         return getCache(dimensionId).values();
     }
 }