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();
}
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);
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
Aggregations