mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-22 09:07:56 +01:00
Backport a few more methods
This commit is contained in:
parent
b6214c1bff
commit
93b87d35ad
@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -37,11 +38,26 @@ public class CustomEntityRegistry extends RegistryMaterials implements Supplier<
|
||||
return wrapped.a(paramRandom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftKey b() {
|
||||
return wrapped.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c(MinecraftKey paramK) {
|
||||
return wrapped.c(paramK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d() {
|
||||
return wrapped.d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<EntityTypes<?>> f() {
|
||||
return wrapped.f();
|
||||
}
|
||||
|
||||
public EntityTypes findType(Class<?> search) {
|
||||
for (Object type : wrapped) {
|
||||
if (((EntityTypes) type).c() == search)
|
||||
|
@ -6,6 +6,7 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -25,6 +26,11 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
this.wrapped = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftKey a() {
|
||||
return wrapped.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int a(Object key) {
|
||||
if (entityIds.containsKey(key))
|
||||
@ -37,6 +43,16 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
return wrapped.a(paramRandom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c() {
|
||||
return wrapped.c();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<EntityTypes<?>> d() {
|
||||
return wrapped.d();
|
||||
}
|
||||
|
||||
public EntityTypes findType(Class<?> search) {
|
||||
return minecraftClassMap.inverse().get(search);
|
||||
/*
|
||||
|
@ -6,6 +6,7 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -25,6 +26,11 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
this.wrapped = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftKey a() {
|
||||
return wrapped.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int a(Object key) {
|
||||
if (entityIds.containsKey(key))
|
||||
@ -37,6 +43,16 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
return wrapped.a(paramRandom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c() {
|
||||
return wrapped.c();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<EntityTypes<?>> d() {
|
||||
return wrapped.d();
|
||||
}
|
||||
|
||||
public EntityTypes findType(Class<?> search) {
|
||||
return minecraftClassMap.inverse().get(search);
|
||||
/*
|
||||
|
@ -3,10 +3,12 @@ package net.citizensnpcs.nms.v1_16_R3.util;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -31,6 +33,11 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
this.wrapped = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftKey a() {
|
||||
return wrapped.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int a(Object key) {
|
||||
if (entityIds.containsKey(key))
|
||||
@ -48,16 +55,31 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
return wrapped.a(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle b() {
|
||||
return wrapped.b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional c(Object key) {
|
||||
return wrapped.c((EntityTypes<?>) key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<ResourceKey<EntityTypes<?>>, EntityTypes<?>>> d() {
|
||||
return wrapped.d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object d(ResourceKey key) {
|
||||
return wrapped.d(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceKey<? extends IRegistry<EntityTypes<?>>> f() {
|
||||
return wrapped.f();
|
||||
}
|
||||
|
||||
public EntityTypes findType(Class<?> search) {
|
||||
return minecraftClassMap.inverse().get(search);
|
||||
/*
|
||||
@ -75,6 +97,11 @@ public class CustomEntityRegistry extends RegistryBlocks implements Supplier<Reg
|
||||
return this.wrapped.fromId(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<EntityTypes<?>> g() {
|
||||
return wrapped.g();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryBlocks<EntityTypes<?>> get() {
|
||||
return wrapped;
|
||||
|
@ -7,6 +7,7 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -162,6 +163,11 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
return this.wrapped.containsKey(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle elementsLifecycle() {
|
||||
return wrapped.elementsLifecycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> entrySet() {
|
||||
return (Set) wrapped.entrySet();
|
||||
@ -242,16 +248,31 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
return (Iterator) wrapped.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceKey<? extends Registry<EntityType<?>>> key() {
|
||||
return wrapped.key();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> keySet() {
|
||||
return (Set) wrapped.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle lifecycle(Object type) {
|
||||
return wrapped.lifecycle((EntityType<?>) type);
|
||||
}
|
||||
|
||||
public void put(int entityId, ResourceLocation key, EntityType entityClass) {
|
||||
entities.put(key, entityClass);
|
||||
entityIds.put(entityClass, entityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream stream() {
|
||||
return wrapped.stream();
|
||||
}
|
||||
|
||||
private static final MethodHandle IREGISTRY_LIFECYCLE = NMS.getFirstGetter(Registry.class, Lifecycle.class);
|
||||
// replace regex
|
||||
// .*?> ([A-Z_]+).*?of\((.*?)::new.*?$
|
||||
|
@ -13,10 +13,14 @@ import java.util.stream.Stream;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Holder.Reference;
|
||||
import net.minecraft.core.IdMap;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
@ -152,6 +156,16 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
this.wrapped = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdMap<Holder<EntityType<?>>> asHolderIdMap() {
|
||||
return wrapped.asHolderIdMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTags(Map var0) {
|
||||
wrapped.bindTags(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object byId(int var0) {
|
||||
return this.wrapped.byId(var0);
|
||||
@ -162,6 +176,11 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
return this.wrapped.byIdOrThrow(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec byNameCodec() {
|
||||
return wrapped.byNameCodec();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(ResourceKey var0) {
|
||||
return this.wrapped.containsKey(var0);
|
||||
@ -172,6 +191,16 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
return this.wrapped.containsKey(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reference createIntrusiveHolder(Object type) {
|
||||
return this.wrapped.createIntrusiveHolder((EntityType<?>) type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle elementsLifecycle() {
|
||||
return wrapped.elementsLifecycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> entrySet() {
|
||||
return (Set) wrapped.entrySet();
|
||||
@ -189,6 +218,11 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public Registry<EntityType<?>> freeze() {
|
||||
return wrapped.freeze();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedRegistry<EntityType<?>> get() {
|
||||
return wrapped;
|
||||
@ -272,26 +306,56 @@ public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<
|
||||
return wrapped.getTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isKnownTagName(TagKey key) {
|
||||
return wrapped.isKnownTagName(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceKey<? extends Registry<EntityType<?>>> key() {
|
||||
return wrapped.key();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> keySet() {
|
||||
return (Set) wrapped.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle lifecycle() {
|
||||
return wrapped.lifecycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lifecycle lifecycle(Object type) {
|
||||
return wrapped.lifecycle((EntityType<?>) type);
|
||||
}
|
||||
|
||||
public void put(int entityId, ResourceLocation key, EntityType entityClass) {
|
||||
entities.put(key, entityClass);
|
||||
entityIds.put(entityClass, entityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTags() {
|
||||
wrapped.resetTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return wrapped.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<EntityType<?>> stream() {
|
||||
return wrapped.stream();
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -316,6 +316,11 @@ 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();
|
||||
|
Loading…
Reference in New Issue
Block a user