@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalBreakDoor.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalBreakDoor.java
|
||||
@@ -66,6 +66,12 @@
|
||||
}
|
||||
|
||||
if (this.a == this.f() && this.a(this.entity.world.getDifficulty())) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.entity, this.door).isCancelled()) {
|
||||
+ this.c();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.entity.world.a(this.door, false);
|
||||
this.entity.world.triggerEffect(1021, this.door, 0);
|
||||
this.entity.world.triggerEffect(2001, this.door, Block.getCombinedId(this.entity.world.getType(this.door)));
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalEatTile.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalEatTile.java
|
||||
@@ -3,6 +3,10 @@
|
||||
import java.util.EnumSet;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalEatTile extends PathfinderGoal {
|
||||
|
||||
private static final Predicate<IBlockData> a = BlockStatePredicate.a(Blocks.GRASS);
|
||||
@@ -55,7 +59,8 @@
|
||||
BlockPosition blockposition = this.b.getChunkCoordinates();
|
||||
|
||||
if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) {
|
||||
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) {
|
||||
this.c.b(blockposition, false);
|
||||
}
|
||||
|
||||
@@ -64,7 +69,8 @@
|
||||
BlockPosition blockposition1 = blockposition.down();
|
||||
|
||||
if (this.c.getType(blockposition1).a(Blocks.GRASS_BLOCK)) {
|
||||
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) {
|
||||
this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
|
||||
this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalFollowOwner.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalFollowOwner.java
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalFollowOwner extends PathfinderGoal {
|
||||
|
||||
private final EntityTameableAnimal a;
|
||||
@@ -104,7 +110,18 @@
|
||||
} else if (!this.a(new BlockPosition(i, j, k))) {
|
||||
return false;
|
||||
} else {
|
||||
- this.a.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch);
|
||||
+ // CraftBukkit start
|
||||
+ CraftEntity entity = this.a.getBukkitEntity();
|
||||
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
|
||||
+ this.a.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ to = event.getTo();
|
||||
+
|
||||
+ this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
|
||||
+ // CraftBukkit end
|
||||
this.e.o();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalPanic.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalPanic.java
|
||||
@@ -68,6 +68,12 @@
|
||||
|
||||
@Override
|
||||
public boolean b() {
|
||||
+ // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
|
||||
+ if ((this.a.ticksLived - this.a.hurtTimestamp) > 100) {
|
||||
+ this.a.setLastDamager((EntityLiving) null);
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return !this.a.getNavigation().m();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
||||
|
||||
private final Block g;
|
||||
@@ -81,6 +86,14 @@
|
||||
}
|
||||
|
||||
if (this.i > 60) {
|
||||
+ // CraftBukkit start - Step on eggs
|
||||
+ EntityInteractEvent event = new EntityInteractEvent(this.entity.getBukkitEntity(), CraftBlock.at(world, blockposition1));
|
||||
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.a(blockposition1, false);
|
||||
if (!world.isClientSide) {
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalSit.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalSit.java
|
||||
@@ -19,7 +19,7 @@
|
||||
@Override
|
||||
public boolean a() {
|
||||
if (!this.entity.isTamed()) {
|
||||
- return false;
|
||||
+ return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
|
||||
} else if (this.entity.aH()) {
|
||||
return false;
|
||||
} else if (!this.entity.isOnGround()) {
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTame.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTame.java
|
||||
@@ -57,7 +57,8 @@
|
||||
int i = this.entity.getTemper();
|
||||
int j = this.entity.getMaxDomestication();
|
||||
|
||||
- if (j > 0 && this.entity.getRandom().nextInt(j) < i) {
|
||||
+ // CraftBukkit - fire EntityTameEvent
|
||||
+ if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
|
||||
this.entity.i((EntityHuman) entity);
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTempt.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTempt.java
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalTempt extends PathfinderGoal {
|
||||
|
||||
private static final PathfinderTargetCondition c = (new PathfinderTargetCondition()).a(10.0D).a().b().d().c();
|
||||
@@ -12,7 +19,7 @@
|
||||
private double g;
|
||||
private double h;
|
||||
private double i;
|
||||
- protected EntityHuman target;
|
||||
+ protected EntityLiving target; // CraftBukkit
|
||||
private int j;
|
||||
private boolean k;
|
||||
private final RecipeItemStack l;
|
||||
@@ -40,7 +47,17 @@
|
||||
return false;
|
||||
} else {
|
||||
this.target = this.a.world.a(PathfinderGoalTempt.c, (EntityLiving) this.a);
|
||||
- return this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand());
|
||||
+ // CraftBukkit start
|
||||
+ boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand());
|
||||
+ if (tempt) {
|
||||
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.target, EntityTargetEvent.TargetReason.TEMPT);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ this.target = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
|
||||
+ }
|
||||
+ return tempt;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalDefendVillage.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalDefendVillage.java
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.a.setGoalTarget(this.b);
|
||||
+ this.a.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason
|
||||
super.c();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalHurtByTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalHurtByTarget.java
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.e.getLastDamager());
|
||||
+ this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
|
||||
this.g = this.e.getGoalTarget();
|
||||
this.c = this.e.da();
|
||||
this.h = 300;
|
||||
@@ -100,6 +100,6 @@
|
||||
}
|
||||
|
||||
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
- entityinsentient.setGoalTarget(entityliving);
|
||||
+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.c);
|
||||
+ this.e.setGoalTarget(this.c, c instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason
|
||||
super.c();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.b);
|
||||
+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.b);
|
||||
+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTarget.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
||||
+
|
||||
public abstract class PathfinderGoalTarget extends PathfinderGoal {
|
||||
|
||||
protected final EntityInsentient e;
|
||||
@@ -59,7 +61,7 @@
|
||||
if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
||||
return false;
|
||||
} else {
|
||||
- this.e.setGoalTarget(entityliving);
|
||||
+ this.e.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +82,7 @@
|
||||
|
||||
@Override
|
||||
public void d() {
|
||||
- this.e.setGoalTarget((EntityLiving) null);
|
||||
+ this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
|
||||
this.g = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user