mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
#723: Implement EntitySpellCastEvent for spellcaster illager
This commit is contained in:
parent
1e76d09fad
commit
82542d01d8
3 changed files with 34 additions and 2 deletions
14
nms-patches/EntityIllagerWizard.patch
Normal file
14
nms-patches/EntityIllagerWizard.patch
Normal file
|
@ -0,0 +1,14 @@
|
|||
--- a/net/minecraft/server/EntityIllagerWizard.java
|
||||
+++ b/net/minecraft/server/EntityIllagerWizard.java
|
||||
@@ -145,6 +145,11 @@
|
||||
public void e() {
|
||||
--this.b;
|
||||
if (this.b == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, l())) { // PAIL rename getSpell
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.j();
|
||||
EntityIllagerWizard.this.playSound(EntityIllagerWizard.this.getSoundCastSpell(), 1.0F, 1.0F);
|
||||
}
|
|
@ -23,13 +23,21 @@ public class CraftSpellcaster extends CraftIllager implements Spellcaster {
|
|||
|
||||
@Override
|
||||
public Spell getSpell() {
|
||||
return Spell.valueOf(getHandle().getSpell().name());
|
||||
return toBukkitSpell(getHandle().getSpell());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpell(Spell spell) {
|
||||
Preconditions.checkArgument(spell != null, "Use Spell.NONE");
|
||||
|
||||
getHandle().setSpell(EntityIllagerWizard.Spell.a(spell.ordinal()));
|
||||
getHandle().setSpell(toNMSSpell(spell));
|
||||
}
|
||||
|
||||
public static Spell toBukkitSpell(EntityIllagerWizard.Spell spell) {
|
||||
return Spell.valueOf(spell.name());
|
||||
}
|
||||
|
||||
public static EntityIllagerWizard.Spell toNMSSpell(Spell spell) {
|
||||
return EntityIllagerWizard.Spell.a(spell.ordinal());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.server.EntityFireworks;
|
|||
import net.minecraft.server.EntityGhast;
|
||||
import net.minecraft.server.EntityGolem;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityIllagerWizard;
|
||||
import net.minecraft.server.EntityInsentient;
|
||||
import net.minecraft.server.EntityItem;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
|
@ -90,6 +91,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
|
|||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.entity.CraftRaider;
|
||||
import org.bukkit.craftbukkit.entity.CraftSpellcaster;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaBook;
|
||||
|
@ -114,6 +116,7 @@ import org.bukkit.entity.PigZombie;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Raider;
|
||||
import org.bukkit.entity.Spellcaster;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
|
@ -148,6 +151,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||
import org.bukkit.event.entity.EntityBreedEvent;
|
||||
import org.bukkit.event.entity.EntitySpellCastEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
@ -1588,4 +1592,10 @@ public class CraftEventFactory {
|
|||
StriderTemperatureChangeEvent event = new StriderTemperatureChangeEvent((Strider) strider.getBukkitEntity(), shivering);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public static boolean handleEntitySpellCastEvent(EntityIllagerWizard caster, EntityIllagerWizard.Spell spell) {
|
||||
EntitySpellCastEvent event = new EntitySpellCastEvent((Spellcaster) caster.getBukkitEntity(), CraftSpellcaster.toBukkitSpell(spell));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue