-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added events to Summoning and Counterspell (#609)
* ISS CreatureSummonedEvent Added the "PlayerSummonsCreature" event, used in summoning spells. Added the "CounterSpellEvent" event, used whenever someone uses counterspell. * Fix unsafe Casting in caused by summoning event - PlayerSummonEvents -> SpellSummonEvent - SpellSummonEvents now works with a generic to avoid potential class casting issues.
- Loading branch information
1 parent
7eb8dbc
commit 54a535d
Showing
7 changed files
with
100 additions
and
30 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/io/redspace/ironsspellbooks/api/events/CounterSpellEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.redspace.ironsspellbooks.api.events; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.neoforged.bus.api.Event; | ||
import net.neoforged.bus.api.ICancellableEvent; | ||
|
||
public class CounterSpellEvent extends Event implements ICancellableEvent { | ||
public final Entity caster; | ||
public final Entity target; | ||
|
||
public CounterSpellEvent(Entity caster, Entity target){ | ||
this.caster = caster; | ||
this.target = target; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/io/redspace/ironsspellbooks/api/events/SpellSummonEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.redspace.ironsspellbooks.api.events; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.neoforged.neoforge.event.entity.living.LivingEvent; | ||
|
||
public class SpellSummonEvent<K extends LivingEntity> extends LivingEvent { | ||
private LivingEntity caster = null; | ||
private K creature = null; | ||
private final ResourceLocation spellId; | ||
private int spellLevel = 0; | ||
public SpellSummonEvent(LivingEntity caster, K creature, ResourceLocation spellId, int spellLevel) { | ||
super(caster); | ||
this.caster = caster; | ||
this.creature= creature; | ||
this.spellId = spellId; | ||
this.spellLevel = spellLevel; | ||
} | ||
|
||
public K getCreature() { | ||
return creature; | ||
} | ||
|
||
public void setCreature(K creature) { | ||
this.creature = creature; | ||
} | ||
|
||
public LivingEntity getCaster() { | ||
return caster; | ||
} | ||
|
||
public ResourceLocation getSpellId() { | ||
return spellId; | ||
} | ||
|
||
public int getSpellLevel() { | ||
return spellLevel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters