Search in sources :

Example 1 with MCEntityDefinition

use of minetweaker.mc1102.entity.MCEntityDefinition in project CraftTweaker by CraftTweaker.

the class MCGame method getEntity.

@Override
public IEntityDefinition getEntity(String entityName) {
    for (IEntityDefinition ent : getEntities()) {
        if (ent.getName().equalsIgnoreCase(entityName)) {
            return ent;
        }
    }
    boolean needsReloading = false;
    for (ResourceLocation res : ForgeRegistries.ENTITIES.getKeys()) {
        if (res.getResourcePath().equalsIgnoreCase(entityName)) {
            needsReloading = true;
            break;
        }
    }
    if (needsReloading) {
        ENTITY_DEFINITIONS.clear();
        ForgeRegistries.ENTITIES.forEach((entry) -> ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry)));
    }
    return getEntities().stream().filter(ent -> ent.getName().equals(entityName)).findFirst().orElse(null);
}
Also used : MCEntityDefinition(crafttweaker.mc1120.entity.MCEntityDefinition) IEntityDefinition(crafttweaker.api.entity.IEntityDefinition) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with MCEntityDefinition

use of minetweaker.mc1102.entity.MCEntityDefinition in project CraftTweaker by CraftTweaker.

the class MCGame method getEntity.

@Override
public IEntityDefinition getEntity(String entityName) {
    for (IEntityDefinition ent : getEntities()) {
        if (ent.getName().equalsIgnoreCase(entityName)) {
            return ent;
        }
    }
    boolean needsReloading = false;
    for (ResourceLocation res : ForgeRegistries.ENTITIES.getKeys()) {
        if (res.getResourcePath().equalsIgnoreCase(entityName)) {
            needsReloading = true;
            break;
        }
    }
    if (needsReloading) {
        ENTITY_DEFINITIONS.clear();
        ForgeRegistries.ENTITIES.forEach((entry) -> {
            ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry.getEntityClass(), entry.getName()));
        });
    }
    return getEntities().stream().filter(ent -> ent.getName().equals(entityName)).findFirst().orElse(null);
}
Also used : MCEntityDefinition(minetweaker.mc1112.entity.MCEntityDefinition) IEntityDefinition(minetweaker.api.entity.IEntityDefinition) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 3 with MCEntityDefinition

use of minetweaker.mc1102.entity.MCEntityDefinition in project CraftTweaker by CraftTweaker.

the class MCGame method getEntities.

@Override
public List<IEntityDefinition> getEntities() {
    if (Iterables.size(ForgeRegistries.ENTITIES) != ENTITY_DEFINITIONS.size()) {
        ENTITY_DEFINITIONS.clear();
        ForgeRegistries.ENTITIES.forEach((entry) -> {
            ENTITY_DEFINITIONS.add(new MCEntityDefinition(entry.getEntityClass(), entry.getName()));
        });
    }
    return ENTITY_DEFINITIONS;
}
Also used : MCEntityDefinition(minetweaker.mc1112.entity.MCEntityDefinition)

Example 4 with MCEntityDefinition

use of minetweaker.mc1102.entity.MCEntityDefinition in project CraftTweaker by CraftTweaker.

the class MCGame method getEntity.

@Override
public IEntityDefinition getEntity(String entityName) {
    for (IEntityDefinition ent : getEntities()) {
        if (ent.getName().equalsIgnoreCase(entityName)) {
            return ent;
        }
    }
    boolean needsReloading = false;
    for (String s : EntityList.NAME_TO_CLASS.keySet()) {
        if (s.equalsIgnoreCase(entityName)) {
            needsReloading = true;
            break;
        }
    }
    if (needsReloading) {
        ENTITY_DEFINITIONS.clear();
        EntityList.CLASS_TO_NAME.forEach((key, val) -> {
            ENTITY_DEFINITIONS.add(new MCEntityDefinition(key, val));
        });
    }
    return getEntities().stream().filter(ent -> ent.getName().equals(entityName)).findFirst().orElse(null);
}
Also used : MCEntityDefinition(minetweaker.mc1102.entity.MCEntityDefinition) IEntityDefinition(minetweaker.api.entity.IEntityDefinition)

Aggregations

IEntityDefinition (minetweaker.api.entity.IEntityDefinition)2 MCEntityDefinition (minetweaker.mc1112.entity.MCEntityDefinition)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IEntityDefinition (crafttweaker.api.entity.IEntityDefinition)1 MCEntityDefinition (crafttweaker.mc1120.entity.MCEntityDefinition)1 MCEntityDefinition (minetweaker.mc1102.entity.MCEntityDefinition)1