From b6214c1bffe347d42bc100b4ab540a467abffefa Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 2 Nov 2024 19:16:48 +0800 Subject: [PATCH] Backport some forwarding methods to 1.19 --- .../v1_19_R3/util/CustomEntityRegistry.java | 15 +++++++ .../v1_20_R4/util/CustomEntityRegistry.java | 39 ++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CustomEntityRegistry.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CustomEntityRegistry.java index 2300d743b..a7a20bff3 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CustomEntityRegistry.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CustomEntityRegistry.java @@ -213,6 +213,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> return minecraftClassMap.inverse().get(search); } + @Override + public Registry> freeze() { + return wrapped.freeze(); + } + @Override public MappedRegistry> get() { return wrapped; @@ -326,11 +331,21 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> entityIds.put(entityClass, entityId); } + @Override + public Reference> register(ResourceKey> key, EntityType type, Lifecycle lifecycle) { + return wrapped.register(key, type, lifecycle); + } + @Override public Set>> registryKeySet() { return wrapped.registryKeySet(); } + @Override + public Lifecycle registryLifecycle() { + return wrapped.registryLifecycle(); + } + @Override public void resetTags() { wrapped.resetTags(); diff --git a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/CustomEntityRegistry.java b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/CustomEntityRegistry.java index cddac7ead..e1da83fea 100644 --- a/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/CustomEntityRegistry.java +++ b/v1_20_R4/src/main/java/net/citizensnpcs/nms/v1_20_R4/util/CustomEntityRegistry.java @@ -26,6 +26,7 @@ import net.minecraft.core.HolderLookup.RegistryLookup; import net.minecraft.core.HolderOwner; import net.minecraft.core.HolderSet.Named; import net.minecraft.core.MappedRegistry; +import net.minecraft.core.RegistrationInfo; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -219,6 +220,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> return minecraftClassMap.inverse().get(search); } + @Override + public Registry> freeze() { + return wrapped.freeze(); + } + @Override public MappedRegistry> get() { return wrapped; @@ -246,6 +252,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> return this.wrapped.getHolder(var0); } + @Override + public Optional>> getHolder(ResourceLocation var0) { + return this.wrapped.getHolder(var0); + } + @Override public int getId(EntityType key) { if (entityIds.containsKey(key)) @@ -272,6 +283,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> return this.wrapped.getOptional(var0); } + @Override + public Named> getOrCreateTag(TagKey> var0) { + return this.wrapped.getOrCreateTag(var0); + } + @Override public Optional>> getRandom(RandomSource paramRandom) { return wrapped.getRandom(paramRandom); @@ -317,21 +333,42 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry> return wrapped.iterator(); } + @Override + public ResourceKey>> key() { + return wrapped.key(); + } + @Override public Set keySet() { return wrapped.keySet(); } - public void put(int entityId, ResourceLocation key, EntityType entityClass) { + public void put(int entityId, ResourceLocation key, EntityType entityClass) { entities.put(key, entityClass); entityIds.put(entityClass, entityId); } + @Override + public Reference> register(ResourceKey> key, EntityType type, + RegistrationInfo info) { + return wrapped.register(key, type, info); + } + + @Override + public Optional registrationInfo(ResourceKey> key) { + return wrapped.registrationInfo(key); + } + @Override public Set>> registryKeySet() { return wrapped.registryKeySet(); } + @Override + public Lifecycle registryLifecycle() { + return wrapped.registryLifecycle(); + } + @Override public void resetTags() { wrapped.resetTags();