--- 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, boolean joinTeam) implements EnchantmentEntityEffect { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { @@ -34,7 +40,7 @@ Optional>> optional = this.entityTypes().getRandomElement(worldserver.getRandom()); if (!optional.isEmpty()) { - Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EnumMobSpawn.TRIGGERED); + Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EnumMobSpawn.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(entity, CreatureSpawnEvent.SpawnReason.ENCHANTMENT); + // CraftBukkit end } if (this.joinTeam && entity.getTeam() != null) {