From 6bdfebffae8f325e4e42a501e667ef18e2774949 Mon Sep 17 00:00:00 2001 From: Doc Date: Fri, 7 Aug 2026 11:00:59 -0400 Subject: [PATCH] Call EntityCollideWithEntityEvent for Sulfur Cube pushed by Player --- .../entity/EntityCollideWithEntityEvent.java | 18 +++++++++--------- .../monster/cubemob/SulfurCube.java.patch | 11 +++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityCollideWithEntityEvent.java b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityCollideWithEntityEvent.java index 82250ddb1f3d..9461adedcdef 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityCollideWithEntityEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityCollideWithEntityEvent.java @@ -1,12 +1,12 @@ package io.papermc.paper.event.entity; +import java.util.List; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; -import java.util.List; +import org.jspecify.annotations.NullMarked; /** * Fired when two entities collide with each other. @@ -15,6 +15,7 @@ * Note that even if cancelled, the client may still run its own collision unless * disabled via player teams. */ +@NullMarked public class EntityCollideWithEntityEvent extends Event implements Cancellable { private static final HandlerList HANDLER_LIST = new HandlerList(); @@ -22,8 +23,8 @@ public class EntityCollideWithEntityEvent extends Event implements Cancellable { private final List entities; @ApiStatus.Internal - public EntityCollideWithEntityEvent(@NotNull Entity entity1, @NotNull Entity entity2) { - entities = List.of(entity1, entity2); + public EntityCollideWithEntityEvent(final Entity entity1, final Entity entity2) { + this.entities = List.of(entity1, entity2); } /** @@ -31,23 +32,22 @@ public EntityCollideWithEntityEvent(@NotNull Entity entity1, @NotNull Entity ent * * @return entities that are involved in this event */ - public @NotNull List getEntities() { - return entities; + public List getEntities() { + return this.entities; } @Override - public @NotNull HandlerList getHandlers() { + public HandlerList getHandlers() { return HANDLER_LIST; } - @NotNull public static HandlerList getHandlerList() { return HANDLER_LIST; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch index 87cf67beb774..c0f6660a9e82 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/cubemob/SulfurCube.java.patch @@ -156,6 +156,17 @@ this.playSound(this.getEjectSound()); this.pickupTimer = 100; } +@@ -748,6 +_,10 @@ + double sulfurCubeTopPosition = sulfurCubeBottomPosition + this.getBbHeight(); + double pusherTopPosition = pusherFeetPosition + pusher.getBbHeight(); + if (cubeToPusher.horizontalDistance() < 1.3F && pusherFeetPosition <= sulfurCubeTopPosition && pusherTopPosition > sulfurCubeBottomPosition) { ++ // Paper start - Add EntityCollideWithEntity Event ++ if (io.papermc.paper.event.entity.EntityCollideWithEntityEvent.getHandlerList().getRegisteredListeners().length != 0 && ++ !new io.papermc.paper.event.entity.EntityCollideWithEntityEvent(this.getBukkitEntity(), pusher.getBukkitEntity()).callEvent()) return; ++ // Paper end - Add EntityCollideWithEntity Event + double knockback = Math.max(0.0, 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); + Vec3 pushDirection = cubeToPusher.horizontal().normalize().scale(knockback); + float pushSpeedScale = player.isPassenger() ? 0.16F : 0.3F; @@ -827,7 +_,7 @@ }