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
@@ -0,0 +1,50 @@
package io.papermc.paper.event.entity;

import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Dispenser;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Called when a block, like a dispenser, places an
* entity. {@link #getPlayer()} will always be {@code null}.
*
* @see org.bukkit.event.hanging.HangingPlaceEvent for paintings, item frames, and leashes.
* @see org.bukkit.event.entity.EntityPlaceEvent for a player-only version with more context
* @see PlaceEntityEvent to listen to both blocks and players placing entities
*/
@NullMarked
public class BlockPlaceEntityEvent extends PlaceEntityEvent {

private final Dispenser dispenser;

@ApiStatus.Internal
public BlockPlaceEntityEvent(final Entity entity, final Block block, final BlockFace blockFace, final ItemStack spawningItem, final Dispenser dispenser) {
super(entity, null, block, blockFace, spawningItem);
this.dispenser = dispenser;
}

/**
* Get the dispenser responsible for placing the entity.
*
* @return a non-snapshot Dispenser
*/
public Dispenser getDispenser() {
return this.dispenser;
}

/**
* Player will always be null on this event.
*/
@Override
@Contract("-> null")
public @Nullable Player getPlayer() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package io.papermc.paper.event.entity;

import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Triggered when an entity is created in the world by "placing" an item
* on a block from a player or dispenser.
* <br>
* Note that this event is currently only fired for these specific placements:
* armor stands, boats, minecarts, end crystals, mob buckets, spawn eggs and tnt (dispenser only).
*
* @see org.bukkit.event.hanging.HangingPlaceEvent for paintings, item frames, and leashes.
* @see org.bukkit.event.entity.EntityPlaceEvent for a player-only version with more context
* @see BlockPlaceEntityEvent for a dispenser-only version with more context
*/
@NullMarked
public abstract class PlaceEntityEvent extends EntityEvent implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();

private final @Nullable Player player;
private final Block block;
private final BlockFace blockFace;
private final ItemStack spawningItem;
private boolean cancelled;

protected PlaceEntityEvent(final Entity entity, final @Nullable Player player, final Block block, final BlockFace blockFace, final ItemStack spawningItem) {
super(entity);
this.player = player;
this.block = block;
this.blockFace = blockFace;
this.spawningItem = spawningItem;
}

/**
* {@return the player placing the entity (if available)}
*/
public @Nullable Player getPlayer() {
return this.player;
}

/**
* {@return the block that the entity was placed on}
*/
public Block getBlock() {
return this.block;
}

/**
* {@return the face of the block that the entity was placed on}
*/
public BlockFace getBlockFace() {
return this.blockFace;
}

/**
* Gets the item responsible for spawning the entity. Mutating
* this item has no effect.
* <p>
* May return an empty item if not available.
*
* @return the spawning item
*/
public ItemStack getSpawningItem() {
return this.spawningItem.clone();
}

@Override
public boolean isCancelled() {
return this.cancelled;
}

@Override
public void setCancelled(final boolean cancel) {
this.cancelled = cancel;
}

@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}
Original file line number Diff line number Diff line change
@@ -1,107 +1,76 @@
package org.bukkit.event.entity;

import io.papermc.paper.event.entity.PlaceEntityEvent;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* Triggered when an entity is created in the world by a player "placing" an item
* on a block.
* <br>
* Note that this event is currently only fired for four specific placements:
* armor stands, boats, minecarts, and end crystals.
* Note that this event is currently only fired for these specific placements:
* armor stands, boats, minecarts, end crystals, spawn eggs and mob buckets.
*
* @see org.bukkit.event.hanging.HangingPlaceEvent for paintings, item frames, and leashes.
* @see io.papermc.paper.event.entity.BlockPlaceEntityEvent for a dispenser-only version
* @see io.papermc.paper.event.entity.PlaceEntityEvent to listen to both blocks and players placing entities
*/
public class EntityPlaceEvent extends EntityEvent implements Cancellable {
@NullMarked
public class EntityPlaceEvent extends PlaceEntityEvent {

private static final HandlerList HANDLER_LIST = new HandlerList();

private final Player player;
private final Block block;
private final BlockFace blockFace;
private final EquipmentSlot hand;

private boolean cancelled;

@ApiStatus.Internal
public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace, @NotNull final EquipmentSlot hand) {
super(entity);
this.player = player;
this.block = block;
this.blockFace = blockFace;
public EntityPlaceEvent(
final Entity entity,
final @Nullable Player player,
final Block block,
final BlockFace blockFace,
final EquipmentSlot hand,
final ItemStack spawningItem
) {
super(entity, player, block, blockFace, spawningItem);
this.hand = hand;
}

@ApiStatus.Internal
@Deprecated(since = "1.19.2", forRemoval = true)
public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) {
this(entity, player, block, blockFace, EquipmentSlot.HAND);
}

/**
* Returns the player placing the entity
*
* @return the player placing the entity
*/
@Nullable
public Player getPlayer() {
return this.player;
@Override
public @Nullable Player getPlayer() {
return super.getPlayer();
}

/**
* Returns the block that the entity was placed on
*
* @return the block that the entity was placed on
*/
@NotNull
@Override
public Block getBlock() {
return this.block;
return super.getBlock();
}

/**
* Returns the face of the block that the entity was placed on
*
* @return the face of the block that the entity was placed on
*/
@NotNull
@Override
public BlockFace getBlockFace() {
return this.blockFace;
return super.getBlockFace();
}

/**
* Get the hand used to place the entity.
*
* @return the hand
*/
@NotNull
public EquipmentSlot getHand() {
return this.hand;
}

@Override
public boolean isCancelled() {
return this.cancelled;
return super.isCancelled();
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

@NotNull
public static HandlerList getHandlerList() {
return HANDLER_LIST;
public void setCancelled(final boolean cancel) {
super.setCancelled(cancel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected TypeSpec getTypeSpec() {
.returns(ParameterizedTypeName.get(ClassName.get(GoalKey.class), type));

List<Class<Goal>> classes;
try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages("net.minecraft").scan()) {
try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages("net.minecraft").scan()) {
classes = scanResult.getSubclasses(Goal.class.getName()).loadClasses(Goal.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MobGoalConverterTest {
@Test
public void testBukkitMap() {
final List<Class<Mob>> classes;
try (ScanResult scanResult = new ClassGraph().enableClassInfo().whitelistPackages(Entity.class.getPackageName()).scan()) {
try (ScanResult scanResult = new ClassGraph().enableClassInfo().acceptPackages(Entity.class.getPackageName()).scan()) {
classes = scanResult.getSubclasses(Mob.class.getName()).loadClasses(Mob.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28453,7 +28453,7 @@ index c974b6cafb1f6aa2a57cfdc8a39c887f02f42b1d..ec40f02032f965f548b0c0a29aa9d9bb
// Paper start - PlayerChunkLoadEvent
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
diff --git a/net/minecraft/server/network/config/PrepareSpawnTask.java b/net/minecraft/server/network/config/PrepareSpawnTask.java
index 83af9ee3ba150da85b9b694cd76a5fabb5b2d8ef..1fb40837bd02672850ec9adc2797190df22b33fc 100644
index b5d993095aa77bb132c513f73dbf6d2afb2e3943..8b318dd8aa918284c5fa89e990b13bec425102cb 100644
--- a/net/minecraft/server/network/config/PrepareSpawnTask.java
+++ b/net/minecraft/server/network/config/PrepareSpawnTask.java
@@ -171,7 +171,7 @@ public class PrepareSpawnTask implements ConfigurationTask {
Expand Down Expand Up @@ -28885,7 +28885,7 @@ index 1ceb7e4a3abd4d9de5133d182d3267d2164918f6..eb2fa32cff6824c14f865c8731df7d08
+ // Paper end - block counting
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4e81a3d3a 100644
index 9ab04735f1091ca73a2f6bd03368ad0f60ca6751..b52e3428e18d8580080e4185bd48901ee965aa01 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -167,7 +167,7 @@ public abstract class Entity
Expand Down Expand Up @@ -29136,7 +29136,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4

public Entity(final EntityType<?> type, final Level level) {
this.type = type;
@@ -1421,34 +1527,76 @@ public abstract class Entity
@@ -1423,34 +1529,76 @@ public abstract class Entity
}

private Vec3 collide(final Vec3 movement) {
Expand Down Expand Up @@ -29236,7 +29236,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
}

private static float[] collectCandidateStepUpHeights(
@@ -2738,21 +2886,110 @@ public abstract class Entity
@@ -2740,21 +2888,110 @@ public abstract class Entity
}

public boolean isInWall() {
Expand Down Expand Up @@ -29358,7 +29358,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
}

public InteractionResult interact(final Player player, final InteractionHand hand, final Vec3 location) {
@@ -4363,15 +4600,17 @@ public abstract class Entity
@@ -4365,15 +4602,17 @@ public abstract class Entity
}

public Iterable<Entity> getIndirectPassengers() {
Expand All @@ -29384,7 +29384,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
}

public int countPlayerPassengers() {
@@ -4682,6 +4921,15 @@ public abstract class Entity
@@ -4684,6 +4923,15 @@ public abstract class Entity
}

public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) {
Expand All @@ -29400,7 +29400,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
if (!checkPosition(this, x, y, z)) {
return;
}
@@ -4831,6 +5079,12 @@ public abstract class Entity
@@ -4833,6 +5081,12 @@ public abstract class Entity

@Override
public final void setRemoved(final Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.@Nullable Cause cause) { // CraftBukkit - add Bukkit remove cause
Expand All @@ -29413,7 +29413,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
if (this.removalReason == null) {
@@ -4841,7 +5095,7 @@ public abstract class Entity
@@ -4843,7 +5097,7 @@ public abstract class Entity
this.stopRiding();
}

Expand All @@ -29422,7 +29422,7 @@ index 29896cb17fcf8ab967a937e9b0e102a8354b6889..e087d5596979044fe7fbcf7f2cccdae4
this.levelCallback.onRemove(reason);
this.onRemoval(reason);
// Paper start - Folia schedulers
@@ -4875,7 +5129,7 @@ public abstract class Entity
@@ -4877,7 +5131,7 @@ public abstract class Entity
public boolean shouldBeSaved() {
return (this.removalReason == null || this.removalReason.shouldSave())
&& !this.isPassenger()
Expand Down Expand Up @@ -31851,7 +31851,7 @@ index 9404f0b0b03dce54e2c9ad6ca2c36354888cc9f5..a0d7f6f8ecbc320267bdad27315fc2e2

public interface NoiseBiomeSource {
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
index 7678701a578d2dc45b35da072a0bb2c027522043..41aab9a526be77b400bed7a74614eceec95345b5 100644
index a3fd479b67a880a513281faf5cdf51d0d0c2d963..24bc5559f11997c674fe09dae0c7828455ba66ae 100644
--- a/net/minecraft/world/level/block/Block.java
+++ b/net/minecraft/world/level/block/Block.java
@@ -366,7 +366,7 @@ public class Block extends BlockBehaviour implements ItemLike {
Expand Down
Loading
Loading