more compile fixes

This commit is contained in:
Jason Penilla 2022-12-07 21:24:59 -07:00
parent 6e1deb99aa
commit a0a9b9291a
11 changed files with 41 additions and 22 deletions

View file

@ -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<GameEvent, ResourceKey<net.minecraft.world.level.gameevent.GameEvent>> 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<GameEvent> 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

View file

@ -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<API extends Keyed, MINECRAFT>(Class<API> apiClass, ResourceKey<? extends Registry<MINECRAFT>> resourceKey) {
+
+ public static final RegistryKey<ConfiguredStructure, Structure> CONFIGURED_STRUCTURE_REGISTRY = new RegistryKey<>(ConfiguredStructure.class, Registry.STRUCTURE_REGISTRY);
+ public static final RegistryKey<ConfiguredStructure, Structure> 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<ConfiguredStructure, Structure> {
+
+ private static final Supplier<Registry<Structure>> STRUCTURE_FEATURE_REGISTRY = registryFor(Registry.STRUCTURE_REGISTRY);
+ private static final Supplier<Registry<Structure>> 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);
+ }

View file

@ -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;
+ }
+ }

View file

@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ // Paper start
+ private static @Nullable org.bukkit.potion.PotionEffectType convert(Optional<MobEffect> 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);
+ }

View file

@ -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;
+ }
+ }

View file

@ -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

View file

@ -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)) {

View file

@ -351,7 +351,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#';
+ com.mojang.datafixers.util.Either<net.minecraft.commands.arguments.blocks.BlockStateParser.BlockResult, net.minecraft.commands.arguments.blocks.BlockStateParser.TagResult> 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<net.minecraft.world.level.block.Block> 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) {

View file

@ -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

View file

@ -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 <U extends Entity> void get(final EntityTypeTest<Entity, U> filter, final Consumer<U> action) {
+ public <U extends Entity> void get(final EntityTypeTest<Entity, U> filter, final AbortableIterationConsumer<U> 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 <U extends Entity> void get(final EntityTypeTest<Entity, U> filter, final AABB box, final Consumer<U> action) {
+ public <U extends Entity> void get(final EntityTypeTest<Entity, U> filter, final AABB box, final AbortableIterationConsumer<U> action) {
+ List<Entity> 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;
+ }
+ }
+ }

View file

@ -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
+ }