mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
More 1.19.3 registry fun (#8618)
This commit is contained in:
parent
0e45eeb9d2
commit
d654558a4e
8 changed files with 20 additions and 19 deletions
|
@ -55,9 +55,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
||||||
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type");
|
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type");
|
||||||
+ TagKey<net.minecraft.world.level.gameevent.GameEvent> gameEventTagKey = TagKey.create(net.minecraft.core.Registry.GAME_EVENT_REGISTRY, key);
|
+ TagKey<net.minecraft.world.level.gameevent.GameEvent> gameEventTagKey = TagKey.create(net.minecraft.core.registries.Registries.GAME_EVENT, key);
|
||||||
+ if (net.minecraft.core.Registry.GAME_EVENT.isKnownTagName(gameEventTagKey)) {
|
+ if (net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getTag(gameEventTagKey).isPresent()) {
|
||||||
+ return (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(net.minecraft.core.Registry.GAME_EVENT, gameEventTagKey);
|
+ return (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT, gameEventTagKey);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
+ case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> {
|
||||||
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class);
|
+ Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class);
|
||||||
+ net.minecraft.core.Registry<net.minecraft.world.level.gameevent.GameEvent> gameEvents = net.minecraft.core.Registry.GAME_EVENT;
|
+ net.minecraft.core.Registry<net.minecraft.world.level.gameevent.GameEvent> gameEvents = net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT;
|
||||||
+ return gameEvents.getTags().map(pair -> (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(gameEvents, pair.getFirst())).collect(ImmutableList.toImmutableList());
|
+ return gameEvents.getTags().map(pair -> (org.bukkit.Tag<T>) new io.papermc.paper.CraftGameEventTag(gameEvents, pair.getFirst())).collect(ImmutableList.toImmutableList());
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -4,7 +4,7 @@ Date: Sat, 15 Oct 2022 00:46:57 +0200
|
||||||
Subject: [PATCH] Add Player Warden Warning API
|
Subject: [PATCH] Add Player Warden Warning API
|
||||||
|
|
||||||
== AT ==
|
== AT ==
|
||||||
public net.minecraft.world.entity.player.Player wardenSpawnTracker
|
public net.minecraft.server.level.ServerPlayer wardenSpawnTracker
|
||||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker ticksSinceLastWarning
|
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker ticksSinceLastWarning
|
||||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker cooldownTicks
|
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker cooldownTicks
|
||||||
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker increaseWarningLevel()V
|
public net.minecraft.world.entity.monster.warden.WardenSpawnTracker increaseWarningLevel()V
|
||||||
|
|
|
@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import net.kyori.adventure.text.TextComponent;
|
+import net.kyori.adventure.text.TextComponent;
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
+import net.kyori.adventure.text.format.TextColor;
|
+import net.kyori.adventure.text.format.TextColor;
|
||||||
+import net.minecraft.core.Registry;
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
+import net.minecraft.server.level.ServerPlayer;
|
+import net.minecraft.server.level.ServerPlayer;
|
||||||
+import net.minecraft.world.entity.MobCategory;
|
+import net.minecraft.world.entity.MobCategory;
|
||||||
|
@ -225,7 +225,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ Component.text(':', NamedTextColor.GRAY),
|
+ Component.text(':', NamedTextColor.GRAY),
|
||||||
+ Component.newline(),
|
+ Component.newline(),
|
||||||
+ Component.newline(),
|
+ Component.newline(),
|
||||||
+ Registry.ENTITY_TYPE.entrySet().stream()
|
+ BuiltInRegistries.ENTITY_TYPE.entrySet().stream()
|
||||||
+ .filter(it -> it.getValue().getCategory() == category)
|
+ .filter(it -> it.getValue().getCategory() == category)
|
||||||
+ .map(it -> Component.translatable(it.getValue().getDescriptionId()))
|
+ .map(it -> Component.translatable(it.getValue().getDescriptionId()))
|
||||||
+ .collect(Component.toComponent(Component.text(", ", NamedTextColor.GRAY)))
|
+ .collect(Component.toComponent(Component.text(", ", NamedTextColor.GRAY)))
|
||||||
|
|
|
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public ChunkGenerator.ChunkData createVanillaChunkData(World world, int x, int z) {
|
+ public ChunkGenerator.ChunkData createVanillaChunkData(World world, int x, int z) {
|
||||||
+ // do bunch of vanilla shit
|
+ // do bunch of vanilla shit
|
||||||
+ final net.minecraft.server.level.ServerLevel serverLevel = ((CraftWorld) world).getHandle();
|
+ final net.minecraft.server.level.ServerLevel serverLevel = ((CraftWorld) world).getHandle();
|
||||||
+ final net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> biomeRegistry = serverLevel.getServer().registryAccess().registryOrThrow(net.minecraft.core.Registry.BIOME_REGISTRY);
|
+ final net.minecraft.core.Registry<net.minecraft.world.level.biome.Biome> biomeRegistry = serverLevel.getServer().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME);
|
||||||
+ final net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(
|
+ final net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(
|
||||||
+ new net.minecraft.world.level.ChunkPos(x, z),
|
+ new net.minecraft.world.level.ChunkPos(x, z),
|
||||||
+ net.minecraft.world.level.chunk.UpgradeData.EMPTY,
|
+ net.minecraft.world.level.chunk.UpgradeData.EMPTY,
|
||||||
|
@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (xx == chunkPos.x && zz == chunkPos.z) {
|
+ if (xx == chunkPos.x && zz == chunkPos.z) {
|
||||||
+ chunks.add(protoChunk);
|
+ chunks.add(protoChunk);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ final net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeHolder = serverLevel.registryAccess().registryOrThrow(net.minecraft.core.Registry.BIOME_REGISTRY).getHolderOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
|
+ final net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeHolder = serverLevel.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.BIOME).getHolderOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS);
|
||||||
+ final net.minecraft.world.level.chunk.ChunkAccess chunk = new net.minecraft.world.level.chunk.EmptyLevelChunk(serverLevel, new net.minecraft.world.level.ChunkPos(xx, zz), biomeHolder);
|
+ final net.minecraft.world.level.chunk.ChunkAccess chunk = new net.minecraft.world.level.chunk.EmptyLevelChunk(serverLevel, new net.minecraft.world.level.ChunkPos(xx, zz), biomeHolder);
|
||||||
+ chunks.add(chunk);
|
+ chunks.add(chunk);
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -209,7 +209,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import io.papermc.paper.configuration.type.EngineMode;
|
+import io.papermc.paper.configuration.type.EngineMode;
|
||||||
+import net.minecraft.core.BlockPos;
|
+import net.minecraft.core.BlockPos;
|
||||||
+import net.minecraft.core.Direction;
|
+import net.minecraft.core.Direction;
|
||||||
+import net.minecraft.core.Registry;
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
+import net.minecraft.core.registries.Registries;
|
||||||
+import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
+import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
|
||||||
+import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
+import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -284,7 +285,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ List<BlockState> presetBlockStateList = new LinkedList<>();
|
+ List<BlockState> presetBlockStateList = new LinkedList<>();
|
||||||
+
|
+
|
||||||
+ for (String id : paperWorldConfig.hiddenBlocks) {
|
+ for (String id : paperWorldConfig.hiddenBlocks) {
|
||||||
+ Block block = Registry.BLOCK.getOptional(new ResourceLocation(id)).orElse(null);
|
+ Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(id)).orElse(null);
|
||||||
+
|
+
|
||||||
+ if (block != null && !(block instanceof EntityBlock)) {
|
+ if (block != null && !(block instanceof EntityBlock)) {
|
||||||
+ toObfuscate.add(id);
|
+ toObfuscate.add(id);
|
||||||
|
@ -315,7 +316,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for (String id : toObfuscate) {
|
+ for (String id : toObfuscate) {
|
||||||
+ Block block = Registry.BLOCK.getOptional(new ResourceLocation(id)).orElse(null);
|
+ Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(id)).orElse(null);
|
||||||
+
|
+
|
||||||
+ // Don't obfuscate air because air causes unnecessary block updates and causes block updates to fail in the void
|
+ // Don't obfuscate air because air causes unnecessary block updates and causes block updates to fail in the void
|
||||||
+ if (block != null && !block.defaultBlockState().isAir()) {
|
+ if (block != null && !block.defaultBlockState().isAir()) {
|
||||||
|
@ -326,7 +327,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ EmptyLevelChunk emptyChunk = new EmptyLevelChunk(level, new ChunkPos(0, 0), MinecraftServer.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getHolderOrThrow(Biomes.PLAINS));
|
+ EmptyLevelChunk emptyChunk = new EmptyLevelChunk(level, new ChunkPos(0, 0), MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.BIOME).getHolderOrThrow(Biomes.PLAINS));
|
||||||
+ BlockPos zeroPos = new BlockPos(0, 0, 0);
|
+ BlockPos zeroPos = new BlockPos(0, 0, 0);
|
||||||
+
|
+
|
||||||
+ for (int i = 0; i < solidGlobal.length; i++) {
|
+ for (int i = 0; i < solidGlobal.length; i++) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
- world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||||
+ // Paper start - option to use the dimension_type to check if spawners should be added. I imagine mojang will add some datapack-y way of managing this in the future.
|
+ // Paper start - option to use the dimension_type to check if spawners should be added. I imagine mojang will add some datapack-y way of managing this in the future.
|
||||||
+ final List<CustomSpawner> spawners;
|
+ final List<CustomSpawner> spawners;
|
||||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.useDimensionTypeForCustomSpawners && this.registryHolder.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(worlddimension.typeHolder().value()).orElseThrow() == net.minecraft.world.level.dimension.BuiltinDimensionTypes.OVERWORLD) {
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.useDimensionTypeForCustomSpawners && this.registryAccess().registryOrThrow(Registries.DIMENSION_TYPE).getResourceKey(worlddimension.type().value()).orElseThrow() == net.minecraft.world.level.dimension.BuiltinDimensionTypes.OVERWORLD) {
|
||||||
+ spawners = list;
|
+ spawners = list;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ spawners = Collections.emptyList();
|
+ spawners = Collections.emptyList();
|
||||||
|
|
|
@ -302,7 +302,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import java.util.Map;
|
+import java.util.Map;
|
||||||
+import java.util.Set;
|
+import java.util.Set;
|
||||||
+import java.util.stream.Collectors;
|
+import java.util.stream.Collectors;
|
||||||
+import net.minecraft.core.Registry;
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
+import net.minecraft.server.level.ServerChunkCache;
|
+import net.minecraft.server.level.ServerChunkCache;
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -335,7 +335,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (args.length == 1) {
|
+ if (args.length == 1) {
|
||||||
+ return CommandUtil.getListMatchingLast(sender, args, "help", "list");
|
+ return CommandUtil.getListMatchingLast(sender, args, "help", "list");
|
||||||
+ } else if (args.length == 2) {
|
+ } else if (args.length == 2) {
|
||||||
+ return CommandUtil.getListMatchingLast(sender, args, Registry.ENTITY_TYPE.keySet().stream().map(ResourceLocation::toString).sorted().toArray(String[]::new));
|
+ return CommandUtil.getListMatchingLast(sender, args, BuiltInRegistries.ENTITY_TYPE.keySet().stream().map(ResourceLocation::toString).sorted().toArray(String[]::new));
|
||||||
+ }
|
+ }
|
||||||
+ return Collections.emptyList();
|
+ return Collections.emptyList();
|
||||||
+ }
|
+ }
|
||||||
|
@ -360,7 +360,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ filter = args[1];
|
+ filter = args[1];
|
||||||
+ }
|
+ }
|
||||||
+ final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?");
|
+ final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?");
|
||||||
+ Set<ResourceLocation> names = Registry.ENTITY_TYPE.keySet().stream()
|
+ Set<ResourceLocation> names = BuiltInRegistries.ENTITY_TYPE.keySet().stream()
|
||||||
+ .filter(n -> n.toString().matches(cleanfilter))
|
+ .filter(n -> n.toString().matches(cleanfilter))
|
||||||
+ .collect(Collectors.toSet());
|
+ .collect(Collectors.toSet());
|
||||||
+ if (names.isEmpty()) {
|
+ if (names.isEmpty()) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import java.util.Objects;
|
+import java.util.Objects;
|
||||||
+import net.kyori.adventure.text.Component;
|
+import net.kyori.adventure.text.Component;
|
||||||
+import net.kyori.adventure.text.event.ClickEvent;
|
+import net.kyori.adventure.text.event.ClickEvent;
|
||||||
+import net.minecraft.core.Registry;
|
+import net.minecraft.core.registries.Registries;
|
||||||
+import net.minecraft.nbt.CompoundTag;
|
+import net.minecraft.nbt.CompoundTag;
|
||||||
+import net.minecraft.world.item.ItemStack;
|
+import net.minecraft.world.item.ItemStack;
|
||||||
+import org.bukkit.Bukkit;
|
+import org.bukkit.Bukkit;
|
||||||
|
@ -73,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ final @Nullable CompoundTag tag = itemStack.getTag();
|
+ final @Nullable CompoundTag tag = itemStack.getTag();
|
||||||
+ final @Nullable Component nbtComponent = tag == null ? null : PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag));
|
+ final @Nullable Component nbtComponent = tag == null ? null : PaperAdventure.asAdventure(net.minecraft.nbt.NbtUtils.toPrettyComponent(tag));
|
||||||
+ final String itemId = Objects.requireNonNull(((CraftWorld) ((CraftPlayer) sender).getWorld()).getHandle().registryAccess()
|
+ final String itemId = Objects.requireNonNull(((CraftWorld) ((CraftPlayer) sender).getWorld()).getHandle().registryAccess()
|
||||||
+ .registryOrThrow(Registry.ITEM_REGISTRY).getKey(itemStack.getItem())).toString();
|
+ .registryOrThrow(Registries.ITEM).getKey(itemStack.getItem())).toString();
|
||||||
+ final Component message = text()
|
+ final Component message = text()
|
||||||
+ .append(text(itemId, YELLOW))
|
+ .append(text(itemId, YELLOW))
|
||||||
+ .apply(b -> {
|
+ .apply(b -> {
|
||||||
|
|
Loading…
Reference in a new issue