craftbukkit/nms-patches/net/minecraft/world/entity/monster/EntityEnderman.patch

61 lines
2.9 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
2022-12-08 03:00:00 +11:00
@@ -114,7 +114,17 @@
2019-04-23 12:00:00 +10:00
@Override
2021-11-22 09:00:00 +11:00
public void setTarget(@Nullable EntityLiving entityliving) {
- super.setTarget(entityliving);
+ // CraftBukkit start - fire event
2021-11-22 09:00:00 +11:00
+ setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
+ @Override
2021-11-22 09:00:00 +11:00
+ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
+ if (!super.setTarget(entityliving, reason, fireEvent)) {
+ return false;
+ }
2021-11-22 09:00:00 +11:00
+ entityliving = getTarget();
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
2022-12-08 03:00:00 +11:00
@@ -129,6 +139,7 @@
2021-11-22 09:00:00 +11:00
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
+ return true;
}
2023-03-15 03:30:00 +11:00
@@ -487,9 +498,13 @@
2021-06-11 15:00:00 +10:00
if (iblockdata2 != null) {
2021-11-22 09:00:00 +11:00
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
2021-06-11 15:00:00 +10:00
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
2021-11-22 09:00:00 +11:00
world.setBlock(blockposition, iblockdata2, 3);
2022-06-08 02:00:00 +10:00
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this.enderman, iblockdata2));
2021-11-22 09:00:00 +11:00
this.enderman.setCarriedBlock((IBlockData) null);
2021-06-11 15:00:00 +10:00
+ }
+ // CraftBukkit end
}
}
2023-03-15 03:30:00 +11:00
@@ -528,9 +543,13 @@
2021-11-22 09:00:00 +11:00
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
2022-03-01 02:00:00 +11:00
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {
2021-11-22 09:00:00 +11:00
- world.removeBlock(blockposition, false);
2022-06-08 02:00:00 +10:00
- world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
2021-11-22 09:00:00 +11:00
- this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
2015-02-26 22:41:06 +00:00
+ // CraftBukkit start - Pickup event
2021-11-22 09:00:00 +11:00
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ world.removeBlock(blockposition, false);
2022-06-08 02:00:00 +10:00
+ world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
2021-11-22 09:00:00 +11:00
+ this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
2015-02-26 22:41:06 +00:00
+ }
+ // CraftBukkit end
}
}