Search in sources :

Example 1 with EnumCreatureType

use of com.lying.variousoddities.species.types.EnumCreatureType in project VariousOddities by Lyinginbedmon.

the class TypesManager method resetMobs.

public void resetMobs() {
    typeToMob.clear();
    mobTypeCache.clear();
    Map<EnumCreatureType, String[]> configuredMobs = ConfigVO.MOBS.typeSettings.getMobTypes();
    for (EnumCreatureType type : configuredMobs.keySet()) if (configuredMobs.get(type).length > 0)
        for (String entry : configuredMobs.get(type)) if (entry != null && entry.length() > 0 && entry.contains(":"))
            addToEntity(new ResourceLocation(entry), type, false);
    markDirty();
}
Also used : EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with EnumCreatureType

use of com.lying.variousoddities.species.types.EnumCreatureType in project VariousOddities by Lyinginbedmon.

the class TypesManager method read.

public void read(CompoundNBT compound) {
    typeToMob.clear();
    ListNBT mobs = compound.getList("Mobs", 10);
    for (int i = 0; i < mobs.size(); i++) {
        CompoundNBT typ = mobs.getCompound(i);
        EnumCreatureType type = EnumCreatureType.fromName(typ.getString("Type"));
        ListNBT entr = typ.getList("Entries", 8);
        List<ResourceLocation> entries = new ArrayList<>();
        for (int j = 0; j < entr.size(); j++) entries.add(new ResourceLocation(entr.getString(j)));
        typeToMob.put(type, entries);
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList)

Example 3 with EnumCreatureType

use of com.lying.variousoddities.species.types.EnumCreatureType in project VariousOddities by Lyinginbedmon.

the class VOBusServer method applyNativeExtraplanar.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void applyNativeExtraplanar(GetEntityTypesEvent event) {
    LivingEntity entity = event.getEntity();
    LivingData data = LivingData.forEntity(entity);
    if (data == null)
        return;
    if (data.getHomeDimension() != null) {
        List<EnumCreatureType> types = event.getTypes();
        if (types.contains(EnumCreatureType.EXTRAPLANAR) || types.contains(EnumCreatureType.NATIVE))
            return;
        ResourceLocation currentDim = entity.getEntityWorld().getDimensionKey().getLocation();
        if (currentDim.equals(data.getHomeDimension())) {
            if (!types.contains(EnumCreatureType.EXTRAPLANAR) && EnumCreatureType.NATIVE.canApplyTo(types))
                event.getTypes().add(EnumCreatureType.NATIVE);
        } else {
            if (!types.contains(EnumCreatureType.NATIVE) && EnumCreatureType.EXTRAPLANAR.canApplyTo(types))
                event.getTypes().add(EnumCreatureType.EXTRAPLANAR);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType) ResourceLocation(net.minecraft.util.ResourceLocation) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) LivingData(com.lying.variousoddities.capabilities.LivingData) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with EnumCreatureType

use of com.lying.variousoddities.species.types.EnumCreatureType in project VariousOddities by Lyinginbedmon.

the class ScentsManager method cleanScents.

public void cleanScents() {
    for (EnumCreatureType type : scentMap.keySet()) {
        List<ScentMarker> scents = scentMap.get(type);
        if (scents.removeIf(ScentMarker::isDead))
            scentMap.put(type, scents);
    }
    int total = totalScents();
    if (total > MAX_SCENTS) {
        List<ScentMarker> scents = getAllScents();
        scents.sort(MARKER_SORT_DIST);
        while (total > MAX_SCENTS) {
            ScentMarker removed = scents.remove(scents.size() - 1);
            List<ScentMarker> ofType = scentMap.get(removed.type);
            ofType.remove(removed);
            scentMap.put(removed.type, ofType);
        }
    }
}
Also used : EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType)

Example 5 with EnumCreatureType

use of com.lying.variousoddities.species.types.EnumCreatureType in project VariousOddities by Lyinginbedmon.

the class ScentsManager method read.

public void read(CompoundNBT compound) {
    this.scentTimer = compound.getInt("Timer");
    scentMap.clear();
    ListNBT scentList = compound.getList("Scents", 10);
    for (int i = 0; i < scentList.size(); i++) {
        CompoundNBT typeData = scentList.getCompound(i);
        EnumCreatureType type = EnumCreatureType.fromName(typeData.getString("Type"));
        ListNBT typeMarkers = typeData.getList("Markers", 10);
        List<ScentMarker> markers = Lists.newArrayList();
        for (int j = 0; j < typeMarkers.size(); j++) markers.add(new ScentMarker(this.world, typeMarkers.getCompound(j)));
        scentMap.put(type, markers);
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) EnumCreatureType(com.lying.variousoddities.species.types.EnumCreatureType)

Aggregations

EnumCreatureType (com.lying.variousoddities.species.types.EnumCreatureType)20 ListNBT (net.minecraft.nbt.ListNBT)10 CompoundNBT (net.minecraft.nbt.CompoundNBT)9 ResourceLocation (net.minecraft.util.ResourceLocation)9 Ability (com.lying.variousoddities.species.abilities.Ability)5 ArrayList (java.util.ArrayList)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 LivingEntity (net.minecraft.entity.LivingEntity)2 JsonParseException (com.google.gson.JsonParseException)1 IDefaultSpecies (com.lying.variousoddities.api.entity.IDefaultSpecies)1 TypeApplyEvent (com.lying.variousoddities.api.event.CreatureTypeEvent.TypeApplyEvent)1 TypeRemoveEvent (com.lying.variousoddities.api.event.CreatureTypeEvent.TypeRemoveEvent)1 LivingData (com.lying.variousoddities.capabilities.LivingData)1 PacketSyncLivingData (com.lying.variousoddities.network.PacketSyncLivingData)1 Template (com.lying.variousoddities.species.Template)1 Types (com.lying.variousoddities.species.types.Types)1 Pair (com.mojang.datafixers.util.Pair)1 Entity (net.minecraft.entity.Entity)1 EntityType (net.minecraft.entity.EntityType)1