-
Notifications
You must be signed in to change notification settings - Fork 0
onExpire + Ui Elements #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr/threshold-decay
Are you sure you want to change the base?
Changes from 3 commits
daa6953
66fedf4
589ff64
f8ba63f
5fc6708
c47e43a
53064b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |||||
| import com.robertx22.mine_and_slash.database.data.value_calc.LeveledValue; | ||||||
| import com.robertx22.mine_and_slash.database.registry.ExileDB; | ||||||
| import com.robertx22.mine_and_slash.database.registry.ExileRegistryTypes; | ||||||
| import com.robertx22.mine_and_slash.mmorpg.DebugHud; | ||||||
| import com.robertx22.mine_and_slash.mmorpg.SlashRef; | ||||||
| import com.robertx22.mine_and_slash.saveclasses.ExactStatData; | ||||||
| import com.robertx22.mine_and_slash.saveclasses.gearitem.gear_bases.StatRangeInfo; | ||||||
|
|
@@ -27,6 +28,7 @@ | |||||
| import com.robertx22.mine_and_slash.uncommon.localization.Words; | ||||||
| import net.minecraft.ChatFormatting; | ||||||
| import net.minecraft.network.chat.Component; | ||||||
| import net.minecraft.server.level.ServerPlayer; | ||||||
| import net.minecraft.resources.ResourceLocation; | ||||||
| import net.minecraft.world.entity.LivingEntity; | ||||||
| import net.minecraft.world.item.Item; | ||||||
|
|
@@ -252,16 +254,59 @@ public void onRemove(LivingEntity target) { | |||||
|
|
||||||
| if (data != null) { | ||||||
| LivingEntity caster = data.getCaster(target.level()); | ||||||
| if (caster != null && spell != null) { | ||||||
|
|
||||||
| if (caster == null) { | ||||||
| caster = target; | ||||||
| } | ||||||
| // --- Debug: show expire intent | ||||||
| if (DebugHud.ON_EXPIRE) { | ||||||
| if (target instanceof ServerPlayer sp) { | ||||||
| DebugHud.send(sp, "expire_onremove_" + GUID(), "[EFFECT][EXPIRE] onRemove(" + GUID() + ") stacks=" + data.stacks + ", ticks_left=" + data.ticks_left + ", infinite=" + data.is_infinite, 200); | ||||||
| } | ||||||
| if (caster instanceof ServerPlayer spc && caster != target) { | ||||||
| DebugHud.send(spc, "expire_onremove_" + GUID(), "[EFFECT][EXPIRE] Trigger from " + GUID() + " on target " + target.getName().getString(), 200); | ||||||
| } | ||||||
| } | ||||||
| if (spell != null && caster != null) { | ||||||
| SpellCtx ctx = SpellCtx.onExpire(caster, target, data.calcSpell); | ||||||
| ctx.expiringEffectId = this.GUID(); | ||||||
| ctx.onExpireEffectDurationTicks = (data.onExpireEffectDurationTicks == null) | ||||||
| ? java.util.Collections.emptyMap() | ||||||
| : java.util.Collections.unmodifiableMap(data.onExpireEffectDurationTicks); | ||||||
| spell.tryActivate(Spell.DEFAULT_EN_NAME, ctx); // source is default name at all times | ||||||
| if (DebugHud.ON_EXPIRE && target instanceof ServerPlayer sp2) { | ||||||
| DebugHud.send(sp2, "expire_dispatched_" + GUID(), "[EFFECT][EXPIRE] Dispatched attached spell for " + GUID(), 400); | ||||||
| } | ||||||
|
|
||||||
| if (!target.level().isClientSide && data.onExpireEffectDurationTicks != null && !data.onExpireEffectDurationTicks.isEmpty()) { | ||||||
| for (var entry : data.onExpireEffectDurationTicks.entrySet()) { | ||||||
| String effId = entry.getKey(); | ||||||
| int durTicks = Math.max(1, entry.getValue()); | ||||||
| if (ctx.onExpireApplied != null && ctx.onExpireApplied.contains(effId)) { | ||||||
| continue; | ||||||
| } | ||||||
| var extraEff = ExileDB.ExileEffects().get(effId); | ||||||
| if (extraEff != null) { | ||||||
| var unitT = com.robertx22.mine_and_slash.uncommon.datasaving.Load.Unit(target); | ||||||
|
||||||
| var unitT = com.robertx22.mine_and_slash.uncommon.datasaving.Load.Unit(target); | |
| var unitT = Load.Unit(target); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use EffectUtils.applyEffect instead and set other fields after this
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happens during onApply function
| unitT.equipmentCache.STATUS.setDirty(); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be done once after the for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to stop code execution early