From a0a9b9291a49e09fcc42ff5501c63f3448a8b1c0 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Wed, 7 Dec 2022 21:24:59 -0700 Subject: [PATCH] more compile fixes --- patches/server/Add-GameEvent-tags.patch | 7 ++++--- patches/server/Add-StructuresLocateEvent.patch | 9 ++++++--- .../Added-PlayerLoomPatternSelectEvent.patch | 4 ++-- ...-firing-of-PlayerChangeBeaconEffectEvent.patch | 2 +- patches/server/Cache-block-data-strings.patch | 2 +- patches/server/Expand-Explosions-API.patch | 2 +- .../Implement-EntityKnockbackByEntityEvent.patch | 2 +- ...-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch | 4 ++-- patches/server/Remap-fixes.patch | 15 +++++++++++++++ patches/server/Rewrite-chunk-system.patch | 14 +++++++------- patches/server/Starlight.patch | 2 +- 11 files changed, 41 insertions(+), 22 deletions(-) diff --git a/patches/server/Add-GameEvent-tags.patch b/patches/server/Add-GameEvent-tags.patch index 0e4845e139..59c3354970 100644 --- a/patches/server/Add-GameEvent-tags.patch +++ b/patches/server/Add-GameEvent-tags.patch @@ -12,7 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper; + -+import net.minecraft.core.Registry; ++import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import org.bukkit.GameEvent; @@ -36,12 +37,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final Map> KEY_CACHE = Collections.synchronizedMap(new IdentityHashMap<>()); + @Override + public boolean isTagged(@NotNull GameEvent gameEvent) { -+ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registry.GAME_EVENT_REGISTRY, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag); ++ return registry.getHolderOrThrow(KEY_CACHE.computeIfAbsent(gameEvent, event -> ResourceKey.create(Registries.GAME_EVENT, CraftNamespacedKey.toMinecraft(event.getKey())))).is(tag); + } + + @Override + public @NotNull Set getValues() { -+ return getHandle().stream().map((nms) -> Objects.requireNonNull(GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(Registry.GAME_EVENT.getKey(nms.value()))), nms + " is not a recognized game event")).collect(Collectors.toUnmodifiableSet()); ++ return getHandle().stream().map((nms) -> Objects.requireNonNull(GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(nms.value()))), nms + " is not a recognized game event")).collect(Collectors.toUnmodifiableSet()); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/patches/server/Add-StructuresLocateEvent.patch b/patches/server/Add-StructuresLocateEvent.patch index ecc5f24d75..9ce9d7b9eb 100644 --- a/patches/server/Add-StructuresLocateEvent.patch +++ b/patches/server/Add-StructuresLocateEvent.patch @@ -14,13 +14,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.world.structure.ConfiguredStructure; import net.minecraft.core.Registry; ++import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.levelgen.structure.Structure; import org.bukkit.Keyed; public record RegistryKey(Class apiClass, ResourceKey> resourceKey) { + -+ public static final RegistryKey CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registry.STRUCTURE_REGISTRY); ++ public static final RegistryKey CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registries.STRUCTURE); + } diff --git a/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java b/src/main/java/io/papermc/paper/world/structure/PaperConfiguredStructure.java @@ -34,6 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import io.papermc.paper.registry.PaperRegistry; +import io.papermc.paper.registry.RegistryKey; +import net.minecraft.core.Registry; ++import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.levelgen.structure.Structure; +import org.bukkit.NamespacedKey; @@ -57,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + static final class ConfiguredStructureRegistry extends PaperRegistry { + -+ private static final Supplier> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_REGISTRY); ++ private static final Supplier> STRUCTURE_FEATURE_REGISTRY = registryFor(Registries.STRUCTURE); + + public ConfiguredStructureRegistry() { + super(RegistryKey.CONFIGURED_STRUCTURE_REGISTRY); @@ -65,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public @Nullable ConfiguredStructure convertToApi(NamespacedKey key, Structure nms) { -+ final ResourceLocation structureTypeLoc = Objects.requireNonNull(Registry.STRUCTURE_TYPES.getKey(nms.type()), "unexpected structure type " + nms.type()); ++ final ResourceLocation structureTypeLoc = Objects.requireNonNull(BuiltInRegistries.STRUCTURE_TYPE.getKey(nms.type()), "unexpected structure type " + nms.type()); + final @Nullable StructureType structureType = StructureType.getStructureTypes().get(structureTypeLoc.getPath()); + return structureType == null ? null : new ConfiguredStructure(key, structureType); + } diff --git a/patches/server/Added-PlayerLoomPatternSelectEvent.patch b/patches/server/Added-PlayerLoomPatternSelectEvent.patch index 177fb66f1c..71e55dae76 100644 --- a/patches/server/Added-PlayerLoomPatternSelectEvent.patch +++ b/patches/server/Added-PlayerLoomPatternSelectEvent.patch @@ -31,9 +31,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + if (selectedPattern == null) { -+ for (BannerPattern pattern : Registry.BANNER_PATTERN) { ++ for (BannerPattern pattern : BuiltInRegistries.BANNER_PATTERN) { + if (event.getPatternType().getIdentifier().equals(pattern.getHashname())) { -+ selectedPattern = Registry.BANNER_PATTERN.getHolder(Registry.BANNER_PATTERN.getId(pattern)).orElseThrow(); ++ selectedPattern = BuiltInRegistries.BANNER_PATTERN.getHolder(BuiltInRegistries.BANNER_PATTERN.getId(pattern)).orElseThrow(); + break; + } + } diff --git a/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch index 2df709fc5b..b27ed51bf1 100644 --- a/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch +++ b/patches/server/Added-firing-of-PlayerChangeBeaconEffectEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start + private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional effect) { -+ return effect.flatMap(net.minecraft.core.Registry.MOB_EFFECT::getResourceKey).map(key -> { ++ return effect.flatMap(net.minecraft.core.registries.BuiltInRegistries.MOB_EFFECT::getResourceKey).map(key -> { + return org.bukkit.potion.PotionEffectType.getByKey(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(key.location())); + }).orElse(null); + } diff --git a/patches/server/Cache-block-data-strings.patch b/patches/server/Cache-block-data-strings.patch index a817a2945b..cd5b7c2996 100644 --- a/patches/server/Cache-block-data-strings.patch +++ b/patches/server/Cache-block-data-strings.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (material != null) { + Block block = CraftMagicNumbers.getBlock(material); + if (block != null) { -+ net.minecraft.resources.ResourceLocation key = Registry.BLOCK.getKey(block); ++ net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block); + data = data == null ? key.toString() : key + data; + } + } diff --git a/patches/server/Expand-Explosions-API.patch b/patches/server/Expand-Explosions-API.patch index 755f70f314..40d8483691 100644 --- a/patches/server/Expand-Explosions-API.patch +++ b/patches/server/Expand-Explosions-API.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks) { -+ return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? Explosion.BlockInteraction.BREAK : Explosion.BlockInteraction.NONE).wasCanceled; ++ return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE).wasCanceled; + } + // Paper end diff --git a/patches/server/Implement-EntityKnockbackByEntityEvent.patch b/patches/server/Implement-EntityKnockbackByEntityEvent.patch index a3b4efe711..a6e884f1fd 100644 --- a/patches/server/Implement-EntityKnockbackByEntityEvent.patch +++ b/patches/server/Implement-EntityKnockbackByEntityEvent.patch @@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f; float h = livingEntity.isDamageSourceBlocked(DamageSource.mobAttack(entity)) ? 0.5F : 1.0F; - livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z()); -+ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), goat); // Paper ++ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper this.finishRam(world, entity); world.playSound((Player)null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F); } else if (this.hasRammedHornBreakingBlock(world, entity)) { diff --git a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch index ed80b67ecf..30a65d497a 100644 --- a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch @@ -351,7 +351,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#'; + com.mojang.datafixers.util.Either result; + try { -+ result = net.minecraft.commands.arguments.blocks.BlockStateParser.parseForTesting(net.minecraft.core.Registry.BLOCK, raw, false); ++ result = net.minecraft.commands.arguments.blocks.BlockStateParser.parseForTesting(net.minecraft.core.registries.BuiltInRegistries.BLOCK.asLookup(), raw, false); + } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { + return null; + } @@ -360,7 +360,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (isTag && result.right().isPresent() && result.right().get().tag() instanceof net.minecraft.core.HolderSet.Named namedSet) { + key = namedSet.key().location(); + } else if (result.left().isPresent()) { -+ key = net.minecraft.core.Registry.BLOCK.getKey(result.left().get().blockState().getBlock()); ++ key = net.minecraft.core.registries.BuiltInRegistries.BLOCK.getKey(result.left().get().blockState().getBlock()); + } + + if (key == null) { diff --git a/patches/server/Remap-fixes.patch b/patches/server/Remap-fixes.patch index 45708b222c..1092ba6eeb 100644 --- a/patches/server/Remap-fixes.patch +++ b/patches/server/Remap-fixes.patch @@ -41,6 +41,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } +diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/level/ChunkMap.java ++++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +@@ -0,0 +0,0 @@ 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); + } 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 0628cf58cb..c73bbf9aa9 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -2693,8 +2693,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.core.BlockPos; +import io.papermc.paper.chunk.system.ChunkSystem; +import net.minecraft.server.level.ChunkHolder; -+import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ServerLevel; ++import net.minecraft.util.AbortableIterationConsumer; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; @@ -2872,15 +2872,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public void get(final EntityTypeTest filter, final Consumer action) { ++ public void get(final EntityTypeTest filter, final AbortableIterationConsumer action) { + for (final Entity entity : this.entityById.values()) { + final Visibility visibility = EntityLookup.getEntityStatus(entity); + if (!visibility.isAccessible()) { + continue; + } + final U casted = filter.tryCast(entity); -+ if (casted != null) { -+ action.accept(casted); ++ if (casted != null && action.accept(casted).shouldAbort()) { ++ break; + } + } + } @@ -2895,13 +2895,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public void get(final EntityTypeTest filter, final AABB box, final Consumer action) { ++ public void get(final EntityTypeTest filter, final AABB box, final AbortableIterationConsumer action) { + List entities = new ArrayList<>(); + this.getEntitiesWithoutDragonParts(null, box, entities, null); + for (int i = 0, len = entities.size(); i < len; ++i) { + final U casted = filter.tryCast(entities.get(i)); -+ if (casted != null) { -+ action.accept(casted); ++ if (casted != null && action.accept(casted).shouldAbort()) { ++ break; + } + } + } diff --git a/patches/server/Starlight.patch b/patches/server/Starlight.patch index 311a04b3ca..41e8c1ff94 100644 --- a/patches/server/Starlight.patch +++ b/patches/server/Starlight.patch @@ -4923,7 +4923,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + try { + // We need this otherwise we return EMPTY for invalid names + ResourceLocation key = new ResourceLocation(name); -+ return Registry.CHUNK_STATUS.getOptional(key).orElse(null); ++ return BuiltInRegistries.CHUNK_STATUS.getOptional(key).orElse(null); + } catch (Exception ex) { + return null; // invalid name + }