Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
@@ -71,6 +71,12 @@
@@ -72,6 +72,12 @@
}
if (this.a == this.f() && this.a(this.entity.world.getDifficulty())) {
if (this.breakTime == this.f() && this.a(this.mob.level.getDifficulty())) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.entity, this.door).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).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)));
this.mob.level.a(this.doorPos, false);
this.mob.level.triggerEffect(1021, this.doorPos, 0);
this.mob.level.triggerEffect(2001, this.doorPos, Block.getCombinedId(this.mob.level.getType(this.doorPos)));

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
@@ -11,6 +11,10 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -12,6 +12,10 @@
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -10,24 +10,24 @@
+
public class PathfinderGoalEatTile extends PathfinderGoal {
private static final Predicate<IBlockData> a = BlockStatePredicate.a(Blocks.GRASS);
@@ -63,7 +67,8 @@
BlockPosition blockposition = this.b.getChunkCoordinates();
private static final int EAT_ANIMATION_TICKS = 40;
@@ -65,7 +69,8 @@
BlockPosition blockposition = this.mob.getChunkCoordinates();
if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) {
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getType(blockposition))) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) {
this.c.b(blockposition, false);
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
this.level.b(blockposition, false);
}
@@ -72,7 +77,8 @@
@@ -75,7 +80,8 @@
BlockPosition blockposition1 = blockposition.down();
if (this.c.getType(blockposition1).a(Blocks.GRASS_BLOCK)) {
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
if (this.level.getType(blockposition1).a(Blocks.GRASS_BLOCK)) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // 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);
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.getBlockData(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
this.level.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
this.level.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
}

View File

@@ -12,24 +12,24 @@
+
public class PathfinderGoalFollowOwner extends PathfinderGoal {
private final EntityTameableAnimal a;
@@ -117,7 +123,18 @@
public static final int TELEPORT_WHEN_DISTANCE_IS = 12;
@@ -121,7 +127,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);
- this.tamable.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
+ // 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);
+ CraftEntity entity = this.tamable.getBukkitEntity();
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
+ this.a.world.getServer().getPluginManager().callEvent(event);
+ this.tamable.level.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());
+ this.tamable.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ // CraftBukkit end
this.e.o();
this.navigation.o();
return true;
}

View File

@@ -10,17 +10,17 @@
+
public class PathfinderGoalPanic extends PathfinderGoal {
protected final EntityCreature a;
protected final EntityCreature mob;
@@ -76,6 +80,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);
+ if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) {
+ this.mob.setLastDamager((EntityLiving) null);
+ return false;
+ }
+ // CraftBukkit end
return !this.a.getNavigation().m();
return !this.mob.getNavigation().m();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
@@ -20,6 +20,11 @@
@@ -21,6 +21,11 @@
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.phys.Vec3D;
@@ -11,13 +11,13 @@
+
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
private final Block g;
@@ -98,6 +103,14 @@
private final Block blockToRemove;
@@ -100,6 +105,14 @@
}
if (this.i > 60) {
if (this.ticksSinceReachedGoal > 60) {
+ // CraftBukkit start - Step on eggs
+ EntityInteractEvent event = new EntityInteractEvent(this.entity.getBukkitEntity(), CraftBlock.at(world, blockposition1));
+ EntityInteractEvent event = new EntityInteractEvent(this.removerMob.getBukkitEntity(), CraftBlock.at(world, blockposition1));
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) event);
+
+ if (event.isCancelled()) {

View File

@@ -3,9 +3,9 @@
@@ -22,7 +22,7 @@
@Override
public boolean a() {
if (!this.entity.isTamed()) {
if (!this.mob.isTamed()) {
- return false;
+ return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
} else if (this.entity.aH()) {
+ return this.mob.isWillSit() && this.mob.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
} else if (this.mob.aO()) {
return false;
} else if (!this.entity.isOnGround()) {
} else if (!this.mob.isOnGround()) {

View File

@@ -1,12 +1,12 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
@@ -62,7 +62,8 @@
int i = this.entity.getTemper();
int j = this.entity.getMaxDomestication();
int i = this.horse.getTemper();
int j = this.horse.getMaxDomestication();
- if (j > 0 && this.entity.getRandom().nextInt(j) < i) {
- if (j > 0 && this.horse.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);
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
this.horse.i((EntityHuman) entity);
return;
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
@@ -11,6 +11,13 @@
import net.minecraft.world.item.ItemStack;
@@ -8,6 +8,13 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.item.crafting.RecipeItemStack;
+// CraftBukkit start
@@ -13,32 +13,29 @@
+
public class PathfinderGoalTempt extends PathfinderGoal {
private static final PathfinderTargetCondition c = (new PathfinderTargetCondition()).a(10.0D).a().b().d().c();
@@ -21,7 +28,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;
@@ -49,7 +56,17 @@
private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.b().a(10.0D).d();
@@ -19,7 +26,7 @@
private double pz;
private double pRotX;
private double pRotY;
- protected EntityHuman player;
+ protected EntityLiving player; // CraftBukkit
private int calmDown;
private boolean isRunning;
private final RecipeItemStack items;
@@ -41,6 +48,15 @@
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());
this.player = this.mob.level.a(this.targetingConditions, (EntityLiving) this.mob);
+ // 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 (this.player != null) {
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT);
+ if (event.isCancelled()) {
+ return false;
+ }
+ this.target = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
+ this.player = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
+ }
+ return tempt;
+ // CraftBukkit end
return this.player != null;
}
}

View File

@@ -4,8 +4,8 @@
@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
- this.golem.setGoalTarget(this.potentialTarget);
+ this.golem.setGoalTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason
super.c();
}
}

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java
@@ -62,7 +62,7 @@
@@ -64,7 +64,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;
@@ -109,6 +109,6 @@
- this.mob.setGoalTarget(this.mob.getLastDamager());
+ this.mob.setGoalTarget(this.mob.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
this.targetMob = this.mob.getGoalTarget();
this.timestamp = this.mob.dH();
this.unseenMemoryTicks = 300;
@@ -111,6 +111,6 @@
}
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
@@ -59,7 +59,7 @@
@@ -61,7 +61,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
- this.mob.setGoalTarget(this.target);
+ this.mob.setGoalTarget(this.target, target instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason
super.c();
}

View File

@@ -4,8 +4,8 @@
@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();
- this.mob.setGoalTarget(this.ownerLastHurtBy);
+ this.mob.setGoalTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason
EntityLiving entityliving = this.tameAnimal.getOwner();
if (entityliving != null) {

View File

@@ -4,8 +4,8 @@
@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();
- this.mob.setGoalTarget(this.ownerLastHurt);
+ this.mob.setGoalTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason
EntityLiving entityliving = this.tameAnimal.getOwner();
if (entityliving != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
@@ -13,6 +13,8 @@
@@ -11,6 +11,8 @@
import net.minecraft.world.level.pathfinder.PathPoint;
import net.minecraft.world.scores.ScoreboardTeamBase;
@@ -8,22 +8,22 @@
+
public abstract class PathfinderGoalTarget extends PathfinderGoal {
protected final EntityInsentient e;
@@ -70,7 +72,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;
private static final int EMPTY_REACH_CACHE = 0;
@@ -68,7 +70,7 @@
}
}
- this.mob.setGoalTarget(entityliving);
+ this.mob.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit
return true;
}
@@ -91,7 +93,7 @@
}
@@ -88,7 +90,7 @@
@Override
public void d() {
- this.e.setGoalTarget((EntityLiving) null);
+ this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
this.g = null;
- this.mob.setGoalTarget((EntityLiving) null);
+ this.mob.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
this.targetMob = null;
}