Backport some forwarding methods to 1.19

This commit is contained in:
fullwall 2024-11-02 19:16:48 +08:00
parent f92fb4373f
commit b6214c1bff
2 changed files with 53 additions and 1 deletions

View File

@ -213,6 +213,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
return minecraftClassMap.inverse().get(search);
}
@Override
public Registry<EntityType<?>> freeze() {
return wrapped.freeze();
}
@Override
public MappedRegistry<EntityType<?>> get() {
return wrapped;
@ -326,11 +331,21 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
entityIds.put(entityClass, entityId);
}
@Override
public Reference<EntityType<?>> register(ResourceKey<EntityType<?>> key, EntityType<?> type, Lifecycle lifecycle) {
return wrapped.register(key, type, lifecycle);
}
@Override
public Set<ResourceKey<EntityType<?>>> registryKeySet() {
return wrapped.registryKeySet();
}
@Override
public Lifecycle registryLifecycle() {
return wrapped.registryLifecycle();
}
@Override
public void resetTags() {
wrapped.resetTags();

View File

@ -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<EntityType<?>>
return minecraftClassMap.inverse().get(search);
}
@Override
public Registry<EntityType<?>> freeze() {
return wrapped.freeze();
}
@Override
public MappedRegistry<EntityType<?>> get() {
return wrapped;
@ -246,6 +252,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
return this.wrapped.getHolder(var0);
}
@Override
public Optional<Reference<EntityType<?>>> 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<EntityType<?>>
return this.wrapped.getOptional(var0);
}
@Override
public Named<EntityType<?>> getOrCreateTag(TagKey<EntityType<?>> var0) {
return this.wrapped.getOrCreateTag(var0);
}
@Override
public Optional<Reference<EntityType<?>>> getRandom(RandomSource paramRandom) {
return wrapped.getRandom(paramRandom);
@ -317,21 +333,42 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
return wrapped.iterator();
}
@Override
public ResourceKey<? extends Registry<EntityType<?>>> key() {
return wrapped.key();
}
@Override
public Set<ResourceLocation> 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<EntityType<?>> register(ResourceKey<EntityType<?>> key, EntityType<?> type,
RegistrationInfo info) {
return wrapped.register(key, type, info);
}
@Override
public Optional<RegistrationInfo> registrationInfo(ResourceKey<EntityType<?>> key) {
return wrapped.registrationInfo(key);
}
@Override
public Set<ResourceKey<EntityType<?>>> registryKeySet() {
return wrapped.registryKeySet();
}
@Override
public Lifecycle registryLifecycle() {
return wrapped.registryLifecycle();
}
@Override
public void resetTags() {
wrapped.resetTags();