Implement a few more entity registry methods

This commit is contained in:
fullwall 2022-12-09 19:40:59 +08:00
parent 27d7b2dee3
commit 4212921a98
2 changed files with 32 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Stream;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@ -263,6 +264,16 @@ public class CustomEntityRegistry extends DefaultedRegistry {
return this.wrapped.getTag(var0);
}
@Override
public Stream getTagNames() {
return wrapped.getTagNames();
}
@Override
public Stream getTags() {
return wrapped.getTags();
}
public MappedRegistry<EntityType<?>> getWrapped() {
return wrapped;
}
@ -282,6 +293,11 @@ public class CustomEntityRegistry extends DefaultedRegistry {
entityIds.put(entityClass, entityId);
}
@Override
public int size() {
return wrapped.size();
}
private static final MethodHandle IREGISTRY_CUSTOM_HOLDER_PROVDER = NMS.getFirstGetter(MappedRegistry.class,
Function.class);
private static final MethodHandle IREGISTRY_LIFECYCLE = NMS.getFirstGetter(Registry.class, Lifecycle.class);

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@ -247,11 +248,6 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry {
return this.wrapped.getOptional(var0);
}
@Override
public EntityType getOrThrow(ResourceKey key) {
return wrapped.getOrThrow(key);
}
@Override
public Optional getRandom(RandomSource paramRandom) {
return wrapped.getRandom(paramRandom);
@ -267,6 +263,16 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry {
return this.wrapped.getTag(var0);
}
@Override
public Stream getTagNames() {
return wrapped.getTagNames();
}
@Override
public Stream getTags() {
return wrapped.getTags();
}
public MappedRegistry<EntityType<?>> getWrapped() {
return wrapped;
}
@ -291,6 +297,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry {
return (Set) wrapped.registryKeySet();
}
@Override
public int size() {
return wrapped.size();
}
private static final MethodHandle IREGISTRY_HOLDER_PROVDER = NMS.getGetter(MappedRegistry.class, "m");
private static final MethodHandle IREGISTRY_LIFECYCLE = NMS.getFirstGetter(MappedRegistry.class, Lifecycle.class);
// replace regex .*?> ([A-Z_]+).*?of\((.*?)::new.*?$ minecraftClassMap.put(EntityType.\1, \2.class);