use of forestry.api.lepidopterology.IAlleleButterflySpecies in project ForestryMC by ForestryMC.
the class EntityButterfly method onUpdate.
/* UPDATING */
@Override
public void onUpdate() {
super.onUpdate();
// Update stuff client side
if (world.isRemote) {
if (species == null) {
String speciesUid = dataManager.get(DATAWATCHER_ID_SPECIES);
IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
if (allele instanceof IAlleleButterflySpecies) {
species = (IAlleleButterflySpecies) allele;
textureResource = new ResourceLocation(species.getEntityTexture());
size = dataManager.get(DATAWATCHER_ID_SIZE) / 100f;
}
}
byte stateOrdinal = dataManager.get(DATAWATCHER_ID_STATE);
if (state.ordinal() != stateOrdinal) {
setState(EnumButterflyState.VALUES[stateOrdinal]);
}
}
motionY *= 0.6000000238418579d;
// Make sure we die if the butterfly hasn't rested in a long, long time.
if (exhaustion > EXHAUSTION_CONSUMPTION && getRNG().nextInt(20) == 0) {
attackEntityFrom(DamageSource.GENERIC, 1);
}
if (ticksExisted > MAX_LIFESPAN) {
attackEntityFrom(DamageSource.GENERIC, 1);
}
// Reduce cooldowns
if (cooldownEgg > 0) {
cooldownEgg--;
}
if (cooldownPollination > 0) {
cooldownPollination--;
}
if (cooldownMate > 0) {
cooldownMate--;
}
}
use of forestry.api.lepidopterology.IAlleleButterflySpecies in project ForestryMC by ForestryMC.
the class ModuleLepidopterology method parseRarity.
private static void parseRarity(LocalizedConfiguration config) {
List<String> butterflyRarity = Lists.newArrayList();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleButterflySpecies) {
IAlleleButterflySpecies species = (IAlleleButterflySpecies) allele;
butterflyRarity.add(species.getUID() + ":" + species.getRarity());
}
}
Collections.sort(butterflyRarity);
String[] defaultRaritys = butterflyRarity.toArray(new String[butterflyRarity.size()]);
Property rarityConf = config.get("butterfly.alleles", "rarity", defaultRaritys);
rarityConf.setComment(Translator.translateToLocal("for.config.butterfly.alleles.rarity"));
String[] configRaritys = rarityConf.getStringList();
for (String rarity : configRaritys) {
if (rarity.contains(":") && rarity.length() > 3) {
String[] raritys = rarity.split(":");
try {
spawnRaritys.put(raritys[0], Float.parseFloat(raritys[1]));
} catch (Exception e) {
Log.error("Failed to parse spawn rarity for butterfly. {}", rarity, e);
}
}
}
}
Aggregations