Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,39 +15,39 @@
* 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();
private boolean cancelled;
private final List<Entity> 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);
}

/**
* Returns the entities involved in this event
*
* @return entities that are involved in this event
*/
public @NotNull List<Entity> getEntities() {
return entities;
public List<Entity> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
}

Expand Down
Loading