Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 11:00:06 +01:00
158 Zeilen
8.6 KiB
Diff
158 Zeilen
8.6 KiB
Diff
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 0612eef6d9a9cda81a8d761be2b5e9b094388270..77bf6865c6df829c5b5455d440cb2222a0d8f2af 100644
|
|
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
|
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
|
@@ -265,9 +265,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();
|
|
@@ -282,7 +284,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;
|
|
@@ -308,7 +310,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 1206ca32cadb98573938328f611b67162c700d84..d81f7eecb8204a974da14a75d1a7a23a6c071112 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/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java
|
|
index b1de312e902c83a2f95d80040abb9255e64431a9..aafa6f472c82f851fe7f5ae3111488bb732d0bcc 100644
|
|
--- 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;
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
-import net.minecraft.world.entity.EntityType;
|
|
import org.bukkit.support.AbstractTestingBase;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
@@ -16,8 +15,8 @@ public class EntityTypesTest extends AbstractTestingBase {
|
|
public void testMaps() {
|
|
Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet());
|
|
|
|
- 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);
|