diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index cb5a91d416..014f36de47 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -393,7 +393,7 @@ } protected final AABB makeBoundingBox() { -@@ -462,6 +716,15 @@ +@@ -462,10 +716,20 @@ this.baseTick(); } @@ -409,7 +409,12 @@ public void baseTick() { ProfilerFiller gameprofilerfiller = Profiler.get(); -@@ -475,7 +738,7 @@ + gameprofilerfiller.push("entityBaseTick"); ++ if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups + this.inBlockState = null; + if (this.isPassenger() && this.getVehicle().isRemoved()) { + this.stopRiding(); +@@ -475,7 +739,7 @@ --this.boardingCooldown; } @@ -418,7 +423,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -502,7 +765,7 @@ +@@ -502,7 +766,7 @@ this.setRemainingFireTicks(this.remainingFireTicks - 1); } @@ -427,7 +432,7 @@ this.setTicksFrozen(0); this.level().levelEvent((Player) null, 1009, this.blockPosition, 1); } -@@ -514,6 +777,10 @@ +@@ -514,6 +778,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -438,7 +443,7 @@ } this.checkBelowWorld(); -@@ -525,7 +792,7 @@ +@@ -525,7 +793,7 @@ world = this.level(); if (world instanceof ServerLevel worldserver) { if (this instanceof Leashable) { @@ -447,7 +452,7 @@ } } -@@ -537,7 +804,11 @@ +@@ -537,7 +805,11 @@ } public void checkBelowWorld() { @@ -460,7 +465,7 @@ this.onBelowWorld(); } -@@ -568,15 +839,32 @@ +@@ -568,15 +840,32 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -495,7 +500,7 @@ } } -@@ -587,9 +875,25 @@ +@@ -587,9 +876,25 @@ } public final void igniteForSeconds(float seconds) { @@ -522,7 +527,7 @@ public void igniteForTicks(int ticks) { if (this.remainingFireTicks < ticks) { this.setRemainingFireTicks(ticks); -@@ -610,7 +914,7 @@ +@@ -610,7 +915,7 @@ } protected void onBelowWorld() { @@ -531,7 +536,7 @@ } public boolean isFree(double offsetX, double offsetY, double offsetZ) { -@@ -750,6 +1054,28 @@ +@@ -750,6 +1055,28 @@ } } @@ -560,7 +565,7 @@ if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { Entity.MovementEmission entity_movementemission = this.getMovementEmission(); -@@ -1131,8 +1457,22 @@ +@@ -1131,8 +1458,22 @@ protected SoundEvent getSwimHighSpeedSplashSound() { return SoundEvents.GENERIC_SPLASH; @@ -583,7 +588,7 @@ public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) { this.movementThisTick.add(new Entity.Movement(oldPos, newPos)); } -@@ -1599,6 +1939,7 @@ +@@ -1599,6 +1940,7 @@ this.setXRot(Mth.clamp(pitch, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -591,7 +596,7 @@ } public void absMoveTo(double x, double y, double z) { -@@ -1609,6 +1950,7 @@ +@@ -1609,6 +1951,7 @@ this.yo = y; this.zo = d4; this.setPos(d3, y, d4); @@ -599,7 +604,7 @@ } public void moveTo(Vec3 pos) { -@@ -1628,11 +1970,19 @@ +@@ -1628,11 +1971,19 @@ } public void moveTo(double x, double y, double z, float yaw, float pitch) { @@ -619,7 +624,7 @@ } public final void setOldPosAndRot() { -@@ -1701,6 +2051,7 @@ +@@ -1701,6 +2052,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -627,7 +632,7 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = Mth.absMax(d0, d1); -@@ -1737,7 +2088,21 @@ +@@ -1737,7 +2089,21 @@ } public void push(double deltaX, double deltaY, double deltaZ) { @@ -650,7 +655,7 @@ this.hasImpulse = true; } -@@ -1858,8 +2223,20 @@ +@@ -1858,9 +2224,21 @@ } public boolean isPushable() { @@ -661,17 +666,18 @@ + public boolean isCollidable(boolean ignoreClimbing) { + // Paper end - Climbing should not bypass cramming gamerule return false; -+ } -+ + } + + // CraftBukkit start - collidable API + public boolean canCollideWithBukkit(Entity entity) { + return this.isPushable(); - } ++ } + // CraftBukkit end - ++ public void awardKillScore(Entity entityKilled, DamageSource damageSource) { if (entityKilled instanceof ServerPlayer) { -@@ -1889,74 +2266,133 @@ + CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource); +@@ -1889,74 +2267,133 @@ } public boolean saveAsPassenger(CompoundTag nbt) { @@ -828,7 +834,7 @@ } ListTag nbttaglist; -@@ -1972,10 +2408,10 @@ +@@ -1972,10 +2409,10 @@ nbttaglist.add(StringTag.valueOf(s)); } @@ -841,7 +847,7 @@ if (this.isVehicle()) { nbttaglist = new ListTag(); iterator = this.getPassengers().iterator(); -@@ -1984,17 +2420,44 @@ +@@ -1984,17 +2421,44 @@ Entity entity = (Entity) iterator.next(); CompoundTag nbttagcompound1 = new CompoundTag(); @@ -889,10 +895,11 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); -@@ -2080,6 +2543,71 @@ +@@ -2079,7 +2543,72 @@ + } } else { throw new IllegalStateException("Entity has invalid position"); - } ++ } + + // CraftBukkit start + // Spigot start @@ -949,7 +956,7 @@ + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL; + } + } -+ } + } + if (spawnReason == null) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; + } @@ -961,7 +968,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -2101,6 +2629,12 @@ +@@ -2101,6 +2630,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -974,7 +981,7 @@ protected abstract void readAdditionalSaveData(CompoundTag nbt); protected abstract void addAdditionalSaveData(CompoundTag nbt); -@@ -2153,9 +2687,23 @@ +@@ -2153,9 +2688,23 @@ if (stack.isEmpty()) { return null; } else { @@ -999,7 +1006,7 @@ world.addFreshEntity(entityitem); return entityitem; } -@@ -2184,7 +2732,16 @@ +@@ -2184,7 +2733,16 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1017,7 +1024,7 @@ leashable.removeLeash(); } else { leashable.dropLeash(); -@@ -2200,6 +2757,13 @@ +@@ -2200,6 +2758,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -1031,7 +1038,7 @@ leashable.setLeashedTo(player, true); } -@@ -2265,15 +2829,15 @@ +@@ -2265,15 +2830,15 @@ } public boolean showVehicleHealth() { @@ -1050,7 +1057,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2285,11 +2849,32 @@ +@@ -2285,11 +2850,32 @@ if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -1084,7 +1091,7 @@ this.vehicle = entity; this.vehicle.addPassenger(this); entity.getIndirectPassengersStream().filter((entity2) -> { -@@ -2314,19 +2899,30 @@ +@@ -2314,19 +2900,30 @@ } public void removeVehicle() { @@ -1117,7 +1124,7 @@ protected void addPassenger(Entity passenger) { if (passenger.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); -@@ -2349,21 +2945,53 @@ +@@ -2349,21 +2946,53 @@ } } @@ -1177,7 +1184,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2464,7 +3092,7 @@ +@@ -2464,7 +3093,7 @@ if (teleporttransition != null) { ServerLevel worldserver1 = teleporttransition.newLevel(); @@ -1186,7 +1193,7 @@ this.teleport(teleporttransition); } } -@@ -2547,7 +3175,7 @@ +@@ -2547,7 +3176,7 @@ } public boolean isCrouching() { @@ -1195,7 +1202,7 @@ } public boolean isSprinting() { -@@ -2563,7 +3191,7 @@ +@@ -2563,7 +3192,7 @@ } public boolean isVisuallySwimming() { @@ -1204,7 +1211,7 @@ } public boolean isVisuallyCrawling() { -@@ -2571,6 +3199,13 @@ +@@ -2571,6 +3200,13 @@ } public void setSwimming(boolean swimming) { @@ -1218,7 +1225,7 @@ this.setSharedFlag(4, swimming); } -@@ -2609,6 +3244,7 @@ +@@ -2609,6 +3245,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1226,7 +1233,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2624,8 +3260,12 @@ +@@ -2624,8 +3261,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; } @@ -1240,7 +1247,7 @@ } public boolean getSharedFlag(int index) { -@@ -2644,7 +3284,7 @@ +@@ -2644,7 +3285,7 @@ } public int getMaxAirSupply() { @@ -1249,7 +1256,7 @@ } public int getAirSupply() { -@@ -2652,7 +3292,18 @@ +@@ -2652,7 +3293,18 @@ } public void setAirSupply(int air) { @@ -1269,7 +1276,7 @@ } public int getTicksFrozen() { -@@ -2679,11 +3330,40 @@ +@@ -2679,11 +3331,40 @@ public void thunderHit(ServerLevel world, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1312,7 +1319,7 @@ } public void onAboveBubbleCol(boolean drag) { -@@ -2713,7 +3393,7 @@ +@@ -2713,7 +3394,7 @@ this.resetFallDistance(); } @@ -1321,7 +1328,7 @@ return true; } -@@ -2818,7 +3498,7 @@ +@@ -2818,7 +3499,7 @@ public String toString() { String s = this.level() == null ? "~NULL~" : this.level().toString(); @@ -1330,7 +1337,7 @@ } public final boolean isInvulnerableToBase(DamageSource damageSource) { -@@ -2838,6 +3518,13 @@ +@@ -2838,6 +3519,13 @@ } public void restoreFrom(Entity original) { @@ -1344,7 +1351,7 @@ CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag()); nbttagcompound.remove("Dimension"); -@@ -2850,8 +3537,57 @@ +@@ -2850,8 +3538,57 @@ public Entity teleport(TeleportTransition teleportTarget) { Level world = this.level(); @@ -1402,7 +1409,7 @@ ServerLevel worldserver1 = teleportTarget.newLevel(); boolean flag = worldserver1.dimension() != worldserver.dimension(); -@@ -2918,10 +3654,19 @@ +@@ -2918,10 +3655,19 @@ gameprofilerfiller.pop(); return null; } else { @@ -1423,7 +1430,7 @@ Iterator iterator1 = list1.iterator(); while (iterator1.hasNext()) { -@@ -2947,7 +3692,7 @@ +@@ -2947,7 +3693,7 @@ } private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { @@ -1432,7 +1439,7 @@ Iterator iterator = this.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -2995,9 +3740,17 @@ +@@ -2995,9 +3741,17 @@ } protected void removeAfterChangingDimensions() { @@ -1453,7 +1460,7 @@ } } -@@ -3006,11 +3759,26 @@ +@@ -3006,11 +3760,26 @@ return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); } @@ -1480,7 +1487,7 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { Iterator iterator = this.getPassengers().iterator(); -@@ -3134,10 +3902,16 @@ +@@ -3134,10 +3903,16 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } @@ -1500,7 +1507,7 @@ return entity != null; } -@@ -3187,7 +3961,7 @@ +@@ -3187,7 +3962,7 @@ /** @deprecated */ @Deprecated protected void fixupDimensions() { @@ -1509,7 +1516,7 @@ EntityDimensions entitysize = this.getDimensions(entitypose); this.dimensions = entitysize; -@@ -3196,7 +3970,7 @@ +@@ -3196,7 +3971,7 @@ public void refreshDimensions() { EntityDimensions entitysize = this.dimensions; @@ -1518,7 +1525,7 @@ EntityDimensions entitysize1 = this.getDimensions(entitypose); this.dimensions = entitysize1; -@@ -3258,10 +4032,29 @@ +@@ -3258,10 +4033,29 @@ } public final void setBoundingBox(AABB boundingBox) { @@ -1550,7 +1557,7 @@ return this.getDimensions(pose).eyeHeight(); } -@@ -3335,7 +4128,7 @@ +@@ -3335,7 +4129,7 @@ } @Nullable @@ -1559,7 +1566,7 @@ return null; } -@@ -3373,20 +4166,34 @@ +@@ -3373,20 +4167,34 @@ } private Stream getIndirectPassengersStream() { @@ -1594,7 +1601,7 @@ return () -> { return this.getIndirectPassengersStream().iterator(); }; -@@ -3399,6 +4206,7 @@ +@@ -3399,6 +4207,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1602,7 +1609,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3435,7 +4243,7 @@ +@@ -3435,7 +4244,7 @@ } public boolean isControlledByLocalInstance() { @@ -1611,7 +1618,7 @@ if (entityliving instanceof Player entityhuman) { return entityhuman.isLocalPlayer(); -@@ -3445,7 +4253,7 @@ +@@ -3445,7 +4254,7 @@ } public boolean isControlledByClient() { @@ -1620,7 +1627,7 @@ return entityliving != null && entityliving.isControlledByClient(); } -@@ -3463,7 +4271,7 @@ +@@ -3463,7 +4272,7 @@ return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); } @@ -1629,7 +1636,7 @@ return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); } -@@ -3489,8 +4297,37 @@ +@@ -3489,8 +4298,37 @@ return 1; } @@ -1668,20 +1675,19 @@ } public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { -@@ -3550,7 +4387,12 @@ - +@@ -3551,6 +4389,11 @@ vec3d = vec3d.add(vec3d1); ++k1; -+ } + } + // CraftBukkit start - store last lava contact location + if (tag == FluidTags.LAVA) { + this.lastLavaContact = blockposition_mutableblockposition.immutable(); - } ++ } + // CraftBukkit end } } } -@@ -3613,7 +4455,7 @@ +@@ -3613,7 +4456,7 @@ return new ClientboundAddEntityPacket(this, entityTrackerEntry); } @@ -1690,7 +1696,7 @@ return this.type.getDimensions(); } -@@ -3714,7 +4556,39 @@ +@@ -3714,7 +4557,39 @@ return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); } @@ -1730,7 +1736,7 @@ if (this.position.x != x || this.position.y != y || this.position.z != z) { this.position = new Vec3(x, y, z); int i = Mth.floor(x); -@@ -3732,6 +4606,12 @@ +@@ -3732,6 +4607,12 @@ this.levelCallback.onMove(); } @@ -1743,7 +1749,7 @@ } public void checkDespawn() {} -@@ -3818,8 +4698,16 @@ +@@ -3818,8 +4699,16 @@ @Override public final void setRemoved(Entity.RemovalReason reason) { @@ -1761,7 +1767,7 @@ } if (this.removalReason.shouldDestroy()) { -@@ -3827,8 +4715,8 @@ +@@ -3827,8 +4716,8 @@ } this.getPassengers().forEach(Entity::stopRiding); @@ -1772,7 +1778,7 @@ } public void unsetRemoved() { -@@ -3887,7 +4775,7 @@ +@@ -3887,7 +4776,7 @@ } public Vec3 getKnownMovement() { @@ -1781,7 +1787,7 @@ if (entityliving instanceof Player entityhuman) { if (this.isAlive()) { -@@ -3962,4 +4850,14 @@ +@@ -3962,4 +4851,14 @@ void accept(Entity entity, double x, double y, double z); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index 25410e40a5..2088822118 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -10,24 +10,37 @@ public interface NeutralMob { -@@ -48,14 +51,14 @@ - if (entity instanceof Mob) { - Mob entityinsentient = (Mob) entity; +@@ -42,24 +45,11 @@ + UUID uuid = nbt.getUUID("AngryAt"); + this.setPersistentAngerTarget(uuid); +- Entity entity = ((ServerLevel) world).getEntity(uuid); +- +- if (entity != null) { +- if (entity instanceof Mob) { +- Mob entityinsentient = (Mob) entity; +- - this.setTarget(entityinsentient); -+ this.setTarget(entityinsentient, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit - this.setLastHurtByMob(entityinsentient); - } - - if (entity instanceof Player) { - Player entityhuman = (Player) entity; - +- this.setLastHurtByMob(entityinsentient); +- } +- +- if (entity instanceof Player) { +- Player entityhuman = (Player) entity; +- - this.setTarget(entityhuman); -+ this.setTarget(entityhuman, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit - this.setLastHurtByPlayer(entityhuman); - } - -@@ -114,7 +117,7 @@ +- this.setLastHurtByPlayer(entityhuman); +- } +- +- } ++ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method ++ // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively ++ // tick the initial persistent anger. ++ // If not, let the first tick on the baseTick call the method later down the line. ++ if (this instanceof Entity entity && !entity.firstTick) this.tickInitialPersistentAnger(world); + } + } + } +@@ -114,7 +104,7 @@ default void stopBeingAngry() { this.setLastHurtByMob((LivingEntity) null); this.setPersistentAngerTarget((UUID) null); @@ -36,7 +49,7 @@ this.setRemainingPersistentAngerTime(0); } -@@ -127,6 +130,8 @@ +@@ -127,8 +117,34 @@ void setTarget(@Nullable LivingEntity target); @@ -45,3 +58,29 @@ boolean canAttack(LivingEntity target); @Nullable + LivingEntity getTarget(); ++ ++ // Paper start - Prevent entity loading causing async lookups ++ // Update last hurt when ticking ++ default void tickInitialPersistentAnger(Level level) { ++ UUID target = getPersistentAngerTarget(); ++ if (target == null) { ++ return; ++ } ++ ++ Entity entity = ((ServerLevel) level).getEntity(target); ++ ++ if (entity != null) { ++ if (entity instanceof Mob mob) { ++ this.setTarget(mob, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit ++ this.setLastHurtByMob(mob); ++ } ++ ++ if (entity instanceof Player player) { ++ this.setTarget(player, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit ++ this.setLastHurtByPlayer(player); ++ } ++ } ++ } ++ // Paper end - Prevent entity loading causing async lookups + }