From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <spottedleaf@spottedleaf.dev>
Date: Mon, 6 Jul 2020 22:48:48 -0700
Subject: [PATCH] Manually inline methods in BlockPosition


diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java
index 6b655b744d31d9660c7521ab596b27bcd92f4d58..e811295b4d6afcd920f60e0ce5440e43300d9085 100644
--- a/src/main/java/net/minecraft/server/BaseBlockPosition.java
+++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java
@@ -16,9 +16,9 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
         return IntStream.of(new int[]{baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ()});
     });
     public static final BaseBlockPosition ZERO = new BaseBlockPosition(0, 0, 0);
-    private int a;public final void setX(final int x) { this.a = x; } // Paper - OBFHELPER
-    private int b;public final void setY(final int y) { this.b = y; } // Paper - OBFHELPER
-    private int e;public final void setZ(final int z) { this.e = z; } // Paper - OBFHELPER
+    protected int a; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the x coordinate - Also revert the decision to expose set on an immutable type
+    protected int b; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the y coordinate - Also revert the decision to expose set on an immutable type
+    protected int e; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the z coordinate - Also revert the decision to expose set on an immutable type
 
     // Paper start
     public boolean isValidLocation() {
@@ -71,15 +71,15 @@ public class BaseBlockPosition implements Comparable<BaseBlockPosition> {
         return this.e;
     }
 
-    public void o(int i) { // Paper - protected -> public
+    protected void o_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
         this.a = i;
     }
 
-    public void p(int i) { // Paper - protected -> public
+    protected void p_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
         this.b = i;
     }
 
-    public void q(int i) { // Paper - protected -> public
+    protected void q_unused(int i) { // Paper - protected -> public // Tuinity - not needed here - Also revert the decision to expose set on an immutable type
         this.e = i;
     }
 
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index 2d887af902a33b0e28d8f0a6ac2e59c815a7856e..2291135eaef64c403183724cb6e413cd7e472672 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -449,10 +449,10 @@ public class BlockPosition extends BaseBlockPosition {
         }
 
         public final BlockPosition.MutableBlockPosition setValues(int i, int j, int k) { return d(i, j, k);} // Paper - OBFHELPER
-        public BlockPosition.MutableBlockPosition d(int i, int j, int k) {
-            this.o(i);
-            this.p(j);
-            this.q(k);
+        public final BlockPosition.MutableBlockPosition d(int i, int j, int k) { // Tuinity
+            ((BaseBlockPosition)this).a = i; // Tuinity - force inline
+            ((BaseBlockPosition)this).b = j; // Tuinity - force inline
+            ((BaseBlockPosition)this).e = k; // Tuinity - force inline
             return this;
         }
 
@@ -462,12 +462,18 @@ public class BlockPosition extends BaseBlockPosition {
         }
 
         public final BlockPosition.MutableBlockPosition setValues(final BaseBlockPosition baseblockposition) { return this.g(baseblockposition); } // Paper - OBFHELPER
-        public BlockPosition.MutableBlockPosition g(BaseBlockPosition baseblockposition) {
-            return this.d(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ());
+        public final BlockPosition.MutableBlockPosition g(BaseBlockPosition baseblockposition) { // Tuinity
+            ((BaseBlockPosition)this).a = baseblockposition.a; // Tuinity - force inline
+            ((BaseBlockPosition)this).b = baseblockposition.b; // Tuinity - force inline
+            ((BaseBlockPosition)this).e = baseblockposition.e; // Tuinity - force inline
+            return this;
         }
 
-        public BlockPosition.MutableBlockPosition g(long i) {
-            return this.d(b(i), c(i), d(i));
+        public final BlockPosition.MutableBlockPosition g(long i) { // Tuinity
+            ((BaseBlockPosition)this).a = (int)(i >> 38); // Tuinity - force inline
+            ((BaseBlockPosition)this).b = (int)((i << 52) >> 52); // Tuinity - force inline
+            ((BaseBlockPosition)this).e = (int)((i << 26) >> 38); // Tuinity - force inline
+            return this;
         }
 
         public BlockPosition.MutableBlockPosition a(EnumAxisCycle enumaxiscycle, int i, int j, int k) {
@@ -482,8 +488,11 @@ public class BlockPosition extends BaseBlockPosition {
             return this.d(baseblockposition.getX() + i, baseblockposition.getY() + j, baseblockposition.getZ() + k);
         }
 
-        public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection) {
-            return this.c(enumdirection, 1);
+        public final BlockPosition.MutableBlockPosition c(EnumDirection enumdirection) { // Tuinity
+            ((BaseBlockPosition)this).a += enumdirection.getAdjacentX(); // Tuinity - force inline
+            ((BaseBlockPosition)this).b += enumdirection.getAdjacentY(); // Tuinity - force inline
+            ((BaseBlockPosition)this).e += enumdirection.getAdjacentZ(); // Tuinity - force inline
+            return this;
         }
 
         public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection, int i) {
@@ -511,21 +520,30 @@ public class BlockPosition extends BaseBlockPosition {
             }
         }
 
-        /* // Paper start - comment out useless overrides @Override
-        @Override
-        public void o(int i) {
-            super.o(i);
+        // Tuinity start
+        // only expose set on the mutable blockpos
+        public final void setX(int value) {
+            ((BaseBlockPosition)this).a = value;
+        }
+        public final void setY(int value) {
+            ((BaseBlockPosition)this).b = value;
+        }
+        public final void setZ(int value) {
+            ((BaseBlockPosition)this).e = value;
         }
 
-        @Override
-        public void p(int i) {
-            super.p(i);
+        public final void o(int i) {
+            ((BaseBlockPosition)this).a = i; // need cast thanks to name conflict
+        }
+
+        public final void p(int i) {
+            ((BaseBlockPosition)this).b = i;
         }
 
-        public void q(int i) {
-            super.q(i);
+        public final void q(int i) {
+            ((BaseBlockPosition)this).e = i;
         }
-        */ // Paper end
+        // Tuinity end
 
         @Override
         public BlockPosition immutableCopy() {
