diff --git a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityPotentSulfurLaunchEvent.java b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityPotentSulfurLaunchEvent.java new file mode 100644 index 000000000000..20e847f4321b --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityPotentSulfurLaunchEvent.java @@ -0,0 +1,84 @@ +package io.papermc.paper.event.entity; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.bukkit.event.entity.EntityEvent; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +/** + * Called when an entity is launched upward by a Potent Sulfur geyser. + */ +@NullMarked +public class EntityPotentSulfurLaunchEvent extends EntityEvent implements Cancellable { + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Location sulfurLocation; + private final Location sourceLocation; + + private Vector launchVelocity; + private boolean cancelled; + + @ApiStatus.Internal + public EntityPotentSulfurLaunchEvent( + Entity entity, + Location sulfurLocation, + Location sourceLocation, + Vector launchVelocity + ) { + super(entity); + this.sulfurLocation = sulfurLocation; + this.sourceLocation = sourceLocation; + this.launchVelocity = launchVelocity; + } + + /** + * Gets the location of the Potent Sulfur block. + */ + public Location getSulfurLocation() { + return this.sulfurLocation.clone(); + } + + /** + * Gets the location where the geyser exits the water column. + */ + public Location getSourceLocation() { + return this.sourceLocation.clone(); + } + + /** + * Gets the velocity that will be added to the entity. + */ + public Vector getLaunchVelocity() { + return this.launchVelocity.clone(); + } + + /** + * Changes the velocity that will be added to the entity. + */ + public void setLaunchVelocity(Vector launchVelocity) { + this.launchVelocity = launchVelocity.clone(); + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } +} diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/PotentSulfurBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/PotentSulfurBlockEntity.java.patch new file mode 100644 index 000000000000..12deabfd88fa --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/PotentSulfurBlockEntity.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/level/block/entity/PotentSulfurBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/PotentSulfurBlockEntity.java +@@ -128,7 +_,19 @@ + && !entityToBeLaunched.isPassenger() + && !entityToBeLaunched.is(EntityTypeTags.NOT_AFFECTED_BY_GEYSERS) + && entityVelocity.y < 0.3F + waterBlocks * 0.1) { +- entityToBeLaunched.addDeltaMovement(new Vec3(0.0, 0.2F, 0.0)); ++ // Paper start - add EntityPotentSulfurLaunchEvent ++ io.papermc.paper.event.entity.EntityPotentSulfurLaunchEvent event = new io.papermc.paper.event.entity.EntityPotentSulfurLaunchEvent( ++ entityToBeLaunched.getBukkitEntity(), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level.getWorld()), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(sourceBlock, level.getWorld()), ++ new org.bukkit.util.Vector(0.0, GEYSER_LAUNCH_FORCE, 0.0) ++ ); ++ if (!event.callEvent()) { ++ continue; ++ } ++ org.bukkit.util.Vector launchVelocity = event.getLaunchVelocity(); ++ entityToBeLaunched.addDeltaMovement(org.bukkit.craftbukkit.util.CraftVector.toVec3(launchVelocity)); ++ // Paper end - add EntityPotentSulfurLaunchEvent + entityToBeLaunched.needsSync = true; + } + }