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

66 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
2023-06-24 17:15:05 +10:00
@@ -70,6 +70,11 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityEnderman extends EntityMonster implements IEntityAngerable {
private static final UUID SPEED_MODIFIER_ATTACKING_UUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
@@ -114,7 +119,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
2023-06-24 17:15:05 +10:00
+ setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
+ }
+
+ @Override
2023-06-24 17:15:05 +10:00
+ public boolean setTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
2021-11-22 09:00:00 +11:00
+ 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) {
2023-06-24 17:15:05 +10:00
@@ -129,6 +144,7 @@
2021-11-22 09:00:00 +11:00
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
+ return true;
}
2023-06-24 17:15:05 +10:00
@@ -487,9 +503,11 @@
2021-06-11 15:00:00 +10:00
if (iblockdata2 != null) {
2023-06-08 01:30:00 +10:00
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
2021-11-22 09:00:00 +11:00
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
2023-06-24 17:15:05 +10:00
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2)) { // CraftBukkit - Place event
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);
2023-06-24 17:15:05 +10:00
+ } // CraftBukkit
2021-06-11 15:00:00 +10:00
}
}
2023-06-24 17:15:05 +10:00
@@ -528,9 +546,11 @@
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) {
2023-06-24 17:15:05 +10:00
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState())) { // CraftBukkit - Place event
world.removeBlock(blockposition, false);
world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
+ } // CraftBukkit
2015-02-26 22:41:06 +00:00
}
}