File tree Expand file tree Collapse file tree
src/main/java/com/robertx22/mine_and_slash/database/data/spells/components/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import com .robertx22 .mine_and_slash .database .data .spells .components .MapHolder ;
44import com .robertx22 .mine_and_slash .database .data .spells .spell_classes .SpellCtx ;
5+ import com .robertx22 .mine_and_slash .database .data .spells .summons .entity .SummonEntity ;
6+ import com .robertx22 .mine_and_slash .uncommon .datasaving .Load ;
7+ import net .minecraft .world .entity .Entity ;
58import net .minecraft .world .entity .LivingEntity ;
69import net .minecraft .world .entity .player .Player ;
710
@@ -16,12 +19,15 @@ public ExpireAction() {
1619
1720 @ Override
1821 public void tryActivate (Collection <LivingEntity > targets , SpellCtx ctx , MapHolder data ) {
19- if (ctx .getPositionEntity () != null ) {
20- if (!ctx .getPositionEntity ().isRemoved ()) {
21-
22- // todo this is confusing
23- if (ctx .getPositionEntity () instanceof Player == false ) {
24- ctx .getPositionEntity ().discard (); // this can cause infi loops and even calling expire spell multiple times
22+ Entity entityToDiscard = ctx .getPositionEntity ();
23+ if (entityToDiscard != null ) {
24+ if (!entityToDiscard .isRemoved ()) {
25+ if (!(entityToDiscard instanceof Player )) {
26+ if (entityToDiscard instanceof SummonEntity summonEntity ) {
27+ Load .Unit (summonEntity ).summonedPetData .discard ((LivingEntity ) entityToDiscard );
28+ } else {
29+ entityToDiscard .discard (); // this can cause infi loops and even calling expire spell multiple times
30+ }
2531 }
2632 }
2733 }
You can’t perform that action at this time.
0 commit comments