]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Extra PlayerData logic to static class
authorirtimaled <irtimaled@gmail.com>
Thu, 28 Dec 2017 06:54:01 +0000 (22:54 -0800)
committerirtimaled <irtimaled@gmail.com>
Sat, 30 Dec 2017 03:48:26 +0000 (19:48 -0800)
java/com/irtimaled/bbor/client/ClientProxy.java
java/com/irtimaled/bbor/client/PlayerData.java [new file with mode: 0644]

index 970bbd988299d377de291b4dc86d10e3583bccbb..5b39b04a86ab2fae7a22eae2c345371b1d6e2861 100644 (file)
@@ -38,14 +38,10 @@ import java.util.Random;
 import java.util.Set;
 
 public class ClientProxy extends CommonProxy {
-    private double activeY;
     private boolean active;
     private boolean outerBoxOnly;
     private KeyBinding activeHotKey;
     private KeyBinding outerBoxOnlyHotKey;
-    private double playerX;
-    private double playerY;
-    private double playerZ;
     private BoundingBox worldSpawnBoundingBox;
     private BoundingBox spawnChunksBoundingBox;
     private BoundingBox lazySpawnChunksBoundingBox;
@@ -54,7 +50,7 @@ public class ClientProxy extends CommonProxy {
         if (activeHotKey.isPressed()) {
             active = !active;
             if (active)
-                activeY = playerY;
+                PlayerData.setActiveY();
         } else if (outerBoxOnlyHotKey.isPressed()) {
             outerBoxOnly = !outerBoxOnly;
         }
@@ -79,9 +75,7 @@ public class ClientProxy extends CommonProxy {
 
     public void render(float partialTicks) {
         EntityPlayer entityPlayer = Minecraft.getMinecraft().player;
-        playerX = entityPlayer.lastTickPosX + (entityPlayer.posX - entityPlayer.lastTickPosX) * (double) partialTicks;
-        playerY = entityPlayer.lastTickPosY + (entityPlayer.posY - entityPlayer.lastTickPosY) * (double) partialTicks;
-        playerZ = entityPlayer.lastTickPosZ + (entityPlayer.posZ - entityPlayer.lastTickPosZ) * (double) partialTicks;
+        PlayerData.setPlayerPosition(partialTicks, entityPlayer);
 
         if (this.active) {
             DimensionType dimensionType = DimensionType.getById(entityPlayer.dimension);
@@ -349,7 +343,7 @@ public class ClientProxy extends CommonProxy {
     private void renderWorldSpawn(BoundingBoxWorldSpawn bb) {
         AxisAlignedBB aaBB = bb.toAxisAlignedBB(false);
         Color color = bb.getColor();
-        double y = getMaxY(ConfigManager.worldSpawnMaxY.getInt()) + 0.001F;
+        double y = PlayerData.getMaxY(ConfigManager.worldSpawnMaxY.getInt()) + 0.001F;
         renderRectangle(aaBB, y, y, color, false);
     }
 
@@ -358,21 +352,12 @@ public class ClientProxy extends CommonProxy {
         Color color = bb.getColor();
         renderCuboid(aaBB, color, fill());
 
-        double maxY = getMaxY(ConfigManager.slimeChunkMaxY.getInt());
+        double maxY = PlayerData.getMaxY(ConfigManager.slimeChunkMaxY.getInt());
         if (maxY > 39) {
             renderRectangle(aaBB, 39, maxY, color, fill());
         }
     }
 
-    private double getMaxY(double configMaxY) {
-        if (configMaxY == -1) {
-            return activeY;
-        } else if ((configMaxY == 0) || (playerY < configMaxY)) {
-            return playerY;
-        }
-        return configMaxY;
-    }
-
     private void renderRectangle(AxisAlignedBB aaBB, double minY, double maxY, Color color, Boolean fill) {
         aaBB = new AxisAlignedBB(aaBB.minX, minY, aaBB.minZ, aaBB.maxX, maxY, aaBB.maxZ);
         renderCuboid(aaBB, color, fill);
@@ -538,7 +523,7 @@ public class ClientProxy extends CommonProxy {
         }
         return axisAlignedBB
                 .grow(growXZ, growY, growXZ)
-                .offset(-playerX, -playerY, -playerZ);
+                .offset(-PlayerData.getX(), -PlayerData.getY(), -PlayerData.getZ());
     }
 
     private void renderBoundingBoxVillageAsSphere(BoundingBoxVillage bb) {
@@ -583,15 +568,15 @@ public class ClientProxy extends CommonProxy {
         }
 
         public double getX() {
-            return x - playerX;
+            return x - PlayerData.getX();
         }
 
         public double getY() {
-            return y - playerY;
+            return y - PlayerData.getY();
         }
 
         public double getZ() {
-            return z - playerZ;
+            return z - PlayerData.getZ();
         }
 
         public OffsetPoint add(double x, double y, double z) {
diff --git a/java/com/irtimaled/bbor/client/PlayerData.java b/java/com/irtimaled/bbor/client/PlayerData.java
new file mode 100644 (file)
index 0000000..339d81c
--- /dev/null
@@ -0,0 +1,41 @@
+package com.irtimaled.bbor.client;
+
+import net.minecraft.entity.player.EntityPlayer;
+
+public class PlayerData {
+    private static double x;
+    private static double y;
+    private static double z;
+    private static double activeY;
+
+    static void setPlayerPosition(double partialTicks, EntityPlayer entityPlayer) {
+        x = entityPlayer.lastTickPosX + (entityPlayer.posX - entityPlayer.lastTickPosX) * partialTicks;
+        y = entityPlayer.lastTickPosY + (entityPlayer.posY - entityPlayer.lastTickPosY) * partialTicks;
+        z = entityPlayer.lastTickPosZ + (entityPlayer.posZ - entityPlayer.lastTickPosZ) * partialTicks;
+    }
+
+    static void setActiveY() {
+        activeY = y;
+    }
+
+    public static double getX() {
+        return x;
+    }
+
+    public static double getY() {
+        return y;
+    }
+
+    public static double getZ() {
+        return z;
+    }
+
+    public static double getMaxY(double configMaxY) {
+        if (configMaxY == -1) {
+            return activeY;
+        } else if ((configMaxY == 0) || (y < configMaxY)) {
+            return y;
+        }
+        return configMaxY;
+    }
+}