use of de.teamlapen.vampirism.api.entity.convertible.IConvertingHandler in project Vampirism by TeamLapen.
the class VampirismEntityRegistry method applyNewResources.
public void applyNewResources(Map<ResourceLocation, Integer> valuesIn, int multiplier) {
this.bloodValues.putAll(valuesIn);
this.bloodMultiplier = multiplier;
Map<ResourceLocation, BiteableEntry> biteables = Maps.newHashMap();
Set<ResourceLocation> blacklist = Sets.newHashSet();
float bloodValueMultiplier = bloodMultiplier / 10F;
final IConvertingHandler defaultHandler = defaultConvertingHandlerCreator.apply(null);
for (Map.Entry<EntityType<? extends CreatureEntity>, IConvertingHandler> entry : convertibles.entrySet()) {
ResourceLocation id = entry.getKey().getRegistryName();
if (id == null) {
LOGGER.warn("Cannot register convertible {} since there is no EntityString for it", entry.getKey());
continue;
}
Integer blood = valuesIn.remove(id);
if (blood == null) {
LOGGER.warn("Missing blood value for convertible creature {} ({})", entry.getKey().getDescription(), id);
continue;
}
blood = Math.round(blood * bloodValueMultiplier);
LOGGER.debug("Registering convertible {} with blood {} and handler {}", entry.getKey().getDescription().getString(), blood, entry.getValue().getClass().getName());
BiteableEntry biteEntry = new BiteableEntry(blood, (entry.getValue() == null ? defaultHandler : entry.getValue()));
biteables.put(id, biteEntry);
}
LOGGER.info("Registered {} convertibles", biteables.size());
for (Map.Entry<ResourceLocation, Integer> entry : valuesIn.entrySet()) {
int blood = Math.abs(Math.round(entry.getValue() * bloodValueMultiplier));
if (blood == 0) {
blacklist.add(entry.getKey());
} else {
biteables.put(entry.getKey(), new BiteableEntry(blood));
}
}
biteableEntryManager.setNewBiteables(biteables, blacklist);
}
use of de.teamlapen.vampirism.api.entity.convertible.IConvertingHandler in project Vampirism by TeamLapen.
the class ConvertedCreatureEntity method getConvertedHelper.
/**
* @return The {@link de.teamlapen.vampirism.api.entity.convertible.IConvertingHandler.IDefaultHelper} for this creature
*/
@Nullable
protected IConvertingHandler.IDefaultHelper getConvertedHelper() {
if (nil())
return null;
BiteableEntry biteableEntry = VampirismAPI.entityRegistry().getEntry(entityCreature);
if (biteableEntry == null) {
LOGGER.warn("Cannot find biteable entry for {}", entityCreature);
return null;
}
IConvertingHandler handler = biteableEntry.convertingHandler;
if (handler instanceof DefaultConvertingHandler) {
return ((DefaultConvertingHandler) handler).getHelper();
}
return null;
}
Aggregations