mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 08:02:13 -07:00
Move patches around
This commit is contained in:
110
patches/server-remapped/Implement-Keyed-on-World.patch
Normal file
110
patches/server-remapped/Implement-Keyed-on-World.patch
Normal file
@@ -0,0 +1,110 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 6 Jan 2021 00:34:04 -0800
|
||||
Subject: [PATCH] Implement Keyed on World
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Registry.java b/src/main/java/net/minecraft/core/Registry.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/core/Registry.java
|
||||
+++ b/src/main/java/net/minecraft/core/Registry.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
|
||||
public static final ResourceKey<Registry<LootItemFunctionType>> LOOT_FUNCTION_REGISTRY = createRegistryKey("loot_function_type");
|
||||
public static final ResourceKey<Registry<LootItemConditionType>> LOOT_ITEM_REGISTRY = createRegistryKey("loot_condition_type");
|
||||
public static final ResourceKey<Registry<DimensionType>> DIMENSION_TYPE_REGISTRY = createRegistryKey("dimension_type");
|
||||
- public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension");
|
||||
+ public static final ResourceKey<Registry<Level>> DIMENSION_REGISTRY = createRegistryKey("dimension"); public static final ResourceKey<Registry<Level>> getWorldRegistry() { return DIMENSION_REGISTRY; } // Paper - OBFHELPER
|
||||
public static final ResourceKey<Registry<LevelStem>> LEVEL_STEM_REGISTRY = createRegistryKey("dimension");
|
||||
public static final Registry<SoundEvent> SOUND_EVENT = registerSimple(Registry.SOUND_EVENT_REGISTRY, () -> {
|
||||
return SoundEvents.ITEM_PICKUP;
|
||||
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
|
||||
ResourceLocation minecraftkey = resourcekey.location();
|
||||
|
||||
Registry.LOADERS.put(minecraftkey, defaultEntry);
|
||||
- WritableRegistry<R> iregistrywritable = Registry.WRITABLE_REGISTRY;
|
||||
+ WritableRegistry iregistrywritable = Registry.WRITABLE_REGISTRY; // Paper - decompile fix
|
||||
|
||||
- return (WritableRegistry) iregistrywritable.register(resourcekey, (Object) registry, lifecycle);
|
||||
+ return (R) iregistrywritable.register(resourcekey, (Object) registry, lifecycle); // Paper - decompile fix
|
||||
}
|
||||
|
||||
protected Registry(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle) {
|
||||
@@ -0,0 +0,0 @@ public abstract class Registry<T> implements Codec<T>, Keyable, IdMap<T> {
|
||||
}
|
||||
|
||||
public static <V, T extends V> T register(Registry<V> registry, ResourceLocation id, T entry) {
|
||||
- return ((WritableRegistry) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable());
|
||||
+ return ((WritableRegistry<V>) registry).register(ResourceKey.create(registry.key, id), entry, Lifecycle.stable()); // Paper - decompile fix
|
||||
}
|
||||
|
||||
public static <V, T extends V> T registerMapping(Registry<V> registry, int rawId, String id, T entry) {
|
||||
- return ((WritableRegistry) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable());
|
||||
+ return ((WritableRegistry<V>) registry).registerMapping(rawId, ResourceKey.create(registry.key, new ResourceLocation(id)), entry, Lifecycle.stable()); // Paper - decompile fix
|
||||
}
|
||||
|
||||
static {
|
||||
diff --git a/src/main/java/net/minecraft/resources/ResourceKey.java b/src/main/java/net/minecraft/resources/ResourceKey.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/resources/ResourceKey.java
|
||||
+++ b/src/main/java/net/minecraft/resources/ResourceKey.java
|
||||
@@ -0,0 +0,0 @@ public class ResourceKey<T> {
|
||||
private final ResourceLocation registryName;
|
||||
private final ResourceLocation location;
|
||||
|
||||
+ public static <T> ResourceKey<T> newResourceKey(ResourceKey<? extends Registry<T>> registryKey, ResourceLocation minecraftKey) { return create(registryKey, minecraftKey); } // Paper - OBFHELPER
|
||||
public static <T> ResourceKey<T> create(ResourceKey<? extends Registry<T>> registry, ResourceLocation value) {
|
||||
return create(registry.location, value);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class ResourceKey<T> {
|
||||
return this.registryName.equals(registry.location());
|
||||
}
|
||||
|
||||
+ public ResourceLocation getLocation() { return location(); } // Paper - OBFHELPER
|
||||
public ResourceLocation location() {
|
||||
return this.location;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
} else if (name.equals(levelName + "_the_end")) {
|
||||
worldKey = net.minecraft.world.level.Level.END;
|
||||
} else {
|
||||
- worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(name.toLowerCase(java.util.Locale.ENGLISH)));
|
||||
+ worldKey = ResourceKey.newResourceKey(Registry.getWorldRegistry(), new net.minecraft.resources.ResourceLocation(creator.key().getNamespace().toLowerCase(java.util.Locale.ENGLISH), creator.key().getKey().toLowerCase(java.util.Locale.ENGLISH))); // Paper
|
||||
}
|
||||
|
||||
ServerLevel internal = (ServerLevel) new ServerLevel(console, console.executor, worldSession, worlddata, worldKey, dimensionmanager, getServer().progressListenerFactory.create(11),
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
return null;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public World getWorld(NamespacedKey worldKey) {
|
||||
+ ServerLevel worldServer = console.getLevel(ResourceKey.newResourceKey(Registry.getWorldRegistry(), CraftNamespacedKey.toMinecraft(worldKey)));
|
||||
+ if (worldServer == null) return null;
|
||||
+ return worldServer.getWorld();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void addWorld(World world) {
|
||||
// Check if a World already exists with the UID.
|
||||
if (getWorld(world.getUID()) != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
return CompletableFuture.completedFuture(chunk == null ? null : chunk.getBukkitChunk());
|
||||
}, net.minecraft.server.MinecraftServer.getServer());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.NamespacedKey getKey() {
|
||||
+ return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(world.dimension().getLocation());
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
// Spigot start
|
Reference in New Issue
Block a user