aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0002-Remap-fixes.patch
blob: fc4f1507e0c366724b970293fbe09a4e6d34eb50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kyle Wood <kyle@denwav.dev>
Date: Fri, 11 Jun 2021 05:25:03 -0500
Subject: [PATCH] Remap fixes


diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index ad3035da44c6af2fa7cc53926f33526a43740313..e89fa618fa20e3e843d8de81629e6dc551777823 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -278,9 +278,11 @@ public class BlockPos extends Vec3i {
 
     public static Iterable<BlockPos> withinManhattan(BlockPos center, int rangeX, int rangeY, int rangeZ) {
         int i = rangeX + rangeY + rangeZ;
-        int j = center.getX();
-        int k = center.getY();
-        int l = center.getZ();
+        // Paper start - rename variables to fix conflict with anonymous class (remap fix)
+        int centerX = center.getX();
+        int centerY = center.getY();
+        int centerZ = center.getZ();
+        // Paper end
         return () -> {
             return new AbstractIterator<BlockPos>() {
                 private final BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
@@ -295,7 +297,7 @@ public class BlockPos extends Vec3i {
                 protected BlockPos computeNext() {
                     if (this.zMirror) {
                         this.zMirror = false;
-                        this.cursor.setZ(l - (this.cursor.getZ() - l));
+                        this.cursor.setZ(centerZ - (this.cursor.getZ() - centerZ)); // Paper - remap fix
                         return this.cursor;
                     } else {
                         BlockPos blockPos;
@@ -321,7 +323,7 @@ public class BlockPos extends Vec3i {
                             int k = this.currentDepth - Math.abs(i) - Math.abs(j);
                             if (k <= rangeZ) {
                                 this.zMirror = k != 0;
-                                blockPos = this.cursor.set(j + i, k + j, l + k);
+                                blockPos = this.cursor.set(centerX + i, centerY + j, centerZ + k); // Paper - remap fix
                             }
                         }
 
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
index 3ba785845a63e46a44fc48264d08c96bfc34ab8b..92bd58010e8c89e361e28aec59447349edbbc028 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
@@ -173,11 +173,11 @@ public class BehaviorUtils {
 
         return optional.map((uuid) -> {
             return ((ServerLevel) entity.level()).getEntity(uuid);
-        }).map((entity) -> {
+        }).map((entity1) -> { // Paper - remap fix
             LivingEntity entityliving1;
 
-            if (entity instanceof LivingEntity) {
-                LivingEntity entityliving2 = (LivingEntity) entity;
+            if (entity1 instanceof LivingEntity) { // Paper - remap fix
+                LivingEntity entityliving2 = (LivingEntity) entity1; // Paper - remap fix
 
                 entityliving1 = entityliving2;
             } else {
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
index b402543da876e6d14b263443b2d692f33eb08863..4d2d23ff118e9307d50ca2a5194b83450c91a752 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -192,7 +192,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
         Builder<ResourceLocation, Recipe<?>> builder = ImmutableMap.builder();
 
         recipes.forEach((irecipe) -> {
-            Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
+            Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes_) -> { // Paper - remap fix
                 return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
             });
             ResourceLocation minecraftkey = irecipe.getId();
diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java
index ad52c3fc6210939a39ef77a382c640a24ee44838..6b7dd01778f0a5d3a96d2d04af4b525d17efbfba 100644
--- a/src/test/java/org/bukkit/DyeColorsTest.java
+++ b/src/test/java/org/bukkit/DyeColorsTest.java
@@ -4,7 +4,6 @@ import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
 import java.util.ArrayList;
 import java.util.List;
-import net.minecraft.world.item.DyeColor;
 import org.bukkit.support.AbstractTestingBase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -29,7 +28,7 @@ public class DyeColorsTest extends AbstractTestingBase {
     @Test
     public void checkColor() {
         Color color = this.dye.getColor();
-        float[] nmsColorArray = DyeColor.byId(this.dye.getWoolData()).getTextureDiffuseColors();
+        float[] nmsColorArray = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getTextureDiffuseColors(); // Paper - remap fix
         Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255));
         assertThat(color, is(nmsColor));
     }
@@ -37,7 +36,7 @@ public class DyeColorsTest extends AbstractTestingBase {
     @Test
     public void checkFireworkColor() {
         Color color = this.dye.getFireworkColor();
-        int nmsColor = DyeColor.byId(this.dye.getWoolData()).getFireworkColor();
+        int nmsColor = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getFireworkColor(); // Paper - remap fix
         assertThat(color, is(Color.fromRGB(nmsColor)));
     }
 }
diff --git a/src/test/java/org/bukkit/RegistryConstantsTest.java b/src/test/java/org/bukkit/RegistryConstantsTest.java
index 569aa9caac8407b52214dbec564dc8e9f08cacc9..c20fc9466649f16f1102978590780bb729c55bc9 100644
--- a/src/test/java/org/bukkit/RegistryConstantsTest.java
+++ b/src/test/java/org/bukkit/RegistryConstantsTest.java
@@ -4,7 +4,7 @@ import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
-import net.minecraft.core.Registry;
+// import net.minecraft.core.Registry; // Paper - remap fix
 import net.minecraft.core.registries.Registries;
 import net.minecraft.resources.ResourceKey;
 import net.minecraft.resources.ResourceLocation;
@@ -105,13 +105,13 @@ public class RegistryConstantsTest extends AbstractTestingBase {
 
     @Test
     public void testTrimMaterial() {
-        this.testExcessConstants(TrimMaterial.class, Registry.TRIM_MATERIAL);
+        this.testExcessConstants(TrimMaterial.class, org.bukkit.Registry.TRIM_MATERIAL); // Paper - remap fix
         this.testMissingConstants(TrimMaterial.class, Registries.TRIM_MATERIAL);
     }
 
     @Test
     public void testTrimPattern() {
-        this.testExcessConstants(TrimPattern.class, Registry.TRIM_PATTERN);
+        this.testExcessConstants(TrimPattern.class, org.bukkit.Registry.TRIM_PATTERN); // Paper - remap fix
         this.testMissingConstants(TrimPattern.class, Registries.TRIM_PATTERN);
     }
 
@@ -169,7 +169,7 @@ public class RegistryConstantsTest extends AbstractTestingBase {
         this.testMissingConstants(MusicInstrument.class, Registries.INSTRUMENT);
     }
 
-    private <T extends Keyed> void testExcessConstants(Class<T> clazz, Registry<T> registry) {
+    private <T extends Keyed> void testExcessConstants(Class<T> clazz, Registry<T> registry) { // Paper - remap fix
         List<NamespacedKey> excessKeys = new ArrayList<>();
 
         for (Field field : clazz.getFields()) {
@@ -198,10 +198,10 @@ public class RegistryConstantsTest extends AbstractTestingBase {
         Assert.assertTrue(excessKeys.size() + " excess constants(s) in " + clazz.getSimpleName() + " that do not exist: " + excessKeys, excessKeys.isEmpty());
     }
 
-    private <T extends Keyed, M> void testMissingConstants(Class<T> clazz, ResourceKey<Registry<M>> nmsRegistryKey) {
+    private <T extends Keyed, M> void testMissingConstants(Class<T> clazz, ResourceKey<net.minecraft.core.Registry<M>> nmsRegistryKey) { // Paper - remap fix
         List<ResourceLocation> missingKeys = new ArrayList<>();
 
-        Registry<M> nmsRegistry = REGISTRY_CUSTOM.registryOrThrow(nmsRegistryKey);
+        net.minecraft.core.Registry<M> nmsRegistry = REGISTRY_CUSTOM.registryOrThrow(nmsRegistryKey); // Paper - remap fix
         for (M nmsObject : nmsRegistry) {
             ResourceLocation minecraftKey = nmsRegistry.getKey(nmsObject);
 
diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java
index db23efff71a5e680c05ba61b3f9db72d35e437c1..e410b06cf7082714e1733be47500950c54031c41 100644
--- a/src/test/java/org/bukkit/entity/EntityTypesTest.java
+++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java
@@ -15,8 +15,8 @@ public class EntityTypesTest extends AbstractTestingBase {
 
     @Test
     public void testClasses() {
-       for (EntityType<?> entityType : Registry.ENTITY_TYPE) {
-           if (entityType == EntityType.UNKNOWN) {
+       for (org.bukkit.entity.EntityType<?> entityType : Registry.ENTITY_TYPE) { // Paper - remap fix
+           if (entityType == org.bukkit.entity.EntityType.UNKNOWN) { // Paper - remap fix
                continue;
            }
 
@@ -26,10 +26,10 @@ public class EntityTypesTest extends AbstractTestingBase {
 
     @Test
     public void testMaps() {
-        Set<EntityType<?>> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b != EntityType.UNKNOWN).collect(Collectors.toSet());
+        Set<org.bukkit.entity.EntityType<?>> allBukkit = Arrays.stream(org.bukkit.entity.EntityType.values()).filter((b) -> b != org.bukkit.entity.EntityType.UNKNOWN).collect(Collectors.toSet()); // Paper - remap fix
 
-        for (EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) {
-            ResourceLocation key = EntityType.getKey(nms);
+        for (net.minecraft.world.entity.EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) { // Paper - remap fix
+            ResourceLocation key = net.minecraft.world.entity.EntityType.getKey(nms); // Paper - remap fix
 
             org.bukkit.entity.EntityType<?> bukkit = org.bukkit.entity.EntityType.fromName(key.getPath());
             Assert.assertNotNull("Missing nms->bukkit " + key, bukkit);
diff --git a/src/test/java/org/bukkit/entity/PandaGeneTest.java b/src/test/java/org/bukkit/entity/PandaGeneTest.java
index 76e2ad676ae68846bdff3c3ef711751445fb0f3c..feee17192bca55a9cf1b2fc5b9609b888db77763 100644
--- a/src/test/java/org/bukkit/entity/PandaGeneTest.java
+++ b/src/test/java/org/bukkit/entity/PandaGeneTest.java
@@ -1,6 +1,5 @@
 package org.bukkit.entity;
 
-import net.minecraft.world.entity.animal.Panda;
 import org.bukkit.craftbukkit.entity.CraftPanda;
 import org.junit.Assert;
 import org.junit.Test;
@@ -10,7 +9,7 @@ public class PandaGeneTest {
     @Test
     public void testBukkit() {
         for (Panda.Gene gene : Panda.Gene.values()) {
-            Panda.Gene nms = CraftPanda.toNms(gene);
+            net.minecraft.world.entity.animal.Panda.Gene nms = CraftPanda.toNms(gene); // Paper - remap fix
 
             Assert.assertNotNull("NMS gene null for " + gene, nms);
             Assert.assertEquals("Recessive status did not match " + gene, gene.isRecessive(), nms.isRecessive());
@@ -20,7 +19,7 @@ public class PandaGeneTest {
 
     @Test
     public void testNMS() {
-        for (Panda.Gene gene : Panda.Gene.values()) {
+        for (net.minecraft.world.entity.animal.Panda.Gene gene : net.minecraft.world.entity.animal.Panda.Gene.values()) { // Paper - remap fix
             org.bukkit.entity.Panda.Gene bukkit = CraftPanda.fromNms(gene);
 
             Assert.assertNotNull("Bukkit gene null for " + gene, bukkit);
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
index 9227d8a2103d7c001c1cba5f96a9a2fcd8c7595c..a9535199b39d03652f1235d4a920b795306f4ec9 100644
--- a/src/test/java/org/bukkit/support/DummyServer.java
+++ b/src/test/java/org/bukkit/support/DummyServer.java
@@ -81,7 +81,7 @@ public final class DummyServer {
             Mockito.when(instance.getTag(Mockito.any(), Mockito.any(), Mockito.any())).then(mock -> {
                 String registry = mock.getArgument(0);
                 Class<?> clazz = mock.getArgument(2);
-                MinecraftKey key = CraftNamespacedKey.toMinecraft(mock.getArgument(1));
+                net.minecraft.resources.ResourceLocation key = CraftNamespacedKey.toMinecraft(mock.getArgument(1)); // Paper - remap fix
 
                 switch (registry) {
                     case org.bukkit.Tag.REGISTRY_BLOCKS -> {
@@ -100,14 +100,14 @@ public final class DummyServer {
                     }
                     case org.bukkit.Tag.REGISTRY_FLUIDS -> {
                         Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type");
-                        TagKey<FluidType> fluidTagKey = TagKey.create(Registries.FLUID, key);
+                        TagKey<net.minecraft.world.level.material.Fluid> fluidTagKey = TagKey.create(Registries.FLUID, key); // Paper - remap fix
                         if (BuiltInRegistries.FLUID.getTag(fluidTagKey).isPresent()) {
                             return new CraftFluidTag(BuiltInRegistries.FLUID, fluidTagKey);
                         }
                     }
                     case org.bukkit.Tag.REGISTRY_ENTITY_TYPES -> {
                         Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type");
-                        TagKey<EntityTypes<?>> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key);
+                        TagKey<net.minecraft.world.entity.EntityType<?>> entityTagKey = TagKey.create(Registries.ENTITY_TYPE, key); // Paper - remap fix
                         if (BuiltInRegistries.ENTITY_TYPE.getTag(entityTagKey).isPresent()) {
                             return new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey);
                         }