mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Fix /npc camel and /npc llama
This commit is contained in:
parent
44e988b7d7
commit
3ee17c6dae
@ -2,10 +2,10 @@ package net.citizensnpcs.trait.versioned;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Camel;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import net.citizensnpcs.api.command.Command;
|
||||
import net.citizensnpcs.api.command.CommandContext;
|
||||
import net.citizensnpcs.api.command.CommandMessages;
|
||||
import net.citizensnpcs.api.command.Flag;
|
||||
import net.citizensnpcs.api.command.Requirements;
|
||||
import net.citizensnpcs.api.command.exception.CommandException;
|
||||
@ -13,7 +13,6 @@ import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.persistence.Persist;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitName;
|
||||
import net.citizensnpcs.api.trait.trait.MobType;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
@ -55,11 +54,9 @@ public class CamelTrait extends Trait {
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "citizens.npc.camel")
|
||||
@Requirements(selected = true, ownership = true)
|
||||
@Requirements(selected = true, ownership = true, types = EntityType.CAMEL)
|
||||
public static void camel(CommandContext args, CommandSender sender, NPC npc, @Flag("pose") CamelPose pose)
|
||||
throws CommandException {
|
||||
if (npc.getOrAddTrait(MobType.class).getType().name().equals("CAMEL"))
|
||||
throw new CommandException(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE);
|
||||
CamelTrait trait = npc.getOrAddTrait(CamelTrait.class);
|
||||
String output = "";
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class LlamaTrait extends Trait {
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public static void llama(CommandContext args, CommandSender sender, NPC npc,
|
||||
@Flag({ "color", "colour" }) Color color, @Flag("strength") Integer strength) throws CommandException {
|
||||
if (npc.getOrAddTrait(MobType.class).getType().name().contains("LLAMA"))
|
||||
if (!npc.getOrAddTrait(MobType.class).getType().name().contains("LLAMA"))
|
||||
throw new CommandException(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE);
|
||||
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||
String output = "";
|
||||
|
@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -14,7 +15,8 @@ import net.minecraft.server.v1_11_R1.MinecraftKey;
|
||||
import net.minecraft.server.v1_11_R1.RegistryMaterials;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryMaterials {
|
||||
public class CustomEntityRegistry extends RegistryMaterials
|
||||
implements Supplier<RegistryMaterials<MinecraftKey, Class<? extends Entity>>> {
|
||||
private final BiMap<MinecraftKey, Class<? extends Entity>> entities = HashBiMap.create();
|
||||
private final BiMap<Class<? extends Entity>, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<Class<? extends Entity>, Integer> entityIds = Maps.newHashMap();
|
||||
@ -57,6 +59,11 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return wrapped.d((MinecraftKey) paramK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Entity> get(Object key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -71,10 +78,6 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return wrapped.getId(paramInt);
|
||||
}
|
||||
|
||||
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1258,7 +1258,7 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
try {
|
||||
MethodHandle setter = NMS.getFinalSetter(EntityTypes.class, "b");
|
||||
setter.invoke(ENTITY_REGISTRY.getWrapped());
|
||||
setter.invoke(ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -14,7 +15,8 @@ import net.minecraft.server.v1_12_R1.MinecraftKey;
|
||||
import net.minecraft.server.v1_12_R1.RegistryMaterials;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryMaterials {
|
||||
public class CustomEntityRegistry extends RegistryMaterials
|
||||
implements Supplier<RegistryMaterials<MinecraftKey, Class<? extends Entity>>> {
|
||||
private final BiMap<MinecraftKey, Class<? extends Entity>> entities = HashBiMap.create();
|
||||
private final BiMap<Class<? extends Entity>, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<Class<? extends Entity>, Integer> entityIds = Maps.newHashMap();
|
||||
@ -57,6 +59,11 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return wrapped.d((MinecraftKey) paramK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Entity> get(Object key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -71,10 +78,6 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return wrapped.getId(paramInt);
|
||||
}
|
||||
|
||||
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1268,7 +1268,7 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
try {
|
||||
MethodHandle setter = NMS.getFinalSetter(EntityTypes.class, "b");
|
||||
setter.invoke(ENTITY_REGISTRY.getWrapped());
|
||||
setter.invoke(ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -14,7 +15,7 @@ import net.minecraft.server.v1_13_R2.MinecraftKey;
|
||||
import net.minecraft.server.v1_13_R2.RegistryMaterials;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryMaterials {
|
||||
public class CustomEntityRegistry extends RegistryMaterials implements Supplier<RegistryMaterials<EntityTypes<?>>> {
|
||||
private final BiMap<MinecraftKey, EntityTypes> entities = HashBiMap.create();
|
||||
private final BiMap<EntityTypes, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityTypes, Integer> entityIds = Maps.newHashMap();
|
||||
@ -52,6 +53,11 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryMaterials<EntityTypes<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTypes get(MinecraftKey key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -70,10 +76,6 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
||||
return wrapped.getKey((EntityTypes) value);
|
||||
}
|
||||
|
||||
public RegistryMaterials<EntityTypes<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1307,7 +1307,7 @@ public class NMSImpl implements NMSBridge {
|
||||
field = NMS.getFinalSetter(IRegistry.class, "ENTITY_TYPE", false);
|
||||
}
|
||||
try {
|
||||
field.invoke(ENTITY_REGISTRY.getWrapped());
|
||||
field.invoke(ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -13,11 +14,11 @@ import com.google.common.collect.Maps;
|
||||
import net.minecraft.server.v1_14_R1.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryBlocks {
|
||||
public class CustomEntityRegistry extends RegistryBlocks implements Supplier<RegistryBlocks<EntityTypes<?>>> {
|
||||
private final BiMap<MinecraftKey, EntityTypes> entities = HashBiMap.create();
|
||||
private final BiMap<EntityTypes, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityTypes, Integer> entityIds = Maps.newHashMap();
|
||||
private final RegistryMaterials<EntityTypes<?>> wrapped;
|
||||
private final RegistryBlocks<EntityTypes<?>> wrapped;
|
||||
|
||||
public CustomEntityRegistry(RegistryBlocks<EntityTypes<?>> original) {
|
||||
super(original.a().getNamespace());
|
||||
@ -55,6 +56,11 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return this.wrapped.fromId(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryBlocks<EntityTypes<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTypes get(MinecraftKey key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -82,10 +88,6 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return Optional.ofNullable(this.wrapped.get(var0));
|
||||
}
|
||||
|
||||
public RegistryMaterials<EntityTypes<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1366,7 +1366,7 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
MethodHandle field = NMS.getFinalSetter(IRegistry.class, "ENTITY_TYPE");
|
||||
try {
|
||||
field.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
field.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -13,11 +14,11 @@ import com.google.common.collect.Maps;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryBlocks {
|
||||
public class CustomEntityRegistry extends RegistryBlocks implements Supplier<RegistryBlocks<EntityTypes<?>>> {
|
||||
private final BiMap<MinecraftKey, EntityTypes> entities = HashBiMap.create();
|
||||
private final BiMap<EntityTypes, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityTypes, Integer> entityIds = Maps.newHashMap();
|
||||
private final RegistryMaterials<EntityTypes<?>> wrapped;
|
||||
private final RegistryBlocks<EntityTypes<?>> wrapped;
|
||||
|
||||
public CustomEntityRegistry(RegistryBlocks<EntityTypes<?>> original) {
|
||||
super(original.a().getNamespace());
|
||||
@ -55,6 +56,11 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return this.wrapped.fromId(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryBlocks<EntityTypes<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTypes get(MinecraftKey key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -82,10 +88,6 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return this.wrapped.getOptional(var0);
|
||||
}
|
||||
|
||||
public RegistryMaterials<EntityTypes<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1409,7 +1409,7 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
MethodHandle field = NMS.getFinalSetter(IRegistry.class, "ENTITY_TYPE");
|
||||
try {
|
||||
field.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
field.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -16,11 +17,11 @@ import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_16_R3.*;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends RegistryBlocks {
|
||||
public class CustomEntityRegistry extends RegistryBlocks implements Supplier<RegistryBlocks<EntityTypes<?>>> {
|
||||
private final BiMap<MinecraftKey, EntityTypes> entities = HashBiMap.create();
|
||||
private final BiMap<EntityTypes, MinecraftKey> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityTypes, Integer> entityIds = Maps.newHashMap();
|
||||
private final RegistryMaterials<EntityTypes<?>> wrapped;
|
||||
private final RegistryBlocks<EntityTypes<?>> wrapped;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CustomEntityRegistry(RegistryBlocks<EntityTypes<?>> original) throws Throwable {
|
||||
@ -76,6 +77,11 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return this.wrapped.fromId(var0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryBlocks<EntityTypes<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTypes get(MinecraftKey key) {
|
||||
if (entities.containsKey(key)) {
|
||||
@ -103,10 +109,6 @@ public class CustomEntityRegistry extends RegistryBlocks {
|
||||
return this.wrapped.getOptional(var0);
|
||||
}
|
||||
|
||||
public RegistryMaterials<EntityTypes<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1436,7 +1436,7 @@ public class NMSImpl implements NMSBridge {
|
||||
return;
|
||||
MethodHandle field = NMS.getFinalSetter(IRegistry.class, "ENTITY_TYPE");
|
||||
try {
|
||||
field.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
field.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -14,7 +15,6 @@ import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@ -133,11 +133,11 @@ import net.minecraft.world.entity.vehicle.MinecartSpawner;
|
||||
import net.minecraft.world.entity.vehicle.MinecartTNT;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<DefaultedRegistry<EntityType<?>>> {
|
||||
private final BiMap<ResourceLocation, EntityType> entities = HashBiMap.create();
|
||||
private final BiMap<EntityType, ResourceLocation> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityType, Integer> entityIds = Maps.newHashMap();
|
||||
private final MappedRegistry<EntityType<?>> wrapped;
|
||||
private final DefaultedRegistry<EntityType<?>> wrapped;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CustomEntityRegistry(DefaultedRegistry<EntityType<?>> original) throws Throwable {
|
||||
@ -179,6 +179,11 @@ public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedRegistry<EntityType<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType get(ResourceKey key) {
|
||||
return wrapped.get(key);
|
||||
@ -240,10 +245,6 @@ public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
return wrapped.getResourceKey((EntityType<?>) var0);
|
||||
}
|
||||
|
||||
public MappedRegistry<EntityType<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1430,7 +1430,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
try {
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
@ -136,11 +137,11 @@ import net.minecraft.world.entity.vehicle.MinecartSpawner;
|
||||
import net.minecraft.world.entity.vehicle.MinecartTNT;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
public class CustomEntityRegistry extends DefaultedRegistry implements Supplier<DefaultedRegistry<EntityType<?>>> {
|
||||
private final BiMap<ResourceLocation, EntityType> entities = HashBiMap.create();
|
||||
private final BiMap<EntityType, ResourceLocation> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityType, Integer> entityIds = Maps.newHashMap();
|
||||
private final MappedRegistry<EntityType<?>> wrapped;
|
||||
private final DefaultedRegistry<EntityType<?>> wrapped;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CustomEntityRegistry(DefaultedRegistry<EntityType<?>> original) throws Throwable {
|
||||
@ -188,6 +189,11 @@ public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedRegistry<EntityType<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType get(ResourceKey key) {
|
||||
return wrapped.get(key);
|
||||
@ -274,10 +280,6 @@ public class CustomEntityRegistry extends DefaultedRegistry {
|
||||
return wrapped.getTags();
|
||||
}
|
||||
|
||||
public MappedRegistry<EntityType<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Object> iterator() {
|
||||
return (Iterator) wrapped.iterator();
|
||||
|
@ -1437,7 +1437,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
try {
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
@ -151,18 +152,18 @@ import net.minecraft.world.entity.vehicle.MinecartSpawner;
|
||||
import net.minecraft.world.entity.vehicle.MinecartTNT;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>> {
|
||||
public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
|
||||
implements Supplier<DefaultedMappedRegistry<EntityType<?>>> {
|
||||
private final BiMap<ResourceLocation, EntityType> entities = HashBiMap.create();
|
||||
private final BiMap<EntityType, ResourceLocation> entityClasses = this.entities.inverse();
|
||||
private final Map<EntityType, Integer> entityIds = Maps.newHashMap();
|
||||
private final MappedRegistry<EntityType<?>> wrapped;
|
||||
private final DefaultedMappedRegistry<EntityType<?>> wrapped;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CustomEntityRegistry(DefaultedRegistry<EntityType<?>> original) throws Throwable {
|
||||
super(original.getDefaultKey().getNamespace(),
|
||||
(ResourceKey<? extends Registry<EntityType<?>>>) IREGISTRY_RESOURCE_KEY.invoke(original),
|
||||
(Lifecycle) IREGISTRY_LIFECYCLE.invoke(original), true);
|
||||
this.wrapped = (MappedRegistry<EntityType<?>>) original;
|
||||
this.wrapped = (DefaultedMappedRegistry<EntityType<?>>) original;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -209,6 +210,11 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
|
||||
return minecraftClassMap.inverse().get(search);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultedMappedRegistry<EntityType<?>> get() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType get(ResourceKey<EntityType<?>> key) {
|
||||
return wrapped.get(key);
|
||||
@ -290,10 +296,6 @@ public class CustomEntityRegistry extends DefaultedMappedRegistry<EntityType<?>>
|
||||
return wrapped.getTags();
|
||||
}
|
||||
|
||||
public MappedRegistry<EntityType<?>> getWrapped() {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HolderOwner<EntityType<?>> holderOwner() {
|
||||
return wrapped.holderOwner();
|
||||
|
@ -1511,7 +1511,7 @@ public class NMSImpl implements NMSBridge {
|
||||
if (ENTITY_REGISTRY == null)
|
||||
return;
|
||||
try {
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.getWrapped());
|
||||
ENTITY_REGISTRY_SETTER.invoke(null, ENTITY_REGISTRY.get());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ public class PlayerMoveControl extends MoveControl {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
this.entity.zza = 0;
|
||||
if (this.moving) {
|
||||
this.moving = false;
|
||||
|
Loading…
Reference in New Issue
Block a user