Paper/patches/server/0002-Remap-fixes.patch

173 lines
9.4 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kyle Wood <kyle@denwav.dev>
Date: Fri, 11 Jun 2021 05:25:03 -0500
2021-06-17 03:43:30 +02:00
Subject: [PATCH] Remap fixes
2021-06-11 14:02:28 +02:00
2021-06-15 15:55:25 +02:00
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
2022-12-07 18:08:55 +01:00
index 954cf20fb9fbf331fe6314590a3edbe73118ceca..d4c46f44f7a998121482c2fc56d7986881d489d8 100644
2021-06-15 15:55:25 +02:00
--- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java
2022-12-07 18:08:55 +01:00
@@ -274,9 +274,11 @@ public class BlockPos extends Vec3i {
2021-06-15 15:55:25 +02:00
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();
2021-06-17 03:43:30 +02:00
+ // Paper start - rename variables to fix conflict with anonymous class (remap fix)
2021-06-15 15:55:25 +02:00
+ 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();
2022-12-07 18:08:55 +01:00
@@ -291,7 +293,7 @@ public class BlockPos extends Vec3i {
2021-06-15 15:55:25 +02:00
protected BlockPos computeNext() {
if (this.zMirror) {
this.zMirror = false;
- this.cursor.setZ(l - (this.cursor.getZ() - l));
2021-06-17 03:43:30 +02:00
+ this.cursor.setZ(centerZ - (this.cursor.getZ() - centerZ)); // Paper - remap fix
2021-06-15 15:55:25 +02:00
return this.cursor;
} else {
BlockPos blockPos;
2022-12-07 18:08:55 +01:00
@@ -317,7 +319,7 @@ public class BlockPos extends Vec3i {
2021-06-15 15:55:25 +02:00
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);
2021-06-17 03:43:30 +02:00
+ blockPos = this.cursor.set(centerX + i, centerY + j, centerZ + k); // Paper - remap fix
2021-06-15 15:55:25 +02:00
}
}
2022-12-08 05:24:59 +01:00
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
2022-12-08 19:23:12 +01:00
index b1ecaf47486eaa876e2286eae894b47ecf3a0849..01438ee9ad7a64ac4fd124d97029f87b49c25d5d 100644
2022-12-08 05:24:59 +01:00
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1419,9 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
LevelChunk chunk1;
if (chunk instanceof LevelChunk) {
- LevelChunk chunk1 = (LevelChunk) chunk;
-
- chunk1 = chunk1;
+ chunk1 = (LevelChunk) chunk; // Paper - remap fix
} else {
chunk1 = this.level.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
}
2021-06-11 14:02:28 +02:00
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
2022-12-07 18:08:55 +01:00
index 8f0a2f8d3a34c6b97bc7a933272ccf2689576c76..b9fcff8862e624644fdb73afcb3ef2106b0a76fc 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
2022-12-07 18:08:55 +01:00
@@ -173,11 +173,11 @@ public class BehaviorUtils {
2021-06-11 14:02:28 +02:00
return optional.map((uuid) -> {
return ((ServerLevel) entity.level).getEntity(uuid);
- }).map((entity) -> {
2021-11-23 09:57:41 +01:00
+ }).map((entity1) -> { // Paper - remap fix
LivingEntity entityliving1;
2021-06-11 14:02:28 +02:00
2021-11-23 09:57:41 +01:00
- if (entity instanceof LivingEntity) {
- LivingEntity entityliving2 = (LivingEntity) entity;
+ if (entity1 instanceof LivingEntity) { // Paper - remap fix
+ LivingEntity entityliving2 = (LivingEntity) entity1; // Paper - remap fix
2021-06-11 14:02:28 +02:00
2021-11-23 09:57:41 +01:00
entityliving1 = entityliving2;
} else {
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
2022-12-07 18:08:55 +01:00
index 0b76584d85194f0b60ed51f577353bfead0489f5..d025df087e7b87fbc89a722226f2f2263c54ac47 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
2022-06-07 20:12:34 +02:00
@@ -192,7 +192,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
Builder<ResourceLocation, Recipe<?>> builder = ImmutableMap.builder();
2021-06-11 14:02:28 +02:00
recipes.forEach((irecipe) -> {
- Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
2021-06-17 03:43:30 +02:00
+ Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes_) -> { // Paper - remap fix
2021-06-11 14:02:28 +02:00
return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
});
ResourceLocation minecraftkey = irecipe.getId();
2021-06-14 02:19:51 +02:00
diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java
2021-06-17 03:43:30 +02:00
index ad52c3fc6210939a39ef77a382c640a24ee44838..6b7dd01778f0a5d3a96d2d04af4b525d17efbfba 100644
2021-06-14 02:19:51 +02:00
--- 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();
2021-06-17 03:43:30 +02:00
+ float[] nmsColorArray = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getTextureDiffuseColors(); // Paper - remap fix
2021-06-14 02:19:51 +02:00
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();
2021-06-17 03:43:30 +02:00
+ int nmsColor = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getFireworkColor(); // Paper - remap fix
2021-06-14 02:19:51 +02:00
assertThat(color, is(Color.fromRGB(nmsColor)));
}
}
diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java
2022-12-08 19:23:12 +01:00
index f0333f01dddb2808eeaa796d9284d5cb3ad4934c..b2efb294822c53768bde38e7a78c7b8f093481e9 100644
2021-06-14 02:19:51 +02:00
--- a/src/test/java/org/bukkit/entity/EntityTypesTest.java
+++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java
@@ -5,7 +5,6 @@ import java.util.Set;
import java.util.stream.Collectors;
2022-12-07 18:08:55 +01:00
import net.minecraft.core.registries.BuiltInRegistries;
2021-06-14 02:19:51 +02:00
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.entity.EntityType;
import org.bukkit.support.AbstractTestingBase;
import org.junit.Assert;
import org.junit.Test;
2022-12-08 19:23:12 +01:00
@@ -16,8 +15,8 @@ public class EntityTypesTest extends AbstractTestingBase {
2021-06-14 02:19:51 +02:00
public void testMaps() {
Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet());
2022-12-07 18:08:55 +01:00
- for (EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) {
2022-12-08 19:23:12 +01:00
- ResourceLocation key = EntityType.getKey(nms);
2022-12-07 18:08:55 +01:00
+ for (net.minecraft.world.entity.EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) { // Paper - remap fix
2022-12-08 19:23:12 +01:00
+ ResourceLocation key = net.minecraft.world.entity.EntityType.getKey(nms); // Paper - remap fix
2021-06-14 02:19:51 +02:00
org.bukkit.entity.EntityType bukkit = org.bukkit.entity.EntityType.fromName(key.getPath());
2022-12-08 19:23:12 +01:00
Assert.assertNotNull("Missing nms->bukkit " + key, bukkit);
2021-06-14 02:19:51 +02:00
diff --git a/src/test/java/org/bukkit/entity/PandaGeneTest.java b/src/test/java/org/bukkit/entity/PandaGeneTest.java
2021-06-17 03:43:30 +02:00
index 76e2ad676ae68846bdff3c3ef711751445fb0f3c..feee17192bca55a9cf1b2fc5b9609b888db77763 100644
2021-06-14 02:19:51 +02:00
--- 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);
2021-06-17 03:43:30 +02:00
+ net.minecraft.world.entity.animal.Panda.Gene nms = CraftPanda.toNms(gene); // Paper - remap fix
2021-06-14 02:19:51 +02:00
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()) {
2021-06-17 03:43:30 +02:00
+ for (net.minecraft.world.entity.animal.Panda.Gene gene : net.minecraft.world.entity.animal.Panda.Gene.values()) { // Paper - remap fix
2021-06-14 02:19:51 +02:00
org.bukkit.entity.Panda.Gene bukkit = CraftPanda.fromNms(gene);
Assert.assertNotNull("Bukkit gene null for " + gene, bukkit);