use of com.lying.variousoddities.species.Species in project VariousOddities by Lyinginbedmon.
the class ScreenSelectSpecies method tick.
public void tick() {
super.tick();
LivingData data = LivingData.forEntity(player);
typesButton.visible = typesButton.active = data.hasCustomTypes();
Species currentSpecies = getCurrentSpecies();
if (currentSpecies != null && !currentSpecies.getAbilities().isEmpty() && this.abilityList.isEmpty())
populateAbilityList(currentSpecies.getFullAbilities());
}
use of com.lying.variousoddities.species.Species in project VariousOddities by Lyinginbedmon.
the class LivingData method tick.
public void tick(LivingEntity entity) {
IDefaultSpecies mobDefaults = entity instanceof IDefaultSpecies ? (IDefaultSpecies) entity : null;
World world = entity.getEntityWorld();
if (!this.initialised && (!isPlayer || ((PlayerEntity) entity).getGameProfile() != null)) {
// TODO Check default home dimension registry for creature before setting to current dim
if (mobDefaults != null) {
if (((IDefaultSpecies) entity).defaultHomeDimension() != null)
setHomeDimension(((IDefaultSpecies) entity).defaultHomeDimension());
} else
setHomeDimension(world.getDimensionKey().getLocation());
if (isPlayer) {
PlayerEntity player = (PlayerEntity) entity;
String name = player.getName().getUnformattedComponentText();
if (CreatureTypeDefaults.isTypedPatron(name)) {
setCustomTypes(CreatureTypeDefaults.getPatronTypes(name));
VariousOddities.log.info("Initialised patron " + name + " as " + EnumCreatureType.getTypes(player).toHeader().getString());
}
} else {
if (mobDefaults != null) {
if (mobDefaults.defaultSpecies() != null) {
Species defaultSpecies = SpeciesRegistry.getSpecies(mobDefaults.defaultSpecies());
if (defaultSpecies != null)
setSpecies(defaultSpecies);
}
if (!mobDefaults.defaultTemplates().isEmpty())
mobDefaults.defaultTemplates().forEach((temp) -> {
Template template = VORegistries.TEMPLATES.getOrDefault(temp, null);
if (template != null)
addTemplateInitial(template);
});
if (!mobDefaults.defaultCreatureTypes().isEmpty())
mobDefaults.defaultCreatureTypes().forEach((type) -> {
addCustomType(type);
});
if (!mobDefaults.defaultAbilities().isEmpty())
mobDefaults.defaultAbilities().forEach((ability) -> {
this.abilities.addCustomAbility(AbilityRegistry.getAbility(ability.writeAtomically(new CompoundNBT())));
});
} else {
Species guess = SpeciesRegistry.getSpecies(entity.getType().getRegistryName());
if (guess != null)
setSpecies(guess);
}
setSelectedSpecies(true);
}
this.initialised = true;
markDirty();
}
if (!ConfigVO.MOBS.selectSpeciesOnLogin.get())
setSelectedSpecies(true);
handleTypes(entity, world);
PlayerEntity player = null;
if (isPlayer)
player = (PlayerEntity) entity;
if (isPlayer)
handleHealth(player);
ActionSet actions = ActionSet.fromTypes(this.entity, this.prevTypes);
// Prevent phantoms due to sleeplessness
if (!actions.sleeps()) {
if (isPlayer && !world.isRemote) {
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
ServerStatisticsManager statManager = serverPlayer.getStats();
statManager.setValue(serverPlayer, Stats.CUSTOM.get(Stats.TIME_SINCE_REST), 0);
}
}
handleAir(actions.breathes(), entity);
if (this.bludgeoning > 0F)
if (--this.recoveryTimer <= 0)
setBludgeoning(this.bludgeoning - 1F);
if (isUnconscious() != isActuallyUnconscious()) {
if (isPlayer) {
if (isUnconscious())
PlayerData.forPlayer((PlayerEntity) entity).setBodyCondition(BodyCondition.UNCONSCIOUS);
this.isUnconscious = isUnconscious();
} else {
if (isUnconscious()) {
AbstractBody.clearNearbyAttackTargetsOf(entity);
// Spawn body
LivingEntity body = EntityBodyUnconscious.createBodyFrom(entity);
((AbstractBody) body).setPocketInventory(getPocketInventory());
if (entity.isAddedToWorld()) {
// TODO Play crit attack noise when creature is knocked unconscious
if (!world.isRemote) {
world.addEntity(body);
entity.remove();
}
}
}
this.isUnconscious = isUnconscious();
}
markDirty();
}
abilities.tick();
handleConditions();
if (this.dirty) {
if (this.entity != null && !this.entity.getEntityWorld().isRemote)
PacketHandler.sendToNearby(entity.getEntityWorld(), entity, new PacketSyncLivingData(entity.getUniqueID(), this));
this.dirty = false;
}
if (world.isRemote && --this.potionSyncTimer <= 0) {
this.potionSyncTimer = Reference.Values.TICKS_PER_MINUTE;
// TODO Ping server for visualPotion value
}
}
use of com.lying.variousoddities.species.Species in project VariousOddities by Lyinginbedmon.
the class CommandSpecies method detailSpecies.
private static int detailSpecies(ResourceLocation speciesName, CommandSource source) throws CommandSyntaxException {
Species species = VORegistries.SPECIES.get(speciesName);
if (species == null)
throw SPECIES_INVALID_EXCEPTION.create(speciesName);
source.sendFeedback(new TranslationTextComponent(translationSlug + "info_name", species.getDisplayName()), true);
if (species.hasTypes())
source.sendFeedback(new Types(species.getCreatureTypes()).toHeader(), false);
if (!species.getFullAbilities().isEmpty()) {
source.sendFeedback(new TranslationTextComponent(translationSlug + "info_abilities"), false);
for (Ability ability : species.getFullAbilities()) source.sendFeedback(new StringTextComponent(" -").append(ability.getDisplayName()), false);
}
return 15;
}
Aggregations