Skip to content

Commit

Permalink
Add CastSource to SpellCastEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvertide7 authored and iron431 committed Oct 4, 2023
1 parent 1808445 commit 77dda68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.redspace.ironsspellbooks.api.events;


import io.redspace.ironsspellbooks.api.spells.CastSource;
import io.redspace.ironsspellbooks.api.spells.SchoolType;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -20,18 +21,21 @@
public class SpellCastEvent extends PlayerEvent {
private final String spellId;
private final SchoolType schoolType;
private final CastSource castSource;
private final int spellLevel;
public SpellCastEvent(Player player, String spellId, int spellLevel, SchoolType schoolType)
public SpellCastEvent(Player player, String spellId, int spellLevel, SchoolType schoolType, CastSource castSource)
{
super(player);
this.spellId = spellId;
this.spellLevel = spellLevel;
this.schoolType = schoolType;
this.castSource = castSource;
}

@Override
public boolean isCancelable() { return true; }
public String getSpellId() { return this.spellId; }
public SchoolType getSchoolType() { return this.schoolType; }
public int getSpellLevel() { return this.spellLevel; }
public CastSource getCastSource() { return this.castSource; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public boolean attemptInitiateCast(ItemStack stack, int spellLevel, Level level,
return false;
}

if (MinecraftForge.EVENT_BUS.post(new SpellCastEvent(player, this.getSpellId(), spellLevel, getSchoolType())))
if (MinecraftForge.EVENT_BUS.post(new SpellCastEvent(player, this.getSpellId(), spellLevel, getSchoolType(), castSource)))
return false;

if (!checkPreCastConditions(level, serverPlayer, playerMagicData))
Expand Down

0 comments on commit 77dda68

Please sign in to comment.