EntityStatsSystems.java
package com.hypixel.hytale.server.core.modules.entitystats;
import com.hypixel.hytale.component.AddReason;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.ComponentAccessor;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.RemoveReason;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.component.SystemGroup;
import com.hypixel.hytale.component.dependency.Dependency;
import com.hypixel.hytale.component.dependency.Order;
import com.hypixel.hytale.component.dependency.SystemDependency;
import com.hypixel.hytale.component.dependency.SystemTypeDependency;
import com.hypixel.hytale.component.query.Query;
import com.hypixel.hytale.component.system.HolderSystem;
import com.hypixel.hytale.component.system.ISystem;
import com.hypixel.hytale.component.system.RefChangeSystem;
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
import com.hypixel.hytale.protocol.ComponentUpdate;
import com.hypixel.hytale.protocol.ComponentUpdateType;
import com.hypixel.hytale.protocol.EntityStatUpdate;
import com.hypixel.hytale.protocol.InteractionType;
import com.hypixel.hytale.server.core.asset.type.item.config.Item;
import com.hypixel.hytale.server.core.entity.EntityUtils;
com.hypixel.hytale.server.core.entity.InteractionChain;
com.hypixel.hytale.server.core.entity.InteractionContext;
com.hypixel.hytale.server.core.entity.InteractionManager;
com.hypixel.hytale.server.core.entity.LivingEntity;
com.hypixel.hytale.server.core.inventory.ItemStack;
com.hypixel.hytale.server.core.inventory.container.ItemContainer;
com.hypixel.hytale.server.core.modules.entity.AllLegacyLivingEntityTypesQuery;
com.hypixel.hytale.server.core.modules.entity.component.Invulnerable;
com.hypixel.hytale.server.core.modules.entity.damage.Damage;
com.hypixel.hytale.server.core.modules.entity.damage.DamageCause;
com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent;
com.hypixel.hytale.server.core.modules.entity.tracker.EntityTrackerSystems;
com.hypixel.hytale.server.core.modules.entitystats.asset.DefaultEntityStatTypes;
com.hypixel.hytale.server.core.modules.entitystats.asset.EntityStatType;
com.hypixel.hytale.server.core.modules.interaction.InteractionModule;
com.hypixel.hytale.server.core.modules.interaction.interaction.config.RootInteraction;
com.hypixel.hytale.server.core.modules.time.TimeResource;
com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
it.unimi.dsi.fastutil.floats.FloatList;
it.unimi.dsi.fastutil.ints.Int2ObjectMap;
java.time.Instant;
java.util.List;
java.util.Map;
java.util.Set;
javax.annotation.Nonnull;
javax.annotation.Nullable;
{
{
}
<EntityStore> {
ComponentType<EntityStore, EntityStatMap> componentType;
{
.componentType = componentType;
}
Query<EntityStore> {
AllLegacyLivingEntityTypesQuery.INSTANCE;
}
{
(EntityStatMap)holder.getComponent(.componentType);
(stats == ) {
stats = (EntityStatMap)holder.ensureAndGetComponent(.componentType);
stats.update();
}
}
{
}
}
<EntityType > <EntityStore> {
ComponentType<EntityStore, EntityStatMap> componentType;
ComponentType<EntityStore, EntityType> entityTypeComponent;
Query<EntityStore> query;
{
.componentType = componentType;
.entityTypeComponent = entityTypeComponent;
.query = Query.<EntityStore>and(componentType, entityTypeComponent);
}
Query<EntityStore> {
.query;
}
{
;
}
{
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
(EntityStatMap)archetypeChunk.getComponent(index, .componentType);
map != ;
((TimeResource)store.getResource(TimeResource.getResourceType())).getNow();
map.size();
(map.tempRegenerationValues.length < size) {
map.tempRegenerationValues = [size];
}
( ; statIndex < size; ++statIndex) {
map.get(statIndex);
(value != ) {
map.tempRegenerationValues[statIndex] = ;
RegeneratingValue[] regenerating = value.getRegeneratingValues();
(regenerating != ) {
(RegeneratingValue regeneratingValue : regenerating) {
(regeneratingValue.getRegenerating().getAmount() > ) {
(value.get() >= value.getMax()) {
;
}
} (value.get() <= value.getMin()) {
;
}
[] var10000 = map.tempRegenerationValues;
var10000[statIndex] += regeneratingValue.regenerate(commandBuffer, ref, now, dt, value, map.tempRegenerationValues[statIndex]);
}
}
}
}
(EntityType)(archetypeChunk.getComponent(index, .entityTypeComponent));
entity != ;
entity.getInventory().getArmor();
armorContainer.getCapacity();
( ; i < armorContainerCapacity; ++i) {
armorContainer.getItemStack(i);
(!ItemStack.isEmpty(itemStack)) {
itemStack.getItem();
(item.getArmor() != && item.getArmor().getRegeneratingValues() != && !item.getArmor().getRegeneratingValues().isEmpty()) {
( ; statIndex < size; ++statIndex) {
map.get(statIndex);
(value != ) {
List<RegeneratingValue> regenValues = (List)item.getArmor().getRegeneratingValues().get(statIndex);
(regenValues != && !regenValues.isEmpty()) {
(RegeneratingValue regeneratingValue : regenValues) {
(regeneratingValue.getRegenerating().getAmount() > ) {
(value.get() >= value.getMax()) {
;
}
} (value.get() <= value.getMin()) {
;
}
[] var32 = map.tempRegenerationValues;
var32[statIndex] += regeneratingValue.regenerate(commandBuffer, ref, now, dt, value, map.tempRegenerationValues[statIndex]);
}
}
}
}
}
}
}
( ; statIndex < size; ++statIndex) {
map.get(statIndex);
(value != ) {
map.tempRegenerationValues[statIndex];
commandBuffer.getArchetype(ref).contains(Invulnerable.getComponentType());
(amount < && !value.getIgnoreInvulnerability() && invulnerable) {
;
}
(amount != ) {
map.addStatValue(statIndex, amount);
}
}
}
}
}
<EntityStore> {
ComponentType<EntityStore, EntityStatMap> componentType;
Query<EntityStore> query;
Set<Dependency<EntityStore>> dependencies;
{
.dependencies = Set.of( (Order.BEFORE, EntityTrackerUpdate.class), (Order.AFTER, EntityStatsModule.get().getStatModifyingSystemType()));
.componentType = componentType;
.query = Query.<EntityStore>and(componentType, InteractionModule.get().getInteractionManagerComponent(), AllLegacyLivingEntityTypesQuery.INSTANCE);
}
Set<Dependency<EntityStore>> {
.dependencies;
}
Query<EntityStore> {
.query;
}
{
;
}
{
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
(EntityStatMap)archetypeChunk.getComponent(index, .componentType);
entityStatMapComponent != ;
(InteractionManager)archetypeChunk.getComponent(index, InteractionModule.get().getInteractionManagerComponent());
interactionManagerComponent != ;
archetypeChunk.getArchetype().contains(DeathComponent.getComponentType());
Int2ObjectMap<List<EntityStatUpdate>> statChanges = entityStatMapComponent.getSelfUpdates();
Int2ObjectMap<FloatList> statValues = entityStatMapComponent.getSelfStatValues();
( ; statIndex < entityStatMapComponent.size(); ++statIndex) {
List<EntityStatUpdate> updates = (List)statChanges.get(statIndex);
(updates != && !updates.isEmpty()) {
(FloatList)statValues.get(statIndex);
entityStatMapComponent.get(statIndex);
(entityStatValue != ) {
(EntityStatType)EntityStatType.getAssetMap().getAsset(statIndex);
( ; i < updates.size(); ++i) {
(EntityStatUpdate)updates.get(i);
statChangeList.getFloat(i * );
statChangeList.getFloat(i * + );
(testMaxValue(statValue, statPrevious, entityStatValue, entityStatType.getMaxValueEffects())) {
runInteractions(ref, interactionManagerComponent, entityStatType.getMaxValueEffects(), commandBuffer);
}
(testMinValue(statValue, statPrevious, entityStatValue, entityStatType.getMinValueEffects())) {
runInteractions(ref, interactionManagerComponent, entityStatType.getMinValueEffects(), commandBuffer);
}
(!isDead && statIndex == DefaultEntityStatTypes.getHealth() && !(update.value > ) && statValue <= entityStatValue.getMin()) {
DeathComponent.tryAddComponent(commandBuffer, archetypeChunk.getReferenceTo(index), (Damage.NULL_SOURCE, DamageCause.COMMAND, ));
isDead = ;
}
}
}
}
}
}
{
(valueEffects == ) {
;
} (valueEffects.triggerAtZero() && stat.getMax() > ) {
previousValue < && value >= ;
} {
previousValue != stat.getMax() && value == stat.getMax();
}
}
{
(valueEffects == ) {
;
} (valueEffects.triggerAtZero() && stat.getMin() < ) {
previousValue > && value < ;
} {
previousValue != stat.getMin() && value == stat.getMin();
}
}
{
(valueEffects != ) {
valueEffects.getInteractions();
(interactions != ) {
InteractionContext.forInteraction(interactionManager, ref, InteractionType.EntityStatEffect, componentAccessor);
interactionManager.initChain(InteractionType.EntityStatEffect, context, RootInteraction.getRootInteractionOrUnknown(interactions), );
interactionManager.queueExecuteChain(chain);
}
}
}
}
<EntityStore> {
ComponentType<EntityStore, EntityStatMap> entityStatMapComponentType;
{
.entityStatMapComponentType = entityStatMapComponentType;
}
Query<EntityStore> {
AllLegacyLivingEntityTypesQuery.INSTANCE;
}
{
EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
}
{
(LivingEntity)EntityUtils.getEntity(index, archetypeChunk);
livingEntity != ;
(EntityStatMap)archetypeChunk.getComponent(index, .entityStatMapComponentType);
entityStatMapComponent != ;
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
livingEntity.getStatModifiersManager().recalculateEntityStatModifiers(ref, entityStatMapComponent, commandBuffer);
}
}
<EntityStore> {
ComponentType<EntityStore, EntityStatMap> componentType;
ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType = EntityTrackerSystems.Visible.getComponentType();
Query<EntityStore> query;
Set<Dependency<EntityStore>> dependencies;
{
.dependencies = Set.of( (Order.BEFORE, EntityTrackerSystems.EffectControllerSystem.class), (Order.AFTER, EntityStatsModule.get().getStatModifyingSystemType()));
.componentType = componentType;
.query = Query.<EntityStore>and(.visibleComponentType, componentType);
}
SystemGroup<EntityStore> {
EntityTrackerSystems.QUEUE_UPDATE_GROUP;
}
Query<EntityStore> {
.query;
}
Set<Dependency<EntityStore>> {
.dependencies;
}
{
EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
}
{
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(index);
EntityTrackerSystems. (EntityTrackerSystems.Visible)archetypeChunk.getComponent(index, .visibleComponentType);
(EntityStatMap)archetypeChunk.getComponent(index, .componentType);
(!visible.newlyVisibleTo.isEmpty()) {
queueUpdatesForNewlyVisible(ref, statMap, visible.newlyVisibleTo);
}
(statMap.consumeSelfNetworkOutdated()) {
EntityTrackerSystems. (EntityTrackerSystems.EntityViewer)visible.visibleTo.get(ref);
(selfEntityViewer != && !visible.newlyVisibleTo.containsKey(ref)) {
();
update.type = ComponentUpdateType.EntityStats;
update.entityStatUpdates = statMap.consumeSelfUpdates();
selfEntityViewer.queueUpdate(ref, update);
}
}
(statMap.consumeNetworkOutdated()) {
();
update.type = ComponentUpdateType.EntityStats;
update.entityStatUpdates = statMap.consumeOtherUpdates();
(Map.Entry<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> entry : visible.visibleTo.entrySet()) {
Ref<EntityStore> viewerRef = (Ref)entry.getKey();
(!visible.newlyVisibleTo.containsKey(viewerRef) && !ref.equals(viewerRef)) {
((EntityTrackerSystems.EntityViewer)entry.getValue()).queueUpdate(ref, update);
}
}
}
}
{
();
update.type = ComponentUpdateType.EntityStats;
update.entityStatUpdates = statMap.createInitUpdate();
(Map.Entry<Ref<EntityStore>, EntityTrackerSystems.EntityViewer> entry : newlyVisibleTo.entrySet()) {
(ref.equals((Ref)entry.getKey())) {
queueUpdateForNewlyVisibleSelf(ref, statMap, (EntityTrackerSystems.EntityViewer)entry.getValue());
} {
((EntityTrackerSystems.EntityViewer)entry.getValue()).queueUpdate(ref, update);
}
}
}
{
();
update.type = ComponentUpdateType.EntityStats;
update.entityStatUpdates = statMap.createInitUpdate();
viewer.queueUpdate(ref, update);
}
}
<EntityStore, EntityStatMap> {
ComponentType<EntityStore, EntityStatMap> componentType;
ComponentType<EntityStore, EntityTrackerSystems.Visible> visibleComponentType = EntityTrackerSystems.Visible.getComponentType();
Query<EntityStore> query;
{
.componentType = componentType;
.query = Query.<EntityStore>and(.visibleComponentType, componentType);
}
Query<EntityStore> {
.query;
}
ComponentType<EntityStore, EntityStatMap> {
.componentType;
}
{
}
{
}
{
(EntityTrackerSystems.EntityViewer viewer : ((EntityTrackerSystems.Visible)store.getComponent(ref, .visibleComponentType)).visibleTo.values()) {
viewer.queueRemove(ref, ComponentUpdateType.EntityStats);
}
}
}
<EntityStore> {
ComponentType<EntityStore, EntityStatMap> componentType;
Set<Dependency<EntityStore>> dependencies;
{
.dependencies = Set.of( (Order.AFTER, EntityTrackerUpdate.class));
.componentType = componentType;
}
Query<EntityStore> {
.componentType;
}
Set<Dependency<EntityStore>> {
.dependencies;
}
{
EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount);
}
{
(EntityStatMap)archetypeChunk.getComponent(index, .componentType);
statMap.clearUpdates();
}
}
<EntityStore> {
}
}