Search in sources :

Example 26 with MinecraftKey

use of net.minecraft.server.v1_9_R2.MinecraftKey in project MyPet by xXKeyleXx.

the class EntityRegistry method registerEntityType.

@SuppressWarnings("unchecked")
protected void registerEntityType(MyPetType petType, String key, RegistryBlocks<EntityTypes<?>> entityRegistry) {
    EntitySize size = entityRegistry.get(new MinecraftKey(key.toLowerCase())).l();
    entityTypes.put(petType, IRegistry.a(entityRegistry, "mypet_" + key.toLowerCase(), EntityTypes.Builder.a(EnumCreatureType.CREATURE).b().a().a(size.width, size.height).a(key)));
    registerDefaultAttributes(entityTypes.get(petType), (EntityTypes<? extends EntityLiving>) ReflectionUtil.getFieldValue(EntityTypes.class, null, ("" + petType.getTypeID()).toUpperCase()));
    overwriteEntityID(entityTypes.get(petType), getEntityTypeId(petType, entityRegistry), entityRegistry);
}
Also used : EntitySize(net.minecraft.server.v1_16_R3.EntitySize) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey)

Example 27 with MinecraftKey

use of net.minecraft.server.v1_9_R2.MinecraftKey in project MyPet by xXKeyleXx.

the class ConfigItem method load.

public void load(MaterialHolder material, String data) {
    MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
    Item item = Item.REGISTRY.get(key);
    if (item == null) {
        return;
    }
    net.minecraft.server.v1_9_R2.ItemStack is = new net.minecraft.server.v1_9_R2.ItemStack(item, 1, material.getLegacyName().getData());
    if (data != null) {
        NBTTagCompound tag = null;
        String nbtString = data.trim();
        if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
            try {
                tag = MojangsonParser.parse(nbtString);
            } catch (Exception e) {
                MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
                MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
            }
            if (tag != null) {
                is.setTag(tag);
            }
        }
    }
    this.item = CraftItemStack.asCraftMirror(is);
}
Also used : Item(net.minecraft.server.v1_9_R2.Item) NBTTagCompound(net.minecraft.server.v1_9_R2.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_9_R2.MinecraftKey) CraftItemStack(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack)

Example 28 with MinecraftKey

use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.

the class NMSImpl method registerEntityClass.

@Override
public void registerEntityClass(Class<?> clazz) {
    if (ENTITY_REGISTRY == null)
        return;
    Class<?> search = clazz;
    while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
        MinecraftKey key = ENTITY_REGISTRY.b(search);
        if (key == null)
            continue;
        int code = ENTITY_REGISTRY.a(search);
        ENTITY_REGISTRY.put(code, key, (Class<? extends Entity>) clazz);
        return;
    }
    throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
Also used : PathEntity(net.minecraft.server.v1_11_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_11_R1.Entity) MinecraftKey(net.minecraft.server.v1_11_R1.MinecraftKey) PathPoint(net.minecraft.server.v1_11_R1.PathPoint)

Example 29 with MinecraftKey

use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.

the class NMSImpl method registerEntityClass.

@Override
public void registerEntityClass(Class<?> clazz) {
    if (ENTITY_REGISTRY == null)
        return;
    Class<?> search = clazz;
    while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
        EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
        MinecraftKey key = ENTITY_REGISTRY.getKey(type);
        if (key == null || type == null)
            continue;
        CITIZENS_ENTITY_TYPES.put(clazz, type);
        int code = ENTITY_REGISTRY.a(type);
        ENTITY_REGISTRY.put(code, key, type);
        return;
    }
    throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_15_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) MinecraftKey(net.minecraft.server.v1_15_R1.MinecraftKey) PathPoint(net.minecraft.server.v1_15_R1.PathPoint)

Example 30 with MinecraftKey

use of net.minecraft.server.v1_9_R2.MinecraftKey in project Citizens2 by CitizensDev.

the class NMSImpl method registerEntityClass.

@Override
public void registerEntityClass(Class<?> clazz) {
    if (ENTITY_REGISTRY == null)
        return;
    Class<?> search = clazz;
    while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
        EntityTypes<?> type = ENTITY_REGISTRY.findType(search);
        MinecraftKey key = ENTITY_REGISTRY.getKey(type);
        if (key == null || type == null)
            continue;
        CITIZENS_ENTITY_TYPES.put(clazz, type);
        int code = ENTITY_REGISTRY.a(type);
        ENTITY_REGISTRY.put(code, key, type);
        return;
    }
    throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_14_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_14_R1.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) MinecraftKey(net.minecraft.server.v1_14_R1.MinecraftKey) PathPoint(net.minecraft.server.v1_14_R1.PathPoint)

Aggregations

MinecraftKey (net.minecraft.server.v1_16_R3.MinecraftKey)9 Field (java.lang.reflect.Field)8 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)6 MinecraftKey (net.minecraft.server.v1_15_R1.MinecraftKey)6 MinecraftKey (net.minecraft.server.v1_16_R2.MinecraftKey)6 LivingEntity (org.bukkit.entity.LivingEntity)6 MinecraftKey (net.minecraft.server.v1_13_R2.MinecraftKey)5 MinecraftKey (net.minecraft.server.v1_14_R1.MinecraftKey)5 MinecraftKey (net.minecraft.server.v1_11_R1.MinecraftKey)4 MinecraftKey (net.minecraft.server.v1_12_R1.MinecraftKey)4 MinecraftKey (net.minecraft.server.v1_16_R1.MinecraftKey)4 NamespacedKey (org.bukkit.NamespacedKey)3 EntityType (org.bukkit.entity.EntityType)3 MobSpawningMethod (dev.rosewood.rosestacker.spawner.spawning.MobSpawningMethod)2 SpawnerStackSettings (dev.rosewood.rosestacker.stack.settings.SpawnerStackSettings)2 List (java.util.List)2 Entity (net.minecraft.server.v1_11_R1.Entity)2 TileEntityMobSpawner (net.minecraft.server.v1_11_R1.TileEntityMobSpawner)2 Entity (net.minecraft.server.v1_12_R1.Entity)2 TileEntityMobSpawner (net.minecraft.server.v1_12_R1.TileEntityMobSpawner)2