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

227 lines
13 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
index 17a400bb1710afe0b2c88ba7b0a008d4dbcbfa0c..1a4cab0b9995b733aa84b89129009a99177eee9b 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
@@ -289,9 +289,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 () -> new AbstractIterator<BlockPos>() {
2021-06-15 15:55:25 +02:00
private final BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
private int currentDepth;
@@ -305,7 +307,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;
@@ -331,7 +333,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
}
}
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
2023-12-05 19:38:29 +01:00
index 1915b138ea89790ef8b7456b7fddcbd5d97e5444..ba9f6d288d8773f275e35a9513f7f59ad3f666c0 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) -> {
2023-06-07 18:24:39 +02:00
return ((ServerLevel) entity.level()).getEntity(uuid);
2021-06-11 14:02:28 +02:00
- }).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
2023-12-05 19:38:29 +01:00
index 17c42cfcec69385f0b65e2d42d735e8b8f6e7b04..04adc10f24f96804a5cb14e884224bb672360464 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
2023-12-05 19:38:29 +01:00
@@ -193,7 +193,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
2023-09-21 19:39:51 +02:00
Builder<ResourceLocation, RecipeHolder<?>> builder = ImmutableMap.builder();
2021-06-11 14:02:28 +02:00
2023-09-21 19:39:51 +02:00
recipes.forEach((recipeholder) -> {
- Map<ResourceLocation, RecipeHolder<?>> map1 = (Map) map.computeIfAbsent(recipeholder.value().getType(), (recipes) -> {
+ Map<ResourceLocation, RecipeHolder<?>> map1 = (Map) map.computeIfAbsent(recipeholder.value().getType(), (recipes_) -> { // Paper - remap fix
2021-06-11 14:02:28 +02:00
return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
});
2023-09-21 19:39:51 +02:00
ResourceLocation minecraftkey = recipeholder.id();
2023-09-22 04:31:59 +02:00
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
index 95a5ce711150c4c999a9d17f28a497f034638610..214215d203892b8009595539f25ce26e8752debd 100644
2023-09-22 04:31:59 +02:00
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
@@ -251,8 +251,8 @@ public class LootTable {
2023-09-22 04:31:59 +02:00
public static class Builder implements FunctionUserBuilder<LootTable.Builder> {
- private final Builder<LootPool> pools = ImmutableList.builder();
- private final Builder<LootItemFunction> functions = ImmutableList.builder();
+ private final ImmutableList.Builder<LootPool> pools = ImmutableList.builder();
+ private final ImmutableList.Builder<LootItemFunction> functions = ImmutableList.builder();
private LootContextParamSet paramSet;
private Optional<ResourceLocation> randomSequence;
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
index b70450722da13bc4d358a70d3d1d2f30a2cca2b9..86d86c292bdeeb7f42685691287c3b4bd476ea14 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
@@ -3,7 +3,6 @@ package org.bukkit;
import static org.bukkit.support.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
2021-06-14 02:19:51 +02:00
-import net.minecraft.world.item.DyeColor;
import org.bukkit.support.AbstractTestingBase;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@@ -14,7 +13,7 @@ public class DyeColorsTest extends AbstractTestingBase {
@EnumSource(DyeColor.class)
public void checkColor(DyeColor dye) {
Color color = dye.getColor();
- float[] nmsColorArray = DyeColor.byId(dye.getWoolData()).getTextureDiffuseColors();
+ float[] nmsColorArray = net.minecraft.world.item.DyeColor.byId(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));
}
@@ -23,7 +22,7 @@ public class DyeColorsTest extends AbstractTestingBase {
@EnumSource(org.bukkit.DyeColor.class)
public void checkFireworkColor(org.bukkit.DyeColor dye) {
Color color = dye.getFireworkColor();
- int nmsColor = DyeColor.byId(dye.getWoolData()).getFireworkColor();
+ int nmsColor = net.minecraft.world.item.DyeColor.byId(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/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java
index 1edc58410316eaf45858db56897179587e8b22ee..cf6f34e506570e7bb9624c5899fbcdd762d8e0c4 100644
--- a/src/test/java/org/bukkit/ParticleTest.java
+++ b/src/test/java/org/bukkit/ParticleTest.java
@@ -231,7 +231,7 @@ public class ParticleTest extends AbstractTestingBase {
Check in CraftParticle if the conversion is still correct.
""", bukkit.getKey()));
- DataResult<Tag> encoded = assertDoesNotThrow(() -> minecraft.codec().encodeStart(DynamicOpsNBT.INSTANCE, particleParam),
+ DataResult<Tag> encoded = assertDoesNotThrow(() -> minecraft.codec().encodeStart(NbtOps.INSTANCE, particleParam), // Paper - remap fix
String.format("""
Could not encoded particle param for particle %s.
This can indicated, that the wrong particle param is created in CraftParticle.
2021-06-14 02:19:51 +02:00
diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java
index 32df0090aab65b551b524603cce0b96e461cc358..952924abae79cc504342bbdb6f6953ab8a6cc295 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
@@ -6,7 +6,6 @@ import java.util.Set;
2021-06-14 02:19:51 +02:00
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.jupiter.api.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());
assertNotNull(bukkit, "Missing nms->bukkit " + key);
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
index 5818bfa69a8573a2a8f350066f829d587cbc546b..8e421a1bee0c526e3024eab9ba4cc0b320842de2 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
@@ -2,7 +2,6 @@ package org.bukkit.entity;
import static org.junit.jupiter.api.Assertions.*;
2021-06-14 02:19:51 +02:00
-import net.minecraft.world.entity.animal.Panda;
import org.bukkit.craftbukkit.entity.CraftPanda;
import org.junit.jupiter.api.Test;
@@ -10,8 +9,8 @@ public class PandaGeneTest {
2021-06-14 02:19:51 +02:00
@Test
public void testBukkit() {
- for (Panda.Gene gene : Panda.Gene.values()) {
2021-06-14 02:19:51 +02:00
- Panda.Gene nms = CraftPanda.toNms(gene);
+ for (Panda.Gene gene : Panda.Gene.values()) { // Paper - remap fix
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
assertNotNull(nms, "NMS gene null for " + gene);
assertEquals(gene.isRecessive(), nms.isRecessive(), "Recessive status did not match " + gene);
@@ -21,7 +20,7 @@ public class PandaGeneTest {
2021-06-14 02:19:51 +02:00
@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);
assertNotNull(bukkit, "Bukkit gene null for " + gene);
diff --git a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java
Updated Upstream (Bukkit/CraftBukkit) (#10242) * Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: a6a9d2a4 Remove some old ApiStatus.Experimental annotations be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration 08f86d1c PR-971: Add Player methods for client-side potion effects 2e3024a9 PR-963: Add API for in-world structures a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality 1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent CraftBukkit Changes: 38fd4bd50 Fix accidentally renamed internal damage method 80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage 7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects 4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration 22a541a29 Improve support for per-world game rules cb7dccce2 PR-1348: Add Player methods for client-side potion effects b8d6109f0 PR-1335: Add API for in-world structures 4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity e74107678 Fix Crafter maximum stack size 0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality 4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason 20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette 3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook 333701839 SPIGOT-7572: Bee nests generated without bees f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
index 8abeb88d1514d22b5095153f9537317006f39df0..82a1efcb3aaaceaf12ad21559dec6b5112fcb361 100644
--- a/src/test/java/org/bukkit/registry/RegistryConstantsTest.java
+++ b/src/test/java/org/bukkit/registry/RegistryConstantsTest.java
Updated Upstream (Bukkit/CraftBukkit) (#10242) * Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: a6a9d2a4 Remove some old ApiStatus.Experimental annotations be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration 08f86d1c PR-971: Add Player methods for client-side potion effects 2e3024a9 PR-963: Add API for in-world structures a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality 1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent CraftBukkit Changes: 38fd4bd50 Fix accidentally renamed internal damage method 80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage 7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects 4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration 22a541a29 Improve support for per-world game rules cb7dccce2 PR-1348: Add Player methods for client-side potion effects b8d6109f0 PR-1335: Add API for in-world structures 4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity e74107678 Fix Crafter maximum stack size 0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality 4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason 20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette 3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook 333701839 SPIGOT-7572: Bee nests generated without bees f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
2024-02-11 22:28:00 +01:00
@@ -28,17 +28,17 @@ 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);
}
- private <T extends Keyed> void testExcessConstants(Class<T> clazz, Registry<T> registry) {
+ private <T extends Keyed> void testExcessConstants(Class<T> clazz, org.bukkit.Registry<T> registry) { // Paper - remap fix
List<NamespacedKey> excessKeys = new ArrayList<>();
for (Field field : clazz.getFields()) {
diff --git a/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java b/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java
index b60b07f15fc61b9a92850b2008e2c928b94dbd04..da3eed6f130903bf27eed7e0bcae672a4f860c17 100644
--- a/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java
+++ b/src/test/java/org/bukkit/registry/RegistryLoadOrderTest.java
@@ -22,7 +22,7 @@ public class RegistryLoadOrderTest extends AbstractTestingBase {
private static boolean initInterface = false;
private static boolean initAbstract = false;
- private static Registry<Keyed> registry;
+ private static org.bukkit.Registry<Keyed> registry; // Paper - remap fix
public static Stream<Arguments> data() {
return Stream.of(