PaperMC/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch
CraftBukkit/Spigot 9ee989ea81 Update to Minecraft 1.18.2
By: md_5 <git@md-5.net>
2022-03-01 02:00:00 +11:00

60 lines
2.8 KiB
Diff

--- a/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
@@ -109,7 +109,17 @@
@Override
public void setTarget(@Nullable EntityLiving entityliving) {
- super.setTarget(entityliving);
+ // CraftBukkit start - fire event
+ setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
+ @Override
+ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
+ if (!super.setTarget(entityliving, reason, fireEvent)) {
+ return false;
+ }
+ entityliving = getTarget();
+ // CraftBukkit end
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
@@ -124,6 +134,7 @@
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
+ return true;
}
@@ -470,9 +481,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
world.setBlock(blockposition, iblockdata2, 3);
world.gameEvent(this.enderman, GameEvent.BLOCK_PLACE, blockposition);
this.enderman.setCarriedBlock((IBlockData) null);
+ }
+ // CraftBukkit end
}
}
@@ -511,9 +526,13 @@
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {
- world.removeBlock(blockposition, false);
- world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
- this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
+ // CraftBukkit start - Pickup event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ world.removeBlock(blockposition, false);
+ world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
+ this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
+ }
+ // CraftBukkit end
}
}