]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Rename abstract base classes
authorIrtimaled <irtimaled@gmail.com>
Sun, 24 Mar 2019 06:53:11 +0000 (23:53 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 25 Mar 2019 03:56:28 +0000 (20:56 -0700)
32 files changed:
src/main/java/com/irtimaled/bbor/client/ClientRenderer.java
src/main/java/com/irtimaled/bbor/client/NBTFileParser.java
src/main/java/com/irtimaled/bbor/client/events/AddBoundingBoxReceived.java
src/main/java/com/irtimaled/bbor/client/events/RemoveBoundingBoxReceived.java
src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/renderers/MobSpawnerRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java [deleted file]
src/main/java/com/irtimaled/bbor/client/renderers/SlimeChunkRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/StructureRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/VillageRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/WorldSpawnRenderer.java
src/main/java/com/irtimaled/bbor/common/BoundingBoxCache.java
src/main/java/com/irtimaled/bbor/common/CommonProxy.java
src/main/java/com/irtimaled/bbor/common/chunkProcessors/AbstractChunkProcessor.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/common/chunkProcessors/ChunkProcessor.java [deleted file]
src/main/java/com/irtimaled/bbor/common/chunkProcessors/EndChunkProcessor.java
src/main/java/com/irtimaled/bbor/common/chunkProcessors/NetherChunkProcessor.java
src/main/java/com/irtimaled/bbor/common/chunkProcessors/OverworldChunkProcessor.java
src/main/java/com/irtimaled/bbor/common/messages/AddBoundingBox.java
src/main/java/com/irtimaled/bbor/common/messages/BoundingBoxDeserializer.java
src/main/java/com/irtimaled/bbor/common/messages/BoundingBoxSerializer.java
src/main/java/com/irtimaled/bbor/common/messages/RemoveBoundingBox.java
src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/common/models/BoundingBox.java [deleted file]
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxMobSpawner.java
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxSlimeChunk.java
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxStructure.java
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxVillage.java
src/main/java/com/irtimaled/bbor/common/models/BoundingBoxWorldSpawn.java
src/main/java/com/irtimaled/bbor/config/AbstractSetting.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/config/Setting.java
src/main/java/com/irtimaled/bbor/config/SettingBase.java [deleted file]

index a828369d57826b0efab76a66181add6610c9300e..bfe2571175c5ba61ba798cab24a92765cddfedf7 100644 (file)
@@ -14,11 +14,11 @@ import java.util.*;
 
 public class ClientRenderer {
     private static final int CHUNK_SIZE = 16;
-    private static final Map<Class<? extends BoundingBox>, Renderer> boundingBoxRendererMap = new HashMap<>();
+    private static final Map<Class<? extends AbstractBoundingBox>, AbstractRenderer> boundingBoxRendererMap = new HashMap<>();
 
     private final GetCache getCache;
     private long seed;
-    private Set<BoundingBox> spawnChunkBoundingBoxes = new HashSet<>();
+    private Set<AbstractBoundingBox> spawnChunkBoundingBoxes = new HashSet<>();
 
     ClientRenderer(GetCache getCache) {
         this.getCache = getCache;
@@ -29,7 +29,7 @@ public class ClientRenderer {
         boundingBoxRendererMap.put(BoundingBoxMobSpawner.class, new MobSpawnerRenderer());
     }
 
-    private boolean isWithinRenderDistance(BoundingBox boundingBox) {
+    private boolean isWithinRenderDistance(AbstractBoundingBox boundingBox) {
         Coords minCoords = boundingBox.getMinCoords();
         Coords maxCoords = boundingBox.getMaxCoords();
         int renderDistanceBlocks = getRenderDistanceChunks() * CHUNK_SIZE;
@@ -45,7 +45,7 @@ public class ClientRenderer {
     }
 
     public void render(int dimensionId, Boolean outerBoxesOnly) {
-        Map<BoundingBox, Set<BoundingBox>> boundingBoxes = getBoundingBoxes(dimensionId);
+        Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxes = getBoundingBoxes(dimensionId);
 
         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
         GL11.glLineWidth(2.0f);
@@ -55,15 +55,15 @@ public class ClientRenderer {
         if (ConfigManager.alwaysVisible.get()) {
             GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
         }
-        for (Map.Entry<BoundingBox, Set<BoundingBox>> entry : boundingBoxes.entrySet()) {
-            BoundingBox key = entry.getKey();
+        for (Map.Entry<AbstractBoundingBox, Set<AbstractBoundingBox>> entry : boundingBoxes.entrySet()) {
+            AbstractBoundingBox key = entry.getKey();
             if (!key.shouldRender()) continue;
 
-            Renderer renderer = boundingBoxRendererMap.get(key.getClass());
+            AbstractRenderer renderer = boundingBoxRendererMap.get(key.getClass());
             if (renderer == null) continue;
 
             if (!outerBoxesOnly) {
-                Set<BoundingBox> children = entry.getValue();
+                Set<AbstractBoundingBox> children = entry.getValue();
                 if (children != null) {
                     children.forEach(renderer::render);
                     continue;
@@ -77,14 +77,14 @@ public class ClientRenderer {
         GL11.glEnable(GL11.GL_TEXTURE_2D);
     }
 
-    private Map<BoundingBox, Set<BoundingBox>> getBoundingBoxes(int dimensionId) {
-        Map<BoundingBox, Set<BoundingBox>> boundingBoxes = new HashMap<>();
+    private Map<AbstractBoundingBox, Set<AbstractBoundingBox>> getBoundingBoxes(int dimensionId) {
+        Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxes = new HashMap<>();
         if (dimensionId == Dimensions.OVERWORLD) {
             if (BoundingBoxType.SlimeChunks.shouldRender()) {
                 addSlimeChunks(boundingBoxes);
             }
 
-            for (BoundingBox boundingBox : spawnChunkBoundingBoxes) {
+            for (AbstractBoundingBox boundingBox : spawnChunkBoundingBoxes) {
                 if (boundingBox.shouldRender() && isWithinRenderDistance(boundingBox)) {
                     boundingBoxes.put(boundingBox, null);
                 }
@@ -93,8 +93,8 @@ public class ClientRenderer {
 
         BoundingBoxCache cache = getCache.apply(dimensionId);
         if (cache != null) {
-            for (Map.Entry<BoundingBox, Set<BoundingBox>> entry : cache.getBoundingBoxes().entrySet()) {
-                BoundingBox key = entry.getKey();
+            for (Map.Entry<AbstractBoundingBox, Set<AbstractBoundingBox>> entry : cache.getBoundingBoxes().entrySet()) {
+                AbstractBoundingBox key = entry.getKey();
                 if (key.shouldRender() && isWithinRenderDistance(key)) {
                     boundingBoxes.put(key, entry.getValue());
                 }
@@ -103,7 +103,7 @@ public class ClientRenderer {
         return boundingBoxes;
     }
 
-    private void addSlimeChunks(Map<BoundingBox, Set<BoundingBox>> boundingBoxes) {
+    private void addSlimeChunks(Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxes) {
         int renderDistanceChunks = getRenderDistanceChunks();
         int playerChunkX = MathHelper.floor(PlayerCoords.getX() / 16.0D);
         int playerChunkZ = MathHelper.floor(PlayerCoords.getZ() / 16.0D);
@@ -138,22 +138,22 @@ public class ClientRenderer {
         spawnChunkBoundingBoxes = getSpawnChunkBoundingBoxes(spawnX, spawnZ);
     }
 
-    private Set<BoundingBox> getSpawnChunkBoundingBoxes(int spawnX, int spawnZ) {
-        Set<BoundingBox> boundingBoxes = new HashSet<>();
+    private Set<AbstractBoundingBox> getSpawnChunkBoundingBoxes(int spawnX, int spawnZ) {
+        Set<AbstractBoundingBox> boundingBoxes = new HashSet<>();
         boundingBoxes.add(getWorldSpawnBoundingBox(spawnX, spawnZ));
         boundingBoxes.add(buildSpawnChunksBoundingBox(spawnX, spawnZ, 12, BoundingBoxType.SpawnChunks));
         boundingBoxes.add(buildSpawnChunksBoundingBox(spawnX, spawnZ, 16, BoundingBoxType.LazySpawnChunks));
         return boundingBoxes;
     }
 
-    private BoundingBox getWorldSpawnBoundingBox(int spawnX, int spawnZ) {
+    private AbstractBoundingBox getWorldSpawnBoundingBox(int spawnX, int spawnZ) {
         Coords minCoords = new Coords(spawnX - 10, 0, spawnZ - 10);
         Coords maxCoords = new Coords(spawnX + 10, 0, spawnZ + 10);
 
         return BoundingBoxWorldSpawn.from(minCoords, maxCoords, BoundingBoxType.WorldSpawn);
     }
 
-    private BoundingBox buildSpawnChunksBoundingBox(int spawnX, int spawnZ, int size, BoundingBoxType type) {
+    private AbstractBoundingBox buildSpawnChunksBoundingBox(int spawnX, int spawnZ, int size, BoundingBoxType type) {
         double midOffset = CHUNK_SIZE * (size / 2.0);
         double midX = Math.round((float) (spawnX / (double) CHUNK_SIZE)) * (double) CHUNK_SIZE;
         double midZ = Math.round((float) (spawnZ / (double) CHUNK_SIZE)) * (double) CHUNK_SIZE;
index 8b4803c4eb69277bf4d8c153c2de814c0befe45d..88cf7340daccc048f2defb12f2c581c55b77c9da 100644 (file)
@@ -4,7 +4,7 @@ import com.irtimaled.bbor.Logger;
 import com.irtimaled.bbor.common.BoundingBoxCache;
 import com.irtimaled.bbor.common.BoundingBoxType;
 import com.irtimaled.bbor.common.Dimensions;
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 import com.irtimaled.bbor.common.models.BoundingBoxStructure;
 import com.irtimaled.bbor.common.models.BoundingBoxVillage;
 import com.irtimaled.bbor.common.models.Coords;
@@ -95,8 +95,8 @@ class NBTFileParser {
         int loadedStructureCount = 0;
         for (Object key : features.getKeySet()) {
             NBTTagCompound feature = features.getCompoundTag((String) key);
-            BoundingBox structure = buildStructure(feature, type);
-            Set<BoundingBox> boundingBoxes = new HashSet<>();
+            AbstractBoundingBox structure = buildStructure(feature, type);
+            Set<AbstractBoundingBox> boundingBoxes = new HashSet<>();
             NBTTagCompound[] children = getChildCompoundTags(feature, "Children");
             for (NBTTagCompound child : children) {
                 if (id.equals(child.getString("id")) || id.equals("*"))
@@ -129,7 +129,7 @@ class NBTFileParser {
             int radius = village.getInteger("Radius");
             int population = village.getInteger("PopSize");
             Set<Coords> doors = getDoors(village);
-            BoundingBox boundingBox = BoundingBoxVillage.from(center, radius, village.hashCode(), population, doors);
+            AbstractBoundingBox boundingBox = BoundingBoxVillage.from(center, radius, village.hashCode(), population, doors);
             cache.addBoundingBox(boundingBox);
         }
 
index c82d02f2866423c1f0511352f14903375f22e660..c4a443afa65667fc12d93f6cd9e8faf237267531 100644 (file)
@@ -1,15 +1,15 @@
 package com.irtimaled.bbor.client.events;
 
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 
 import java.util.Set;
 
 public class AddBoundingBoxReceived {
     private final int dimensionId;
-    private final BoundingBox key;
-    private final Set<BoundingBox> boundingBoxes;
+    private final AbstractBoundingBox key;
+    private final Set<AbstractBoundingBox> boundingBoxes;
 
-    public AddBoundingBoxReceived(int dimensionId, BoundingBox key, Set<BoundingBox> boundingBoxes) {
+    public AddBoundingBoxReceived(int dimensionId, AbstractBoundingBox key, Set<AbstractBoundingBox> boundingBoxes) {
         this.dimensionId = dimensionId;
         this.key = key;
         this.boundingBoxes = boundingBoxes;
@@ -19,11 +19,11 @@ public class AddBoundingBoxReceived {
         return dimensionId;
     }
 
-    public BoundingBox getKey() {
+    public AbstractBoundingBox getKey() {
         return key;
     }
 
-    public Set<BoundingBox> getBoundingBoxes() {
+    public Set<AbstractBoundingBox> getBoundingBoxes() {
         return boundingBoxes;
     }
 }
index 78b679bd815d585c75fea70ddcb12d9befb961ef..a648627a5e97ebad7ad170aed71895bec28a8a6d 100644 (file)
@@ -1,12 +1,12 @@
 package com.irtimaled.bbor.client.events;
 
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 
 public class RemoveBoundingBoxReceived {
     private final int dimensionId;
-    private final BoundingBox key;
+    private final AbstractBoundingBox key;
 
-    public RemoveBoundingBoxReceived(int dimensionId, BoundingBox key) {
+    public RemoveBoundingBoxReceived(int dimensionId, AbstractBoundingBox key) {
         this.dimensionId = dimensionId;
         this.key = key;
     }
@@ -15,7 +15,7 @@ public class RemoveBoundingBoxReceived {
         return dimensionId;
     }
 
-    public BoundingBox getKey() {
+    public AbstractBoundingBox getKey() {
         return key;
     }
 }
diff --git a/src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java b/src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java
new file mode 100644 (file)
index 0000000..1063c1a
--- /dev/null
@@ -0,0 +1,152 @@
+package com.irtimaled.bbor.client.renderers;
+
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.config.ConfigManager;
+import net.minecraft.client.renderer.BufferBuilder;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+
+public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
+    public abstract void render(T boundingBox);
+
+    void renderBoundingBox(T boundingBox) {
+        OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
+        renderCuboid(bb, boundingBox.getColor(), fill());
+    }
+
+    boolean fill() {
+        return ConfigManager.fill.get();
+    }
+
+    void renderLine(OffsetPoint point1, OffsetPoint point2, Color color) {
+        int colorR = color.getRed();
+        int colorG = color.getGreen();
+        int colorB = color.getBlue();
+
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder worldRenderer = tessellator.getBuffer();
+        worldRenderer.begin(GL11.GL_LINES, worldRenderer.getVertexFormat());
+        worldRenderer.pos(point1.getX(), point1.getY(), point1.getZ()).color(colorR, colorG, colorB, 255).endVertex();
+        worldRenderer.pos(point2.getX(), point2.getY(), point2.getZ()).color(colorR, colorG, colorB, 255).endVertex();
+        tessellator.draw();
+    }
+
+    void renderCuboid(OffsetBox bb, Color color, boolean fill) {
+        bb = bb.nudge();
+        if (fill) {
+            renderFilledCuboid(bb, color);
+        }
+        renderUnfilledCuboid(bb, color);
+    }
+
+    private void renderFilledCuboid(OffsetBox bb, Color color) {
+        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+        GL11.glEnable(GL11.GL_BLEND);
+        renderCuboid(bb, 30, color);
+        GL11.glDisable(GL11.GL_BLEND);
+        GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
+        GL11.glPolygonOffset(-1.f, -1.f);
+    }
+
+    private void renderUnfilledCuboid(OffsetBox bb, Color color) {
+        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+        renderCuboid(bb, 255, color);
+    }
+
+    private void renderCuboid(OffsetBox bb, int alphaChannel, Color color) {
+        int colorR = color.getRed();
+        int colorG = color.getGreen();
+        int colorB = color.getBlue();
+
+        OffsetPoint min = bb.getMin();
+        OffsetPoint max = bb.getMax();
+
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder worldRenderer = tessellator.getBuffer();
+
+        worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+        worldRenderer.pos(min.getX(), min.getY(), min.getZ())
+                .color(colorR, colorG, colorB, alphaChannel)
+                .endVertex();
+        worldRenderer.pos(max.getX(), min.getY(), min.getZ())
+                .color(colorR, colorG, colorB, alphaChannel)
+                .endVertex();
+        worldRenderer.pos(max.getX(), min.getY(), max.getZ())
+                .color(colorR, colorG, colorB, alphaChannel)
+                .endVertex();
+        worldRenderer.pos(min.getX(), min.getY(), max.getZ())
+                .color(colorR, colorG, colorB, alphaChannel)
+                .endVertex();
+
+        if (min.getY() != max.getY()) {
+            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+
+            worldRenderer.pos(min.getX(), min.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), min.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+
+            worldRenderer.pos(min.getX(), min.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), min.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+
+            worldRenderer.pos(min.getX(), min.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), min.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+
+            worldRenderer.pos(max.getX(), min.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), min.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
+                    .color(colorR, colorG, colorB, alphaChannel)
+                    .endVertex();
+        }
+        tessellator.draw();
+    }
+}
index d4425a258450fe32b3349b8fe35059dd3d976c3c..b90bea8dbd55666b7f9a243bcae412834ebf015e 100644 (file)
@@ -8,7 +8,7 @@ import com.irtimaled.bbor.config.ConfigManager;
 
 import java.awt.*;
 
-public class MobSpawnerRenderer extends Renderer<BoundingBoxMobSpawner> {
+public class MobSpawnerRenderer extends AbstractRenderer<BoundingBoxMobSpawner> {
     @Override
     public void render(BoundingBoxMobSpawner boundingBox) {
         Coords coords = boundingBox.getCoords();
diff --git a/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java b/src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java
deleted file mode 100644 (file)
index a90cedd..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-package com.irtimaled.bbor.client.renderers;
-
-import com.irtimaled.bbor.common.models.BoundingBox;
-import com.irtimaled.bbor.config.ConfigManager;
-import net.minecraft.client.renderer.BufferBuilder;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-
-public abstract class Renderer<T extends BoundingBox> {
-    public abstract void render(T boundingBox);
-
-    void renderBoundingBox(T boundingBox) {
-        OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
-        renderCuboid(bb, boundingBox.getColor(), fill());
-    }
-
-    boolean fill() {
-        return ConfigManager.fill.get();
-    }
-
-    void renderLine(OffsetPoint point1, OffsetPoint point2, Color color) {
-        int colorR = color.getRed();
-        int colorG = color.getGreen();
-        int colorB = color.getBlue();
-
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder worldRenderer = tessellator.getBuffer();
-        worldRenderer.begin(GL11.GL_LINES, worldRenderer.getVertexFormat());
-        worldRenderer.pos(point1.getX(), point1.getY(), point1.getZ()).color(colorR, colorG, colorB, 255).endVertex();
-        worldRenderer.pos(point2.getX(), point2.getY(), point2.getZ()).color(colorR, colorG, colorB, 255).endVertex();
-        tessellator.draw();
-    }
-
-    void renderCuboid(OffsetBox bb, Color color, boolean fill) {
-        bb = bb.nudge();
-        if (fill) {
-            renderFilledCuboid(bb, color);
-        }
-        renderUnfilledCuboid(bb, color);
-    }
-
-    private void renderFilledCuboid(OffsetBox bb, Color color) {
-        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-        GL11.glEnable(GL11.GL_BLEND);
-        renderCuboid(bb, 30, color);
-        GL11.glDisable(GL11.GL_BLEND);
-        GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
-        GL11.glPolygonOffset(-1.f, -1.f);
-    }
-
-    private void renderUnfilledCuboid(OffsetBox bb, Color color) {
-        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-        renderCuboid(bb, 255, color);
-    }
-
-    private void renderCuboid(OffsetBox bb, int alphaChannel, Color color) {
-        int colorR = color.getRed();
-        int colorG = color.getGreen();
-        int colorB = color.getBlue();
-
-        OffsetPoint min = bb.getMin();
-        OffsetPoint max = bb.getMax();
-
-        Tessellator tessellator = Tessellator.getInstance();
-        BufferBuilder worldRenderer = tessellator.getBuffer();
-
-        worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
-        worldRenderer.pos(min.getX(), min.getY(), min.getZ())
-                .color(colorR, colorG, colorB, alphaChannel)
-                .endVertex();
-        worldRenderer.pos(max.getX(), min.getY(), min.getZ())
-                .color(colorR, colorG, colorB, alphaChannel)
-                .endVertex();
-        worldRenderer.pos(max.getX(), min.getY(), max.getZ())
-                .color(colorR, colorG, colorB, alphaChannel)
-                .endVertex();
-        worldRenderer.pos(min.getX(), min.getY(), max.getZ())
-                .color(colorR, colorG, colorB, alphaChannel)
-                .endVertex();
-
-        if (min.getY() != max.getY()) {
-            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-
-            worldRenderer.pos(min.getX(), min.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), min.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-
-            worldRenderer.pos(min.getX(), min.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), min.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-
-            worldRenderer.pos(min.getX(), min.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), min.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(min.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-
-            worldRenderer.pos(max.getX(), min.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), min.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), max.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-            worldRenderer.pos(max.getX(), max.getY(), min.getZ())
-                    .color(colorR, colorG, colorB, alphaChannel)
-                    .endVertex();
-        }
-        tessellator.draw();
-    }
-}
index f19040a3b4837644405c894c0c63c0d039dcc9e1..b7d270a713bf8d3c7c4412be58b019226bac3b8e 100644 (file)
@@ -6,7 +6,7 @@ import com.irtimaled.bbor.config.ConfigManager;
 
 import java.awt.*;
 
-public class SlimeChunkRenderer extends Renderer<BoundingBoxSlimeChunk> {
+public class SlimeChunkRenderer extends AbstractRenderer<BoundingBoxSlimeChunk> {
     @Override
     public void render(BoundingBoxSlimeChunk boundingBox) {
         OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
index e98cec8b820aa8d13cb9373d7adb4c8444b907cb..95b52ad4f0aab669f300c44f33b5854bf135348f 100644 (file)
@@ -2,7 +2,7 @@ package com.irtimaled.bbor.client.renderers;
 
 import com.irtimaled.bbor.common.models.BoundingBoxStructure;
 
-public class StructureRenderer extends Renderer<BoundingBoxStructure> {
+public class StructureRenderer extends AbstractRenderer<BoundingBoxStructure> {
     @Override
     public void render(BoundingBoxStructure boundingBox) {
         renderBoundingBox(boundingBox);
index d9034b4c8e1cc80106713fa22b2fee1c96f8a4ec..2bccb5d2895e9cec555b878a1290ac677adfafc7 100644 (file)
@@ -12,7 +12,7 @@ import java.awt.*;
 import java.util.HashSet;
 import java.util.Set;
 
-public class VillageRenderer extends Renderer<BoundingBoxVillage> {
+public class VillageRenderer extends AbstractRenderer<BoundingBoxVillage> {
     @Override
     public void render(BoundingBoxVillage boundingBox) {
         if (ConfigManager.renderVillageAsSphere.get()) {
index 696b4c18c7d2aabb235edce43005dfc573b843d5..ec74116e74346b3e5a76b51b6f0267954ae0ed12 100644 (file)
@@ -7,7 +7,7 @@ import com.irtimaled.bbor.config.ConfigManager;
 
 import java.awt.*;
 
-public class WorldSpawnRenderer extends Renderer<BoundingBoxWorldSpawn> {
+public class WorldSpawnRenderer extends AbstractRenderer<BoundingBoxWorldSpawn> {
     @Override
     public void render(BoundingBoxWorldSpawn boundingBox) {
         Color color = boundingBox.getColor();
index 03f870d8255570e334950f8b4aef09506fc4a771..638265031c3da82348df5c61674f24b3805218bf 100644 (file)
@@ -1,6 +1,6 @@
 package com.irtimaled.bbor.common;
 
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 
 import java.util.HashSet;
 import java.util.Map;
@@ -8,9 +8,9 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 public class BoundingBoxCache {
-    private Map<BoundingBox, Set<BoundingBox>> cache = new ConcurrentHashMap<>();
+    private Map<AbstractBoundingBox, Set<AbstractBoundingBox>> cache = new ConcurrentHashMap<>();
 
-    public Map<BoundingBox, Set<BoundingBox>> getBoundingBoxes() {
+    public Map<AbstractBoundingBox, Set<AbstractBoundingBox>> getBoundingBoxes() {
         return cache;
     }
 
@@ -18,23 +18,23 @@ public class BoundingBoxCache {
         cache.clear();
     }
 
-    public boolean isCached(BoundingBox key) {
+    public boolean isCached(AbstractBoundingBox key) {
         return cache.containsKey(key);
     }
 
-    public void addBoundingBoxes(BoundingBox key, Set<BoundingBox> boundingBoxes) {
+    public void addBoundingBoxes(AbstractBoundingBox key, Set<AbstractBoundingBox> boundingBoxes) {
         cache.put(key, boundingBoxes);
     }
 
-    public void addBoundingBox(BoundingBox key) {
+    public void addBoundingBox(AbstractBoundingBox key) {
         if(isCached(key)) return;
 
-        Set<BoundingBox> boundingBoxes = new HashSet<>();
+        Set<AbstractBoundingBox> boundingBoxes = new HashSet<>();
         boundingBoxes.add(key);
         addBoundingBoxes(key, boundingBoxes);
     }
 
-    void removeBoundingBox(BoundingBox key) {
+    void removeBoundingBox(AbstractBoundingBox key) {
         cache.remove(key);
     }
 }
index 30f15d7d77afe89bf596095d23780d931d7c415f..461d8f47235425a2c0077d86f474cf52d1622eec 100644 (file)
@@ -1,7 +1,7 @@
 package com.irtimaled.bbor.common;
 
 import com.irtimaled.bbor.Logger;
-import com.irtimaled.bbor.common.chunkProcessors.ChunkProcessor;
+import com.irtimaled.bbor.common.chunkProcessors.AbstractChunkProcessor;
 import com.irtimaled.bbor.common.chunkProcessors.EndChunkProcessor;
 import com.irtimaled.bbor.common.chunkProcessors.NetherChunkProcessor;
 import com.irtimaled.bbor.common.chunkProcessors.OverworldChunkProcessor;
@@ -22,9 +22,9 @@ import java.util.concurrent.ConcurrentHashMap;
 
 public class CommonProxy {
     private Set<ServerPlayer> players = new HashSet<>();
-    private Map<ServerPlayer, Set<BoundingBox>> playerBoundingBoxesCache = new HashMap<>();
+    private Map<ServerPlayer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
     private Map<Integer, VillageProcessor> villageProcessors = new HashMap<>();
-    private Map<Integer, ChunkProcessor> chunkProcessors = new HashMap<>();
+    private Map<Integer, AbstractChunkProcessor> chunkProcessors = new HashMap<>();
     private WorldData worldData = null;
     private final Map<Integer, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
 
@@ -47,7 +47,7 @@ public class CommonProxy {
     private void worldLoaded(WorldServer world) {
         int dimensionId = world.dimension.getType().getId();
         BoundingBoxCache boundingBoxCache = getOrCreateCache(dimensionId);
-        ChunkProcessor chunkProcessor = null;
+        AbstractChunkProcessor chunkProcessor = null;
         if (dimensionId == Dimensions.OVERWORLD) {
             setWorldData(world.getSeed(), world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnZ());
             chunkProcessor = new OverworldChunkProcessor(boundingBoxCache);
@@ -65,7 +65,7 @@ public class CommonProxy {
 
     private void chunkLoaded(Chunk chunk) {
         int dimensionId = chunk.getWorld().dimension.getType().getId();
-        ChunkProcessor chunkProcessor = chunkProcessors.get(dimensionId);
+        AbstractChunkProcessor chunkProcessor = chunkProcessors.get(dimensionId);
         if (chunkProcessor != null) {
             chunkProcessor.process(chunk);
         }
@@ -80,7 +80,7 @@ public class CommonProxy {
         playerBoundingBoxesCache.remove(player);
     }
 
-    private void sendRemoveBoundingBox(int dimensionId, BoundingBox boundingBox) {
+    private void sendRemoveBoundingBox(int dimensionId, AbstractBoundingBox boundingBox) {
         PayloadBuilder payload = RemoveBoundingBox.getPayload(dimensionId, boundingBox);
         if (payload == null) return;
 
@@ -103,10 +103,10 @@ public class CommonProxy {
     private void sendToPlayer(ServerPlayer player, BoundingBoxCache boundingBoxCache) {
         if (boundingBoxCache == null) return;
 
-        Map<BoundingBox, Set<BoundingBox>> cacheSubset = getBoundingBoxMap(player, boundingBoxCache.getBoundingBoxes());
+        Map<AbstractBoundingBox, Set<AbstractBoundingBox>> cacheSubset = getBoundingBoxMap(player, boundingBoxCache.getBoundingBoxes());
 
-        for (BoundingBox key : cacheSubset.keySet()) {
-            Set<BoundingBox> boundingBoxes = cacheSubset.get(key);
+        for (AbstractBoundingBox key : cacheSubset.keySet()) {
+            Set<AbstractBoundingBox> boundingBoxes = cacheSubset.get(key);
             PayloadBuilder payload = AddBoundingBox.getPayload(player.getDimensionId(), key, boundingBoxes);
             if (payload != null)
                 player.sendPacket(payload);
@@ -118,9 +118,9 @@ public class CommonProxy {
         }
     }
 
-    private Map<BoundingBox, Set<BoundingBox>> getBoundingBoxMap(ServerPlayer player, Map<BoundingBox, Set<BoundingBox>> boundingBoxMap) {
-        Map<BoundingBox, Set<BoundingBox>> cacheSubset = new HashMap<>();
-        for (BoundingBox key : boundingBoxMap.keySet()) {
+    private Map<AbstractBoundingBox, Set<AbstractBoundingBox>> getBoundingBoxMap(ServerPlayer player, Map<AbstractBoundingBox, Set<AbstractBoundingBox>> boundingBoxMap) {
+        Map<AbstractBoundingBox, Set<AbstractBoundingBox>> cacheSubset = new HashMap<>();
+        for (AbstractBoundingBox key : boundingBoxMap.keySet()) {
             if (!playerBoundingBoxesCache.containsKey(player) || !playerBoundingBoxesCache.get(player).contains(key)) {
                 cacheSubset.put(key, boundingBoxMap.get(key));
             }
@@ -128,14 +128,14 @@ public class CommonProxy {
         return cacheSubset;
     }
 
-    protected void addBoundingBox(int dimensionId, BoundingBox key, Set<BoundingBox> boundingBoxes) {
+    protected void addBoundingBox(int dimensionId, AbstractBoundingBox key, Set<AbstractBoundingBox> boundingBoxes) {
         BoundingBoxCache cache = getCache(dimensionId);
         if (cache == null) return;
 
         cache.addBoundingBoxes(key, boundingBoxes);
     }
 
-    protected void removeBoundingBox(int dimensionId, BoundingBox key) {
+    protected void removeBoundingBox(int dimensionId, AbstractBoundingBox key) {
         BoundingBoxCache cache = getCache(dimensionId);
         if (cache == null) return;
 
@@ -143,7 +143,7 @@ public class CommonProxy {
     }
 
     private void mobSpawnerBroken(int dimensionId, Coords pos) {
-        BoundingBox boundingBox = BoundingBoxMobSpawner.from(pos);
+        AbstractBoundingBox boundingBox = BoundingBoxMobSpawner.from(pos);
         removeBoundingBox(dimensionId, boundingBox);
         sendRemoveBoundingBox(dimensionId, boundingBox);
     }
diff --git a/src/main/java/com/irtimaled/bbor/common/chunkProcessors/AbstractChunkProcessor.java b/src/main/java/com/irtimaled/bbor/common/chunkProcessors/AbstractChunkProcessor.java
new file mode 100644 (file)
index 0000000..bcb83f9
--- /dev/null
@@ -0,0 +1,70 @@
+package com.irtimaled.bbor.common.chunkProcessors;
+
+import com.irtimaled.bbor.common.BoundingBoxCache;
+import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
+import com.irtimaled.bbor.common.models.BoundingBoxStructure;
+import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.tileentity.TileEntityMobSpawner;
+import net.minecraft.util.math.MutableBoundingBox;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.gen.feature.structure.StructurePiece;
+import net.minecraft.world.gen.feature.structure.StructureStart;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public abstract class AbstractChunkProcessor {
+    Set<BoundingBoxType> supportedStructures = new HashSet<>();
+
+    AbstractChunkProcessor(BoundingBoxCache boundingBoxCache) {
+        this.boundingBoxCache = boundingBoxCache;
+    }
+
+    private final BoundingBoxCache boundingBoxCache;
+
+    private void addStructures(BoundingBoxType type, Map<String, StructureStart> structureMap) {
+        StructureStart structureStart = structureMap.get(type.getName());
+        if (structureStart == null) return;
+
+        MutableBoundingBox bb = structureStart.getBoundingBox();
+        if (bb == null) return;
+
+        AbstractBoundingBox boundingBox = buildStructure(bb, type);
+        if (boundingBoxCache.isCached(boundingBox)) return;
+
+        Set<AbstractBoundingBox> structureBoundingBoxes = new HashSet<>();
+        for (StructurePiece structureComponent : structureStart.getComponents()) {
+            structureBoundingBoxes.add(buildStructure(structureComponent.getBoundingBox(), type));
+        }
+        boundingBoxCache.addBoundingBoxes(boundingBox, structureBoundingBoxes);
+    }
+
+    private AbstractBoundingBox buildStructure(MutableBoundingBox bb, BoundingBoxType type) {
+        Coords min = new Coords(bb.minX, bb.minY, bb.minZ);
+        Coords max = new Coords(bb.maxX, bb.maxY, bb.maxZ);
+        return BoundingBoxStructure.from(min, max, type);
+    }
+
+    private void addMobSpawners(Chunk chunk) {
+        Collection<TileEntity> tileEntities = chunk.getTileEntityMap().values();
+        for (TileEntity tileEntity : tileEntities) {
+            if (tileEntity instanceof TileEntityMobSpawner) {
+                Coords coords = new Coords(tileEntity.getPos());
+                boundingBoxCache.addBoundingBox(BoundingBoxMobSpawner.from(coords));
+            }
+        }
+    }
+
+    public void process(Chunk chunk) {
+        Map<String, StructureStart> structureMap = chunk.getStructureStarts();
+        if (structureMap.size() > 0) {
+            supportedStructures.forEach(type -> addStructures(type, structureMap));
+        }
+        addMobSpawners(chunk);
+    }
+}
diff --git a/src/main/java/com/irtimaled/bbor/common/chunkProcessors/ChunkProcessor.java b/src/main/java/com/irtimaled/bbor/common/chunkProcessors/ChunkProcessor.java
deleted file mode 100644 (file)
index af70bfd..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.irtimaled.bbor.common.chunkProcessors;
-
-import com.irtimaled.bbor.common.BoundingBoxCache;
-import com.irtimaled.bbor.common.BoundingBoxType;
-import com.irtimaled.bbor.common.models.BoundingBox;
-import com.irtimaled.bbor.common.models.BoundingBoxMobSpawner;
-import com.irtimaled.bbor.common.models.BoundingBoxStructure;
-import com.irtimaled.bbor.common.models.Coords;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.tileentity.TileEntityMobSpawner;
-import net.minecraft.util.math.MutableBoundingBox;
-import net.minecraft.world.chunk.Chunk;
-import net.minecraft.world.gen.feature.structure.StructurePiece;
-import net.minecraft.world.gen.feature.structure.StructureStart;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class ChunkProcessor {
-    Set<BoundingBoxType> supportedStructures = new HashSet<>();
-
-    ChunkProcessor(BoundingBoxCache boundingBoxCache) {
-        this.boundingBoxCache = boundingBoxCache;
-    }
-
-    private final BoundingBoxCache boundingBoxCache;
-
-    private void addStructures(BoundingBoxType type, Map<String, StructureStart> structureMap) {
-        StructureStart structureStart = structureMap.get(type.getName());
-        if (structureStart == null) return;
-
-        MutableBoundingBox bb = structureStart.getBoundingBox();
-        if (bb == null) return;
-
-        BoundingBox boundingBox = buildStructure(bb, type);
-        if (boundingBoxCache.isCached(boundingBox)) return;
-
-        Set<BoundingBox> structureBoundingBoxes = new HashSet<>();
-        for (StructurePiece structureComponent : structureStart.getComponents()) {
-            structureBoundingBoxes.add(buildStructure(structureComponent.getBoundingBox(), type));
-        }
-        boundingBoxCache.addBoundingBoxes(boundingBox, structureBoundingBoxes);
-    }
-
-    private BoundingBox buildStructure(MutableBoundingBox bb, BoundingBoxType type) {
-        Coords min = new Coords(bb.minX, bb.minY, bb.minZ);
-        Coords max = new Coords(bb.maxX, bb.maxY, bb.maxZ);
-        return BoundingBoxStructure.from(min, max, type);
-    }
-
-    private void addMobSpawners(Chunk chunk) {
-        Collection<TileEntity> tileEntities = chunk.getTileEntityMap().values();
-        for (TileEntity tileEntity : tileEntities) {
-            if (tileEntity instanceof TileEntityMobSpawner) {
-                Coords coords = new Coords(tileEntity.getPos());
-                boundingBoxCache.addBoundingBox(BoundingBoxMobSpawner.from(coords));
-            }
-        }
-    }
-
-    public void process(Chunk chunk) {
-        Map<String, StructureStart> structureMap = chunk.getStructureStarts();
-        if (structureMap.size() > 0) {
-            supportedStructures.forEach(type -> addStructures(type, structureMap));
-        }
-        addMobSpawners(chunk);
-    }
-}
index 0a732643e1bb07718e3e119c308fbdd6a1d624c0..b46824ff1d8b150b211abcc62f39218b4692c1af 100644 (file)
@@ -3,7 +3,7 @@ package com.irtimaled.bbor.common.chunkProcessors;
 import com.irtimaled.bbor.common.BoundingBoxCache;
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class EndChunkProcessor extends ChunkProcessor {
+public class EndChunkProcessor extends AbstractChunkProcessor {
     public EndChunkProcessor(BoundingBoxCache boundingBoxCache) {
         super(boundingBoxCache);
         supportedStructures.add(BoundingBoxType.EndCity);
index 6ecd4c102b6902088689779b231a26ee368baf7d..79e960713a6d1ec790193aaf295722f21b3f29f9 100644 (file)
@@ -3,7 +3,7 @@ package com.irtimaled.bbor.common.chunkProcessors;
 import com.irtimaled.bbor.common.BoundingBoxCache;
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class NetherChunkProcessor extends ChunkProcessor {
+public class NetherChunkProcessor extends AbstractChunkProcessor {
     public NetherChunkProcessor(BoundingBoxCache boundingBoxCache) {
         super(boundingBoxCache);
         supportedStructures.add(BoundingBoxType.NetherFortress);
index 89ef90cbc42a9e8d7b036d488a59d0425221d57b..ab561ba7031121035c168f78267d37d37aee7d43 100644 (file)
@@ -3,7 +3,7 @@ package com.irtimaled.bbor.common.chunkProcessors;
 import com.irtimaled.bbor.common.BoundingBoxCache;
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class OverworldChunkProcessor extends ChunkProcessor {
+public class OverworldChunkProcessor extends AbstractChunkProcessor {
     public OverworldChunkProcessor(BoundingBoxCache boundingBoxCache) {
         super(boundingBoxCache);
         supportedStructures.add(BoundingBoxType.DesertTemple);
index 8c72108ac8f274d6bc148c10e076429c4a56f181..3a12945565057955ae2971d51b80c38fff92d472 100644 (file)
@@ -1,7 +1,7 @@
 package com.irtimaled.bbor.common.messages;
 
 import com.irtimaled.bbor.client.events.AddBoundingBoxReceived;
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -9,14 +9,14 @@ import java.util.Set;
 public class AddBoundingBox {
     public static final String NAME = "bbor:add_bounding_box";
 
-    public static PayloadBuilder getPayload(int dimensionId, BoundingBox key, Set<BoundingBox> boundingBoxes) {
+    public static PayloadBuilder getPayload(int dimensionId, AbstractBoundingBox key, Set<AbstractBoundingBox> boundingBoxes) {
         if (!BoundingBoxSerializer.canSerialize(key)) return null;
 
         PayloadBuilder builder = PayloadBuilder.clientBound(NAME)
                 .writeVarInt(dimensionId);
         BoundingBoxSerializer.serialize(key, builder);
         if (boundingBoxes != null && boundingBoxes.size() > 1) {
-            for (BoundingBox boundingBox : boundingBoxes) {
+            for (AbstractBoundingBox boundingBox : boundingBoxes) {
                 BoundingBoxSerializer.serialize(boundingBox, builder);
             }
         }
@@ -25,12 +25,12 @@ public class AddBoundingBox {
 
     public static AddBoundingBoxReceived getEvent(PayloadReader reader) {
         int dimensionId = reader.readVarInt();
-        BoundingBox key = BoundingBoxDeserializer.deserialize(reader);
+        AbstractBoundingBox key = BoundingBoxDeserializer.deserialize(reader);
         if (key == null) return null;
 
-        Set<BoundingBox> boundingBoxes = new HashSet<>();
+        Set<AbstractBoundingBox> boundingBoxes = new HashSet<>();
         while (reader.isReadable()) {
-            BoundingBox boundingBox = BoundingBoxDeserializer.deserialize(reader);
+            AbstractBoundingBox boundingBox = BoundingBoxDeserializer.deserialize(reader);
             boundingBoxes.add(boundingBox);
         }
         if (boundingBoxes.size() == 0)
index 2e3d50f7e675a5c1d896605c6c1550f543ab070a..9481c88a7e50061502ccda09cbebb773073cc37a 100644 (file)
@@ -8,7 +8,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 class BoundingBoxDeserializer {
-    static BoundingBox deserialize(PayloadReader reader) {
+    static AbstractBoundingBox deserialize(PayloadReader reader) {
         if (!reader.isReadable(2)) return null;
 
         char type = reader.readChar();
@@ -23,7 +23,7 @@ class BoundingBoxDeserializer {
         return null;
     }
 
-    private static BoundingBox deserializeStructure(PayloadReader reader) {
+    private static AbstractBoundingBox deserializeStructure(PayloadReader reader) {
         BoundingBoxType type = BoundingBoxType.getByNameHash(reader.readInt());
         if (type == null) return null;
         Coords minCoords = reader.readCoords();
@@ -31,7 +31,7 @@ class BoundingBoxDeserializer {
         return BoundingBoxStructure.from(minCoords, maxCoords, type);
     }
 
-    private static BoundingBox deserializeVillage(PayloadReader reader) {
+    private static AbstractBoundingBox deserializeVillage(PayloadReader reader) {
         Coords center = reader.readCoords();
         int radius = reader.readVarInt();
         boolean spawnsIronGolems = reader.readBoolean();
@@ -43,7 +43,7 @@ class BoundingBoxDeserializer {
         return BoundingBoxVillage.from(center, radius, color, spawnsIronGolems, doors);
     }
 
-    private static BoundingBox deserializeMobSpawner(PayloadReader reader) {
+    private static AbstractBoundingBox deserializeMobSpawner(PayloadReader reader) {
         return BoundingBoxMobSpawner.from(reader.readCoords());
     }
 }
index 024a6e3548c55224399e4a15f186923358e58ad9..40d9084054e011775a1e4931eec370977a021dba 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Map;
 import java.util.function.BiConsumer;
 
 class BoundingBoxSerializer {
-    private static final Map<Class, BiConsumer<BoundingBox, PayloadBuilder>> serializers = new HashMap<>();
+    private static final Map<Class, BiConsumer<AbstractBoundingBox, PayloadBuilder>> serializers = new HashMap<>();
 
     static {
         serializers.put(BoundingBoxVillage.class, (bb, pb) -> serializeVillage((BoundingBoxVillage) bb, pb));
@@ -15,12 +15,12 @@ class BoundingBoxSerializer {
         serializers.put(BoundingBoxMobSpawner.class, (bb, pb) -> serializeMobSpawner((BoundingBoxMobSpawner) bb, pb));
     }
 
-    static boolean canSerialize(BoundingBox key) {
+    static boolean canSerialize(AbstractBoundingBox key) {
         return serializers.containsKey(key.getClass());
     }
 
-    static void serialize(BoundingBox boundingBox, PayloadBuilder builder) {
-        BiConsumer<BoundingBox, PayloadBuilder> serializer = serializers.get(boundingBox.getClass());
+    static void serialize(AbstractBoundingBox boundingBox, PayloadBuilder builder) {
+        BiConsumer<AbstractBoundingBox, PayloadBuilder> serializer = serializers.get(boundingBox.getClass());
         if (serializer == null) return;
 
         serializer.accept(boundingBox, builder);
index b44313daf087532e883608b7bc79d0f188cc6df5..2baf62e2b5a4d6a37442580165c8c57813865c65 100644 (file)
@@ -1,12 +1,12 @@
 package com.irtimaled.bbor.common.messages;
 
 import com.irtimaled.bbor.client.events.RemoveBoundingBoxReceived;
-import com.irtimaled.bbor.common.models.BoundingBox;
+import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 
 public class RemoveBoundingBox {
     public static final String NAME = "bbor:remove_bounding_box";
 
-    public static PayloadBuilder getPayload(int dimensionId, BoundingBox key) {
+    public static PayloadBuilder getPayload(int dimensionId, AbstractBoundingBox key) {
         if (!BoundingBoxSerializer.canSerialize(key)) return null;
 
         PayloadBuilder builder = PayloadBuilder.clientBound(NAME)
@@ -17,7 +17,7 @@ public class RemoveBoundingBox {
 
     public static RemoveBoundingBoxReceived getEvent(PayloadReader reader) {
         int dimensionId = reader.readVarInt();
-        BoundingBox key = BoundingBoxDeserializer.deserialize(reader);
+        AbstractBoundingBox key = BoundingBoxDeserializer.deserialize(reader);
         if (key == null) return null;
 
         return new RemoveBoundingBoxReceived(dimensionId, key);
diff --git a/src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java b/src/main/java/com/irtimaled/bbor/common/models/AbstractBoundingBox.java
new file mode 100644 (file)
index 0000000..b77f769
--- /dev/null
@@ -0,0 +1,63 @@
+package com.irtimaled.bbor.common.models;
+
+import com.irtimaled.bbor.common.BoundingBoxType;
+
+import java.awt.*;
+
+public abstract class AbstractBoundingBox {
+    private final Coords minCoords;
+    private final Coords maxCoords;
+    private final BoundingBoxType type;
+
+    protected AbstractBoundingBox(Coords minCoords, Coords maxCoords, BoundingBoxType type) {
+        this.minCoords = minCoords;
+        this.maxCoords = maxCoords;
+        this.type = type;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + minCoords.hashCode();
+        result = prime * result + maxCoords.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        AbstractBoundingBox other = (AbstractBoundingBox) obj;
+        return minCoords.equals(other.minCoords) && maxCoords.equals(other.maxCoords);
+    }
+
+    @Override
+    public String toString() {
+        return "(" + minCoords.toString() + "; " + maxCoords.toString() + ")";
+    }
+
+    public Coords getMinCoords() {
+        return minCoords;
+    }
+
+    public Coords getMaxCoords() {
+        return maxCoords;
+    }
+
+    public Color getColor() {
+        return type.getColor();
+    }
+
+    public Boolean shouldRender() {
+        return type.shouldRender();
+    }
+
+    public String getTypeName() {
+        return type.getName();
+    }
+}
diff --git a/src/main/java/com/irtimaled/bbor/common/models/BoundingBox.java b/src/main/java/com/irtimaled/bbor/common/models/BoundingBox.java
deleted file mode 100644 (file)
index d09f04c..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.irtimaled.bbor.common.models;
-
-import com.irtimaled.bbor.common.BoundingBoxType;
-
-import java.awt.*;
-
-public abstract class BoundingBox {
-    private final Coords minCoords;
-    private final Coords maxCoords;
-    private final BoundingBoxType type;
-
-    protected BoundingBox(Coords minCoords, Coords maxCoords, BoundingBoxType type) {
-        this.minCoords = minCoords;
-        this.maxCoords = maxCoords;
-        this.type = type;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + minCoords.hashCode();
-        result = prime * result + maxCoords.hashCode();
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj)
-            return true;
-        if (obj == null)
-            return false;
-        if (getClass() != obj.getClass())
-            return false;
-        BoundingBox other = (BoundingBox) obj;
-        return minCoords.equals(other.minCoords) && maxCoords.equals(other.maxCoords);
-    }
-
-    @Override
-    public String toString() {
-        return "(" + minCoords.toString() + "; " + maxCoords.toString() + ")";
-    }
-
-    public Coords getMinCoords() {
-        return minCoords;
-    }
-
-    public Coords getMaxCoords() {
-        return maxCoords;
-    }
-
-    public Color getColor() {
-        return type.getColor();
-    }
-
-    public Boolean shouldRender() {
-        return type.shouldRender();
-    }
-
-    public String getTypeName() {
-        return type.getName();
-    }
-}
index 681ddcddd447c4815fa1670c2a04125d5f1fef2f..27de5fe281b2e99b82274164f78bf67079cbd132 100644 (file)
@@ -2,7 +2,7 @@ package com.irtimaled.bbor.common.models;
 
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class BoundingBoxMobSpawner extends BoundingBox {
+public class BoundingBoxMobSpawner extends AbstractBoundingBox {
     private final Coords coords;
 
     private BoundingBoxMobSpawner(Coords coords, Coords minCoords, Coords maxCoords) {
index e95923b4fcdc61005b82aae86696f5542e820689..cb044c8fcaa0ff173b9f01a6168f382d46891443 100644 (file)
@@ -2,7 +2,7 @@ package com.irtimaled.bbor.common.models;
 
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class BoundingBoxSlimeChunk extends BoundingBox {
+public class BoundingBoxSlimeChunk extends AbstractBoundingBox {
     private BoundingBoxSlimeChunk(Coords minCoords, Coords maxCoords) {
         super(minCoords, maxCoords, BoundingBoxType.SlimeChunks);
     }
index 62179c16ad23b850c6b29bc7a1170842d6c9ce33..ba42a14a15d85318e56d93e1f3921f2f77df2bbe 100644 (file)
@@ -2,7 +2,7 @@ package com.irtimaled.bbor.common.models;
 
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class BoundingBoxStructure extends BoundingBox {
+public class BoundingBoxStructure extends AbstractBoundingBox {
     private BoundingBoxStructure(Coords minCoords, Coords maxCoords, BoundingBoxType type) {
         super(minCoords, maxCoords, type);
     }
index db0dd53ea622a3bf97d62b171a6862d041d7619a..e3e82d1691825ea17270481f81820103423235db 100644 (file)
@@ -7,7 +7,7 @@ import com.irtimaled.bbor.common.VillageHelper;
 import java.awt.*;
 import java.util.Set;
 
-public class BoundingBoxVillage extends BoundingBox {
+public class BoundingBoxVillage extends AbstractBoundingBox {
     private final Coords center;
     private final Integer radius;
     private final boolean spawnsIronGolems;
index 530a233debea07c9c60a24060f75eb05bae66c6f..d2610a74f672efca6e91650c813b2a3288065967 100644 (file)
@@ -2,7 +2,7 @@ package com.irtimaled.bbor.common.models;
 
 import com.irtimaled.bbor.common.BoundingBoxType;
 
-public class BoundingBoxWorldSpawn extends BoundingBox {
+public class BoundingBoxWorldSpawn extends AbstractBoundingBox {
     private BoundingBoxWorldSpawn(Coords minCoords, Coords maxCoords, BoundingBoxType type) {
         super(minCoords, maxCoords, type);
     }
diff --git a/src/main/java/com/irtimaled/bbor/config/AbstractSetting.java b/src/main/java/com/irtimaled/bbor/config/AbstractSetting.java
new file mode 100644 (file)
index 0000000..a3d6e74
--- /dev/null
@@ -0,0 +1,19 @@
+package com.irtimaled.bbor.config;
+
+public abstract class AbstractSetting {
+    String comment;
+    String category;
+    String name;
+
+    private final char type;
+
+    public AbstractSetting(char type) {
+        this.type = type;
+    }
+
+    char getType() {
+        return type;
+    }
+
+    abstract Object getValue();
+}
index 0af115ac3f3b01dfb221b9ac02dad26b6e673c9d..b1ee7d473d2cffccab587ecd7acab936d3cde0db 100644 (file)
@@ -1,6 +1,6 @@
 package com.irtimaled.bbor.config;
 
-public class Setting<T> extends SettingBase {
+public class Setting<T> extends AbstractSetting {
     private T value;
 
     public Setting(char type, T value) {
diff --git a/src/main/java/com/irtimaled/bbor/config/SettingBase.java b/src/main/java/com/irtimaled/bbor/config/SettingBase.java
deleted file mode 100644 (file)
index 418fb9f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.irtimaled.bbor.config;
-
-public abstract class SettingBase {
-    String comment;
-    String category;
-    String name;
-
-    private final char type;
-
-    public SettingBase(char type) {
-        this.type = type;
-    }
-
-    char getType() {
-        return type;
-    }
-
-    abstract Object getValue();
-}