Paper/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch
CraftBukkit/Spigot b3a8254758 Update to Minecraft 1.17
By: md_5 <git@md-5.net>
2021-06-11 15:00:00 +10:00

61 lines
2.8 KiB
Diff

--- a/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
@@ -105,7 +105,17 @@
@Override
public void setGoalTarget(@Nullable EntityLiving entityliving) {
- super.setGoalTarget(entityliving);
+ // CraftBukkit start - fire event
+ setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
+ @Override
+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
+ if (!super.setGoalTarget(entityliving, reason, fireEvent)) {
+ return false;
+ }
+ entityliving = getGoalTarget();
+ // CraftBukkit end
AttributeModifiable attributemodifiable = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
@@ -120,6 +130,7 @@
attributemodifiable.b(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
+ return true;
}
@@ -446,9 +457,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.enderman.level, blockposition);
if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
world.setTypeAndData(blockposition, iblockdata2, 3);
world.a((Entity) this.enderman, GameEvent.BLOCK_PLACE, blockposition);
this.enderman.setCarried((IBlockData) null);
+ }
+ // CraftBukkit end
}
}
@@ -487,9 +502,13 @@
boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition);
if (iblockdata.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) {
- world.a(blockposition, false);
- world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
- this.enderman.setCarried(iblockdata.getBlock().getBlockData());
+ // CraftBukkit start - Pickup event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ world.a(blockposition, false);
+ world.a((Entity) this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
+ this.enderman.setCarried(iblockdata.getBlock().getBlockData());
+ }
+ // CraftBukkit end
}
}