0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 08:56:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.patch

37 lines
1.9 KiB
Diff

--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -20,6 +20,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.world.item.Items;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+// CraftBukkit end
+
public record SummonEntityEffect(HolderSet<EntityTypes<?>> entityTypes, boolean joinTeam) implements EnchantmentEntityEffect {
public static final MapCodec<SummonEntityEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -34,7 +40,7 @@
Optional<Holder<EntityTypes<?>>> optional = this.entityTypes().getRandomElement(worldserver.getRandom());
if (!optional.isEmpty()) {
- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EntitySpawnReason.TRIGGERED);
+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit
if (entity1 != null) {
if (entity1 instanceof EntityLightning) {
@@ -46,6 +52,11 @@
entitylightning.setCause(entityplayer);
}
+ // CraftBukkit start
+ worldserver.strikeLightning(entity1, (enchantediteminuse.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT);
+ } else {
+ worldserver.addFreshEntityWithPassengers(entity1, CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ // CraftBukkit end
}
if (this.joinTeam && entity.getTeam() != null) {