diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 33cb73426b..d18325ede3 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -80,7 +80,7 @@ + public final UUID uuid; + public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent + public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent - ++ + public LevelChunk getChunkIfLoaded(int x, int z) { + return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately + } @@ -142,7 +142,7 @@ + + this.loadChunks(minChunkX, minChunkZ, maxChunkX, maxChunkZ, priority, onLoad); + } -+ + + public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, + ca.spottedleaf.concurrentutil.util.Priority priority, + java.util.function.Consumer> onLoad) { @@ -638,7 +638,7 @@ } } -@@ -939,41 +1192,104 @@ +@@ -939,41 +1192,105 @@ this.entityManager.addNewEntity(player); } @@ -646,6 +646,7 @@ + // CraftBukkit start + private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot ++ entity.generation = false; // Paper - Don't fire sync event during generation; Reset flag if it was added during a ServerLevel generation process + // Paper start - extra debug info + if (entity.valid) { + MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable()); @@ -748,7 +749,7 @@ while (iterator.hasNext()) { ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -982,6 +1298,12 @@ +@@ -982,6 +1299,12 @@ double d1 = (double) pos.getY() - entityplayer.getY(); double d2 = (double) pos.getZ() - entityplayer.getZ(); @@ -761,7 +762,7 @@ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress)); } -@@ -1030,7 +1352,7 @@ +@@ -1030,7 +1353,7 @@ @Override public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) { @@ -770,7 +771,7 @@ } public int getLogicalHeight() { -@@ -1039,6 +1361,11 @@ +@@ -1039,6 +1362,11 @@ @Override public void gameEvent(Holder event, Vec3 emitterPos, GameEvent.Context emitter) { @@ -782,7 +783,7 @@ this.gameEventDispatcher.post(event, emitterPos, emitter); } -@@ -1052,6 +1379,7 @@ +@@ -1052,6 +1380,7 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -790,7 +791,7 @@ VoxelShape voxelshape = oldState.getCollisionShape(this, pos); VoxelShape voxelshape1 = newState.getCollisionShape(this, pos); -@@ -1060,7 +1388,18 @@ +@@ -1060,7 +1389,18 @@ Iterator iterator = this.navigatingMobs.iterator(); while (iterator.hasNext()) { @@ -810,7 +811,7 @@ PathNavigation navigationabstract = entityinsentient.getNavigation(); if (navigationabstract.shouldRecomputePath(pos)) { -@@ -1082,15 +1421,18 @@ +@@ -1082,15 +1422,18 @@ } } @@ -829,7 +830,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null, orientation); } -@@ -1126,9 +1468,20 @@ +@@ -1126,9 +1469,20 @@ @Override public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder soundEvent) { @@ -851,7 +852,7 @@ case NONE: explosion_effect = Explosion.BlockInteraction.KEEP; break; -@@ -1144,16 +1497,27 @@ +@@ -1144,16 +1498,27 @@ case TRIGGER: explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK; break; @@ -882,7 +883,7 @@ Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { -@@ -1162,10 +1526,11 @@ +@@ -1162,10 +1527,11 @@ if (entityplayer.distanceToSqr(vec3d) < 4096.0D) { Optional optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer)); @@ -895,7 +896,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayRule) { -@@ -1226,17 +1591,29 @@ +@@ -1226,17 +1592,29 @@ } public int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) { @@ -930,7 +931,7 @@ ++j; } } -@@ -1292,7 +1669,7 @@ +@@ -1292,7 +1670,7 @@ @Nullable public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) { @@ -939,7 +940,7 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1334,11 +1711,38 @@ +@@ -1334,11 +1712,38 @@ @Nullable @Override public MapItemSavedData getMapData(MapId id) { @@ -979,7 +980,7 @@ this.getServer().overworld().getDataStorage().set(id.key(), state); } -@@ -1352,7 +1756,9 @@ +@@ -1352,7 +1757,9 @@ float f1 = this.levelData.getSpawnAngle(); if (!blockposition1.equals(pos) || f1 != angle) { @@ -989,7 +990,7 @@ this.getServer().getPlayerList().broadcastAll(new ClientboundSetDefaultSpawnPositionPacket(pos, angle)); } -@@ -1419,6 +1825,11 @@ +@@ -1419,6 +1826,11 @@ }); optional1.ifPresent((holder) -> { this.getServer().execute(() -> { @@ -1001,7 +1002,7 @@ this.getPoiManager().add(blockposition1, holder); DebugPackets.sendPoiAddedPacket(this, blockposition1); }); -@@ -1649,6 +2060,11 @@ +@@ -1649,6 +2061,11 @@ @Override public void blockUpdated(BlockPos pos, Block block) { if (!this.isDebug()) { @@ -1013,7 +1014,7 @@ this.updateNeighborsAt(pos, block); } -@@ -1668,12 +2084,12 @@ +@@ -1668,12 +2085,12 @@ } public boolean isFlat() { @@ -1028,7 +1029,7 @@ } @Nullable -@@ -1696,7 +2112,7 @@ +@@ -1696,7 +2113,7 @@ private static String getTypeCount(Iterable items, Function classifier) { try { Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); @@ -1037,7 +1038,7 @@ while (iterator.hasNext()) { T t0 = iterator.next(); -@@ -1705,7 +2121,7 @@ +@@ -1705,7 +2122,7 @@ object2intopenhashmap.addTo(s, 1); } @@ -1046,7 +1047,7 @@ String s1 = (String) entry.getKey(); return s1 + ":" + entry.getIntValue(); -@@ -1717,6 +2133,7 @@ +@@ -1717,6 +2134,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1054,10 +1055,12 @@ return this.entityManager.getEntityGetter(); } -@@ -1802,6 +2219,27 @@ - return this.serverLevelData.getGameRules(); - } +@@ -1800,7 +2218,28 @@ + public GameRules getGameRules() { + return this.serverLevelData.getGameRules(); ++ } ++ + // Paper start - respect global sound events gamerule + public List getPlayersForGlobalSoundGamerule() { + return this.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) ? ((ServerLevel) this).getServer().getPlayerList().players : ((ServerLevel) this).players(); @@ -1076,13 +1079,12 @@ + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { + this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); + } -+ } + } + // Paper end - notify observers even if grow failed -+ + @Override public CrashReportCategory fillReportDetails(CrashReport report) { - CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report); -@@ -1828,6 +2266,7 @@ +@@ -1828,6 +2267,7 @@ } public void onTickingStart(Entity entity) { @@ -1090,7 +1092,7 @@ ServerLevel.this.entityTickList.add(entity); } -@@ -1836,14 +2275,15 @@ +@@ -1836,14 +2276,15 @@ } public void onTrackingStart(Entity entity) { @@ -1108,7 +1110,7 @@ String s = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); -@@ -1864,9 +2304,58 @@ +@@ -1864,9 +2305,58 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1167,7 +1169,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer entityplayer) { ServerLevel.this.players.remove(entityplayer); -@@ -1874,7 +2363,7 @@ +@@ -1874,7 +2364,7 @@ } if (entity instanceof Mob entityinsentient) { @@ -1176,7 +1178,7 @@ String s = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")); -@@ -1895,10 +2384,27 @@ +@@ -1895,10 +2385,27 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); 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 a2e61caaab..61ffb2e55e 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 @@ -320,7 +320,7 @@ public boolean equals(Object object) { return object instanceof Entity ? ((Entity) object).id == this.id : false; } -@@ -385,22 +613,35 @@ +@@ -385,22 +613,39 @@ } public void remove(Entity.RemovalReason reason) { @@ -345,7 +345,11 @@ + if (pose == this.getPose()) { + return; + } -+ this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()])); ++ // Paper start - Don't fire sync event during generation ++ if (!this.generation) { ++ this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[pose.ordinal()])); ++ } ++ // Paper end - Don't fire sync event during generation + // CraftBukkit end this.entityData.set(Entity.DATA_POSE, pose); } @@ -361,7 +365,7 @@ return this.getPose() == pose; } -@@ -417,6 +658,33 @@ +@@ -417,6 +662,33 @@ } public void setRot(float yaw, float pitch) { @@ -395,7 +399,7 @@ this.setYRot(yaw % 360.0F); this.setXRot(pitch % 360.0F); } -@@ -426,8 +694,8 @@ +@@ -426,8 +698,8 @@ } public void setPos(double x, double y, double z) { @@ -406,7 +410,7 @@ } protected final AABB makeBoundingBox() { -@@ -462,10 +730,20 @@ +@@ -462,10 +734,20 @@ this.baseTick(); } @@ -427,7 +431,7 @@ this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { this.stopRiding(); -@@ -475,7 +753,7 @@ +@@ -475,7 +757,7 @@ --this.boardingCooldown; } @@ -436,7 +440,7 @@ if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -502,7 +780,7 @@ +@@ -502,7 +784,7 @@ this.setRemainingFireTicks(this.remainingFireTicks - 1); } @@ -445,7 +449,7 @@ this.setTicksFrozen(0); this.level().levelEvent((Player) null, 1009, this.blockPosition, 1); } -@@ -514,6 +792,10 @@ +@@ -514,6 +796,10 @@ if (this.isInLava()) { this.lavaHurt(); this.fallDistance *= 0.5F; @@ -456,7 +460,7 @@ } this.checkBelowWorld(); -@@ -525,7 +807,7 @@ +@@ -525,7 +811,7 @@ world = this.level(); if (world instanceof ServerLevel worldserver) { if (this instanceof Leashable) { @@ -465,7 +469,7 @@ } } -@@ -537,7 +819,11 @@ +@@ -537,7 +823,11 @@ } public void checkBelowWorld() { @@ -478,7 +482,7 @@ this.onBelowWorld(); } -@@ -568,15 +854,32 @@ +@@ -568,15 +858,32 @@ public void lavaHurt() { if (!this.fireImmune()) { @@ -513,7 +517,7 @@ } } -@@ -587,9 +890,25 @@ +@@ -587,9 +894,25 @@ } public final void igniteForSeconds(float seconds) { @@ -540,7 +544,7 @@ public void igniteForTicks(int ticks) { if (this.remainingFireTicks < ticks) { this.setRemainingFireTicks(ticks); -@@ -610,7 +929,7 @@ +@@ -610,7 +933,7 @@ } protected void onBelowWorld() { @@ -549,7 +553,7 @@ } public boolean isFree(double offsetX, double offsetY, double offsetZ) { -@@ -672,6 +991,7 @@ +@@ -672,6 +995,7 @@ } public void move(MoverType type, Vec3 movement) { @@ -557,7 +561,7 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { -@@ -747,8 +1067,30 @@ +@@ -747,8 +1071,30 @@ if (movement.y != vec3d1.y) { block.updateEntityMovementAfterFallOn(this.level(), this); @@ -577,18 +581,18 @@ + bl = bl.getRelative(BlockFace.SOUTH); + } else if (movement.z < vec3d1.z) { + bl = bl.getRelative(BlockFace.NORTH); -+ } + } + + if (!bl.getType().isAir()) { + VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity + this.level.getCraftServer().getPluginManager().callEvent(event); - } ++ } } + // CraftBukkit end if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { Entity.MovementEmission entity_movementemission = this.getMovementEmission(); -@@ -913,7 +1255,7 @@ +@@ -913,7 +1259,7 @@ } protected BlockPos getOnPos(float offset) { @@ -597,7 +601,7 @@ BlockPos blockposition = (BlockPos) this.mainSupportingBlockPos.get(); if (offset <= 1.0E-5F) { -@@ -1131,8 +1473,22 @@ +@@ -1131,7 +1477,21 @@ protected SoundEvent getSwimHighSpeedSplashSound() { return SoundEvents.GENERIC_SPLASH; @@ -606,21 +610,20 @@ + // CraftBukkit start - Add delegate methods + public SoundEvent getSwimSound0() { + return this.getSwimSound(); - } - ++ } ++ + public SoundEvent getSwimSplashSound0() { + return this.getSwimSplashSound(); + } + + public SoundEvent getSwimHighSpeedSplashSound0() { + return this.getSwimHighSpeedSplashSound(); -+ } + } + // CraftBukkit end -+ + public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) { this.movementThisTick.add(new Entity.Movement(oldPos, newPos)); - } -@@ -1599,6 +1955,7 @@ +@@ -1599,6 +1959,7 @@ this.setXRot(Mth.clamp(pitch, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); @@ -628,7 +631,7 @@ } public void absMoveTo(double x, double y, double z) { -@@ -1609,6 +1966,7 @@ +@@ -1609,6 +1970,7 @@ this.yo = y; this.zo = d4; this.setPos(d3, y, d4); @@ -636,7 +639,7 @@ } public void moveTo(Vec3 pos) { -@@ -1628,11 +1986,19 @@ +@@ -1628,11 +1990,19 @@ } public void moveTo(double x, double y, double z, float yaw, float pitch) { @@ -656,7 +659,7 @@ } public final void setOldPosAndRot() { -@@ -1701,6 +2067,7 @@ +@@ -1701,6 +2071,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -664,7 +667,7 @@ double d0 = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = Mth.absMax(d0, d1); -@@ -1737,7 +2104,21 @@ +@@ -1737,7 +2108,21 @@ } public void push(double deltaX, double deltaY, double deltaZ) { @@ -687,7 +690,7 @@ this.hasImpulse = true; } -@@ -1858,9 +2239,21 @@ +@@ -1858,8 +2243,20 @@ } public boolean isPushable() { @@ -699,17 +702,16 @@ + // 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) { - CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource); -@@ -1889,74 +2282,133 @@ +@@ -1889,74 +2286,133 @@ } public boolean saveAsPassenger(CompoundTag nbt) { @@ -866,7 +868,7 @@ } ListTag nbttaglist; -@@ -1972,10 +2424,10 @@ +@@ -1972,10 +2428,10 @@ nbttaglist.add(StringTag.valueOf(s)); } @@ -879,7 +881,7 @@ if (this.isVehicle()) { nbttaglist = new ListTag(); iterator = this.getPassengers().iterator(); -@@ -1984,17 +2436,44 @@ +@@ -1984,17 +2440,44 @@ Entity entity = (Entity) iterator.next(); CompoundTag nbttagcompound1 = new CompoundTag(); @@ -927,7 +929,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); -@@ -2080,6 +2559,71 @@ +@@ -2080,6 +2563,71 @@ } else { throw new IllegalStateException("Entity has invalid position"); } @@ -999,7 +1001,7 @@ } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); -@@ -2101,6 +2645,12 @@ +@@ -2101,6 +2649,12 @@ return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; } @@ -1012,7 +1014,7 @@ protected abstract void readAdditionalSaveData(CompoundTag nbt); protected abstract void addAdditionalSaveData(CompoundTag nbt); -@@ -2153,9 +2703,31 @@ +@@ -2153,9 +2707,31 @@ if (stack.isEmpty()) { return null; } else { @@ -1045,7 +1047,7 @@ world.addFreshEntity(entityitem); return entityitem; } -@@ -2184,7 +2756,16 @@ +@@ -2184,7 +2760,16 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1063,7 +1065,7 @@ leashable.removeLeash(); } else { leashable.dropLeash(); -@@ -2200,6 +2781,14 @@ +@@ -2200,6 +2785,14 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -1078,7 +1080,7 @@ leashable.setLeashedTo(player, true); } -@@ -2265,15 +2854,15 @@ +@@ -2265,15 +2858,15 @@ } public boolean showVehicleHealth() { @@ -1097,7 +1099,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2285,11 +2874,32 @@ +@@ -2285,11 +2878,32 @@ if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -1131,7 +1133,7 @@ this.vehicle = entity; this.vehicle.addPassenger(this); entity.getIndirectPassengersStream().filter((entity2) -> { -@@ -2314,19 +2924,30 @@ +@@ -2314,19 +2928,30 @@ } public void removeVehicle() { @@ -1164,7 +1166,7 @@ protected void addPassenger(Entity passenger) { if (passenger.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); -@@ -2349,21 +2970,53 @@ +@@ -2349,21 +2974,53 @@ } } @@ -1224,7 +1226,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2464,7 +3117,7 @@ +@@ -2464,7 +3121,7 @@ if (teleporttransition != null) { ServerLevel worldserver1 = teleporttransition.newLevel(); @@ -1233,7 +1235,7 @@ this.teleport(teleporttransition); } } -@@ -2547,7 +3200,7 @@ +@@ -2547,7 +3204,7 @@ } public boolean isCrouching() { @@ -1242,7 +1244,7 @@ } public boolean isSprinting() { -@@ -2563,7 +3216,7 @@ +@@ -2563,7 +3220,7 @@ } public boolean isVisuallySwimming() { @@ -1251,7 +1253,7 @@ } public boolean isVisuallyCrawling() { -@@ -2571,6 +3224,13 @@ +@@ -2571,6 +3228,13 @@ } public void setSwimming(boolean swimming) { @@ -1265,7 +1267,7 @@ this.setSharedFlag(4, swimming); } -@@ -2609,6 +3269,7 @@ +@@ -2609,6 +3273,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1273,7 +1275,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2624,8 +3285,12 @@ +@@ -2624,8 +3289,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; } @@ -1287,7 +1289,7 @@ } public boolean getSharedFlag(int index) { -@@ -2644,7 +3309,7 @@ +@@ -2644,7 +3313,7 @@ } public int getMaxAirSupply() { @@ -1296,7 +1298,7 @@ } public int getAirSupply() { -@@ -2652,7 +3317,18 @@ +@@ -2652,7 +3321,18 @@ } public void setAirSupply(int air) { @@ -1316,7 +1318,7 @@ } public int getTicksFrozen() { -@@ -2679,11 +3355,44 @@ +@@ -2679,11 +3359,44 @@ public void thunderHit(ServerLevel world, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1363,7 +1365,7 @@ } public void onAboveBubbleCol(boolean drag) { -@@ -2713,7 +3422,7 @@ +@@ -2713,7 +3426,7 @@ this.resetFallDistance(); } @@ -1372,7 +1374,7 @@ return true; } -@@ -2818,7 +3527,7 @@ +@@ -2818,7 +3531,7 @@ public String toString() { String s = this.level() == null ? "~NULL~" : this.level().toString(); @@ -1381,7 +1383,7 @@ } public final boolean isInvulnerableToBase(DamageSource damageSource) { -@@ -2838,6 +3547,13 @@ +@@ -2838,6 +3551,13 @@ } public void restoreFrom(Entity original) { @@ -1395,7 +1397,7 @@ CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag()); nbttagcompound.remove("Dimension"); -@@ -2850,8 +3566,57 @@ +@@ -2850,8 +3570,57 @@ public Entity teleport(TeleportTransition teleportTarget) { Level world = this.level(); @@ -1453,7 +1455,7 @@ ServerLevel worldserver1 = teleportTarget.newLevel(); boolean flag = worldserver1.dimension() != worldserver.dimension(); -@@ -2918,10 +3683,19 @@ +@@ -2918,10 +3687,19 @@ gameprofilerfiller.pop(); return null; } else { @@ -1474,7 +1476,7 @@ Iterator iterator1 = list1.iterator(); while (iterator1.hasNext()) { -@@ -2947,7 +3721,7 @@ +@@ -2947,7 +3725,7 @@ } private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { @@ -1483,7 +1485,7 @@ Iterator iterator = this.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -2995,9 +3769,17 @@ +@@ -2995,9 +3773,17 @@ } protected void removeAfterChangingDimensions() { @@ -1504,7 +1506,7 @@ } } -@@ -3006,11 +3788,34 @@ +@@ -3006,11 +3792,34 @@ return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); } @@ -1539,7 +1541,7 @@ if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { Iterator iterator = this.getPassengers().iterator(); -@@ -3134,10 +3939,16 @@ +@@ -3134,10 +3943,16 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } @@ -1559,7 +1561,7 @@ return entity != null; } -@@ -3187,7 +3998,7 @@ +@@ -3187,7 +4002,7 @@ /** @deprecated */ @Deprecated protected void fixupDimensions() { @@ -1568,7 +1570,7 @@ EntityDimensions entitysize = this.getDimensions(entitypose); this.dimensions = entitysize; -@@ -3196,7 +4007,7 @@ +@@ -3196,7 +4011,7 @@ public void refreshDimensions() { EntityDimensions entitysize = this.dimensions; @@ -1577,7 +1579,7 @@ EntityDimensions entitysize1 = this.getDimensions(entitypose); this.dimensions = entitysize1; -@@ -3258,10 +4069,29 @@ +@@ -3258,10 +4073,29 @@ } public final void setBoundingBox(AABB boundingBox) { @@ -1609,7 +1611,7 @@ return this.getDimensions(pose).eyeHeight(); } -@@ -3300,7 +4130,14 @@ +@@ -3300,7 +4134,14 @@ public void startSeenByPlayer(ServerPlayer player) {} @@ -1625,7 +1627,7 @@ public float rotate(Rotation rotation) { float f = Mth.wrapDegrees(this.getYRot()); -@@ -3335,7 +4172,7 @@ +@@ -3335,7 +4176,7 @@ } @Nullable @@ -1634,7 +1636,7 @@ return null; } -@@ -3373,20 +4210,34 @@ +@@ -3373,20 +4214,34 @@ } private Stream getIndirectPassengersStream() { @@ -1669,7 +1671,7 @@ return () -> { return this.getIndirectPassengersStream().iterator(); }; -@@ -3399,6 +4250,7 @@ +@@ -3399,6 +4254,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1677,7 +1679,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3435,7 +4287,7 @@ +@@ -3435,7 +4291,7 @@ } public boolean isControlledByLocalInstance() { @@ -1686,7 +1688,7 @@ if (entityliving instanceof Player entityhuman) { return entityhuman.isLocalPlayer(); -@@ -3445,7 +4297,7 @@ +@@ -3445,7 +4301,7 @@ } public boolean isControlledByClient() { @@ -1695,7 +1697,7 @@ return entityliving != null && entityliving.isControlledByClient(); } -@@ -3463,7 +4315,7 @@ +@@ -3463,7 +4319,7 @@ return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); } @@ -1704,7 +1706,7 @@ return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); } -@@ -3489,8 +4341,37 @@ +@@ -3489,8 +4345,37 @@ return 1; } @@ -1743,7 +1745,7 @@ } public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { -@@ -3551,6 +4432,11 @@ +@@ -3551,6 +4436,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -1755,7 +1757,7 @@ } } } -@@ -3613,7 +4499,7 @@ +@@ -3613,7 +4503,7 @@ return new ClientboundAddEntityPacket(this, entityTrackerEntry); } @@ -1764,7 +1766,7 @@ return this.type.getDimensions(); } -@@ -3714,7 +4600,39 @@ +@@ -3714,7 +4604,39 @@ return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); } @@ -1804,7 +1806,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 +4650,12 @@ +@@ -3732,6 +4654,12 @@ this.levelCallback.onMove(); } @@ -1817,7 +1819,7 @@ } public void checkDespawn() {} -@@ -3818,8 +4742,17 @@ +@@ -3818,8 +4746,17 @@ @Override public final void setRemoved(Entity.RemovalReason reason) { @@ -1836,7 +1838,7 @@ } if (this.removalReason.shouldDestroy()) { -@@ -3827,14 +4760,30 @@ +@@ -3827,14 +4764,30 @@ } this.getPassengers().forEach(Entity::stopRiding); @@ -1869,7 +1871,7 @@ @Override public void setLevelCallback(EntityInLevelCallback changeListener) { this.levelCallback = changeListener; -@@ -3887,7 +4836,7 @@ +@@ -3887,7 +4840,7 @@ } public Vec3 getKnownMovement() { @@ -1878,7 +1880,7 @@ if (entityliving instanceof Player entityhuman) { if (this.isAlive()) { -@@ -3962,4 +4911,14 @@ +@@ -3962,4 +4915,14 @@ void accept(Entity entity, double x, double y, double z); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index bb085c1cad..ed5e561816 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -34,14 +34,14 @@ + // CraftBukkit start + return this.spawn(world, stack, player, pos, spawnReason, alignPosition, invertY, spawnReason == EntitySpawnReason.DISPENSER ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // Paper - use correct spawn reason for dispenser spawn eggs + } -+ + +- if (stack != null) { +- consumer = EntityType.createDefaultStackConfig(world, stack, player); + @Nullable + public T spawn(ServerLevel worldserver, @Nullable ItemStack itemstack, @Nullable Player entityhuman, BlockPos blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end + Consumer consumer; // CraftBukkit - decompile error - -- if (stack != null) { -- consumer = EntityType.createDefaultStackConfig(world, stack, player); ++ + if (itemstack != null) { + consumer = EntityType.createDefaultStackConfig(worldserver, itemstack, entityhuman); } else { @@ -125,7 +125,23 @@ nbt.loadInto(entity); } } -@@ -657,7 +703,7 @@ +@@ -613,9 +659,15 @@ + } + + public static Optional create(CompoundTag nbt, Level world, EntitySpawnReason reason) { ++ // Paper start - Don't fire sync event during generation ++ return create(nbt, world, reason, false); ++ } ++ public static Optional create(CompoundTag nbt, Level world, EntitySpawnReason reason, boolean generation) { ++ // Paper end - Don't fire sync event during generation + return Util.ifElse(EntityType.by(nbt).map((entitytypes) -> { + return entitytypes.create(world, reason); + }), (entity) -> { ++ if (generation) entity.generation = true; // Paper - Don't fire sync event during generation + entity.load(nbt); + }, () -> { + EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); +@@ -657,7 +709,7 @@ } return entity; @@ -134,7 +150,7 @@ } public static Stream loadEntitiesRecursive(final List entityNbtList, final Level world, final EntitySpawnReason reason) { -@@ -718,7 +764,7 @@ +@@ -718,7 +770,7 @@ @Nullable public T tryCast(Entity obj) { @@ -143,7 +159,7 @@ } @Override -@@ -791,7 +837,7 @@ +@@ -791,7 +843,7 @@ this.canSpawnFarFromPlayer = spawnGroup == MobCategory.CREATURE || spawnGroup == MobCategory.MISC; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 1b06b50ed1..4a71ab8db0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -409,7 +409,7 @@ } } -@@ -987,24 +1149,55 @@ +@@ -987,24 +1149,63 @@ return this.addEffect(effect, (Entity) null); } @@ -424,6 +424,11 @@ + } + + public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) { ++ // Paper start - Don't fire sync event during generation ++ return this.addEffect(mobeffect, entity, cause, true); ++ } ++ public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) { ++ // Paper end - Don't fire sync event during generation + // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API + if (this.isTickingEffects) { + this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); @@ -444,10 +449,13 @@ + override = new MobEffectInstance(mobeffect1).update(mobeffect); + } + ++ if (fireEvent) { // Paper - Don't fire sync event during generation + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override); ++ override = event.isOverride(); // Paper - Don't fire sync event during generation + if (event.isCancelled()) { + return false; + } ++ } // Paper - Don't fire sync event during generation + // CraftBukkit end + if (mobeffect1 == null) { @@ -461,7 +469,7 @@ - this.onEffectUpdated(mobeffect1, true, source); + mobeffect.onEffectAdded(this); + // CraftBukkit start -+ } else if (event.isOverride()) { ++ } else if (override) { // Paper - Don't fire sync event during generation + mobeffect1.update(mobeffect); + this.onEffectUpdated(mobeffect1, true, entity); + // CraftBukkit end @@ -473,7 +481,7 @@ return flag; } } -@@ -1031,14 +1224,40 @@ +@@ -1031,14 +1232,40 @@ return this.getType().is(EntityTypeTags.INVERTED_HEALING_AND_HARM); } @@ -516,7 +524,7 @@ if (mobeffect != null) { this.onEffectsRemoved(List.of(mobeffect)); return true; -@@ -1142,20 +1361,65 @@ +@@ -1142,20 +1369,65 @@ } @@ -583,7 +591,7 @@ this.entityData.set(LivingEntity.DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1167,7 +1431,7 @@ +@@ -1167,7 +1439,7 @@ public boolean hurtServer(ServerLevel world, DamageSource source, float amount) { if (this.isInvulnerableTo(world, source)) { return false; @@ -592,7 +600,7 @@ return false; } else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1182,10 +1446,11 @@ +@@ -1182,10 +1454,11 @@ } float f1 = amount; @@ -606,7 +614,7 @@ this.hurtCurrentlyUsedShield(amount); f2 = amount; amount = 0.0F; -@@ -1202,15 +1467,26 @@ +@@ -1202,15 +1475,26 @@ flag = true; } @@ -635,7 +643,7 @@ this.walkAnimation.setSpeed(1.5F); if (Float.isNaN(amount) || Float.isInfinite(amount)) { amount = Float.MAX_VALUE; -@@ -1218,18 +1494,27 @@ +@@ -1218,18 +1502,27 @@ boolean flag1 = true; @@ -667,7 +675,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1243,7 +1528,7 @@ +@@ -1243,7 +1536,7 @@ world.broadcastDamageEvent(this, source); } @@ -676,7 +684,7 @@ this.markHurt(); } -@@ -1263,7 +1548,7 @@ +@@ -1263,7 +1556,7 @@ d1 = source.getSourcePosition().z() - this.getZ(); } @@ -685,7 +693,7 @@ if (!flag) { this.indicateDamage(d0, d1); } -@@ -1272,17 +1557,18 @@ +@@ -1272,17 +1565,18 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(source)) { @@ -708,7 +716,7 @@ if (flag2) { this.lastDamageSource = source; -@@ -1329,10 +1615,10 @@ +@@ -1329,10 +1623,10 @@ } @Nullable @@ -721,7 +729,7 @@ this.lastHurtByPlayerTime = 100; this.lastHurtByPlayer = entityhuman; return entityhuman; -@@ -1342,8 +1628,8 @@ +@@ -1342,8 +1636,8 @@ this.lastHurtByPlayerTime = 100; LivingEntity entityliving = entitywolf.getOwner(); @@ -732,7 +740,7 @@ this.lastHurtByPlayer = entityhuman1; } else { -@@ -1363,7 +1649,7 @@ +@@ -1363,7 +1657,7 @@ } protected void blockedByShield(LivingEntity target) { @@ -741,7 +749,7 @@ } private boolean checkTotemDeathProtection(DamageSource source) { -@@ -1375,20 +1661,33 @@ +@@ -1375,20 +1669,33 @@ InteractionHand[] aenumhand = InteractionHand.values(); int i = aenumhand.length; @@ -779,7 +787,7 @@ ServerPlayer entityplayer = (ServerPlayer) this; entityplayer.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); -@@ -1468,6 +1767,7 @@ +@@ -1468,6 +1775,7 @@ Entity entity = damageSource.getEntity(); LivingEntity entityliving = this.getKillCredit(); @@ -787,7 +795,7 @@ if (entityliving != null) { entityliving.awardKillScore(this, damageSource); } -@@ -1477,26 +1777,61 @@ +@@ -1477,26 +1785,61 @@ } if (!this.level().isClientSide && this.hasCustomName()) { @@ -854,7 +862,7 @@ } } -@@ -1506,20 +1841,28 @@ +@@ -1506,20 +1849,28 @@ if (world instanceof ServerLevel worldserver) { boolean flag = false; @@ -886,7 +894,7 @@ this.level().addFreshEntity(entityitem); } } -@@ -1527,27 +1870,60 @@ +@@ -1527,27 +1878,60 @@ } } @@ -909,6 +917,8 @@ this.dropCustomDeathLoot(world, damageSource, flag); + this.clearEquipmentSlots = prev; // Paper } +- +- this.dropEquipment(world); + // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment + org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, damageSource, this.drops, () -> { + final LivingEntity entityliving = this.getKillCredit(); @@ -919,8 +929,7 @@ + this.postDeathDropItems(deathEvent); // Paper + this.drops = new ArrayList<>(); + // CraftBukkit end - -- this.dropEquipment(world); ++ + // this.dropEquipment(worldserver);// CraftBukkit - moved up this.dropExperience(world, damageSource.getEntity()); + return deathEvent; // Paper @@ -952,7 +961,7 @@ protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {} public long getLootTableSeed() { -@@ -1612,19 +1988,35 @@ +@@ -1612,19 +1996,35 @@ } public void knockback(double strength, double x, double z) { @@ -995,7 +1004,7 @@ } } -@@ -1683,6 +2075,20 @@ +@@ -1683,6 +2083,20 @@ return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL); } @@ -1016,7 +1025,7 @@ public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1757,9 +2163,14 @@ +@@ -1757,9 +2171,14 @@ int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1032,7 +1041,7 @@ return true; } else { return flag; -@@ -1830,7 +2241,7 @@ +@@ -1830,7 +2249,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1041,7 +1050,7 @@ amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); } -@@ -1841,7 +2252,8 @@ +@@ -1841,7 +2260,8 @@ if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) { return amount; } else { @@ -1051,7 +1060,7 @@ int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = amount * (float) j; -@@ -1884,18 +2296,154 @@ +@@ -1884,18 +2304,154 @@ } } @@ -1215,7 +1224,7 @@ if (entity instanceof ServerPlayer) { ServerPlayer entityplayer = (ServerPlayer) entity; -@@ -1904,13 +2452,48 @@ +@@ -1904,13 +2460,48 @@ } } @@ -1268,7 +1277,7 @@ } public CombatTracker getCombatTracker() { -@@ -1935,9 +2518,19 @@ +@@ -1935,9 +2526,19 @@ } public final void setArrowCount(int stuckArrowCount) { @@ -1289,7 +1298,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID); } -@@ -1999,7 +2592,7 @@ +@@ -1999,7 +2600,7 @@ this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } @@ -1298,7 +1307,7 @@ this.setHealth(0.0F); this.die(this.damageSources().generic()); } -@@ -2182,6 +2775,12 @@ +@@ -2182,6 +2783,12 @@ public abstract ItemStack getItemBySlot(EquipmentSlot slot); @@ -1311,7 +1320,7 @@ public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack); public Iterable getHandSlots() { -@@ -2292,17 +2891,29 @@ +@@ -2292,17 +2899,29 @@ return this.hasEffect(MobEffects.JUMP) ? 0.1F * ((float) this.getEffect(MobEffects.JUMP).getAmplifier() + 1.0F) : 0.0F; } @@ -1342,7 +1351,7 @@ this.addDeltaMovement(new Vec3((double) (-Mth.sin(f1)) * 0.2D, 0.0D, (double) Mth.cos(f1) * 0.2D)); } -@@ -2494,7 +3105,7 @@ +@@ -2494,7 +3113,7 @@ } @@ -1351,7 +1360,7 @@ Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput); this.tickRidden(controllingPlayer, vec3d1); -@@ -2507,13 +3118,13 @@ +@@ -2507,13 +3126,13 @@ } @@ -1368,7 +1377,7 @@ return this.getSpeed(); } -@@ -2571,7 +3182,7 @@ +@@ -2571,7 +3190,7 @@ double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D); double d2 = Math.max(motion.y, -0.15000000596046448D); @@ -1377,7 +1386,7 @@ d2 = 0.0D; } -@@ -2586,7 +3197,7 @@ +@@ -2586,7 +3205,7 @@ } protected float getFlyingSpeed() { @@ -1386,7 +1395,7 @@ } public float getSpeed() { -@@ -2634,7 +3245,7 @@ +@@ -2634,7 +3253,7 @@ } } @@ -1395,7 +1404,7 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2687,37 +3298,15 @@ +@@ -2687,37 +3306,15 @@ gameprofilerfiller.pop(); gameprofilerfiller.push("rangeChecks"); @@ -1439,7 +1448,7 @@ gameprofilerfiller.pop(); this.animStep += f2; -@@ -2741,7 +3330,7 @@ +@@ -2741,7 +3338,7 @@ this.elytraAnimationState.tick(); } @@ -1448,7 +1457,7 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -2778,10 +3367,17 @@ +@@ -2778,10 +3375,17 @@ throw new MatchException((String) null, (Throwable) null); } @@ -1468,7 +1477,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2974,8 +3570,10 @@ +@@ -2974,8 +3578,10 @@ } else if (this.isInLava() && (!this.onGround() || d3 > d4)) { this.jumpInLiquid(FluidTags.LAVA); } else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) { @@ -1479,7 +1488,7 @@ } } else { this.noJumpDelay = 0; -@@ -3000,7 +3598,7 @@ +@@ -3000,7 +3606,7 @@ { LivingEntity entityliving = this.getControllingPassenger(); @@ -1488,7 +1497,7 @@ if (this.isAlive()) { this.travelRidden(entityhuman, vec3d1); break label112; -@@ -3017,7 +3615,7 @@ +@@ -3017,7 +3623,7 @@ this.calculateEntityAnimation(this instanceof FlyingAnimal); gameprofilerfiller.pop(); gameprofilerfiller.push("freezing"); @@ -1497,7 +1506,7 @@ int i = this.getTicksFrozen(); if (this.isInPowderSnow && this.canFreeze()) { -@@ -3046,6 +3644,20 @@ +@@ -3046,6 +3652,20 @@ this.pushEntities(); gameprofilerfiller.pop(); @@ -1518,7 +1527,7 @@ world = this.level(); if (world instanceof ServerLevel worldserver) { if (this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { -@@ -3063,6 +3675,7 @@ +@@ -3063,6 +3683,7 @@ this.checkSlowFallDistance(); if (!this.level().isClientSide) { if (!this.canGlide()) { @@ -1526,7 +1535,7 @@ this.setSharedFlag(7, false); return; } -@@ -3113,12 +3726,26 @@ +@@ -3113,12 +3734,26 @@ Level world = this.level(); if (!(world instanceof ServerLevel worldserver)) { @@ -1556,7 +1565,7 @@ if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) { int j = 0; -@@ -3138,10 +3765,12 @@ +@@ -3138,10 +3773,12 @@ } Iterator iterator1 = list.iterator(); @@ -1571,7 +1580,7 @@ this.doPush(entity1); } } -@@ -3190,10 +3819,16 @@ +@@ -3190,10 +3827,16 @@ @Override public void stopRiding() { @@ -1590,7 +1599,7 @@ this.dismountVehicle(entity); } -@@ -3258,7 +3893,7 @@ +@@ -3258,7 +3901,7 @@ } public void onItemPickup(ItemEntity item) { @@ -1599,7 +1608,7 @@ if (entity instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer) entity, item.getItem(), this); -@@ -3268,7 +3903,7 @@ +@@ -3268,7 +3911,7 @@ public void take(Entity item, int count) { if (!item.isRemoved() && !this.level().isClientSide && (item instanceof ItemEntity || item instanceof AbstractArrow || item instanceof ExperienceOrb)) { @@ -1608,7 +1617,7 @@ } } -@@ -3284,7 +3919,8 @@ +@@ -3284,7 +3927,8 @@ Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec3d1 = new Vec3(entity.getX(), entityY, entity.getZ()); @@ -1618,7 +1627,7 @@ } } -@@ -3305,15 +3941,29 @@ +@@ -3305,15 +3949,29 @@ @Override public boolean isPickable() { @@ -1650,7 +1659,7 @@ public float getYHeadRot() { return this.yHeadRot; } -@@ -3342,7 +3992,7 @@ +@@ -3342,7 +4000,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1659,7 +1668,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3410,9 +4060,14 @@ +@@ -3410,9 +4068,14 @@ } public void startUsingItem(InteractionHand hand) { @@ -1675,7 +1684,7 @@ this.useItem = itemstack; this.useItemRemaining = itemstack.getUseDuration(this); if (!this.level().isClientSide) { -@@ -3483,13 +4138,50 @@ +@@ -3483,13 +4146,50 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1727,7 +1736,7 @@ } } -@@ -3512,6 +4204,7 @@ +@@ -3512,6 +4212,7 @@ public void releaseUsingItem() { if (!this.useItem.isEmpty()) { @@ -1735,7 +1744,7 @@ this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3544,12 +4237,69 @@ +@@ -3544,12 +4245,69 @@ if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); @@ -1744,8 +1753,8 @@ } else { return null; } - } - ++ } ++ + // Paper start - Make shield blocking delay configurable + public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) { + if (maxDistance < 1 || maxDistance > 120) { @@ -1796,8 +1805,8 @@ + + public int getShieldBlockingDelay() { + return shieldBlockingDelay; -+ } -+ + } + + public void setShieldBlockingDelay(int shieldBlockingDelay) { + this.shieldBlockingDelay = shieldBlockingDelay; + } @@ -1806,7 +1815,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3568,12 +4318,18 @@ +@@ -3568,12 +4326,18 @@ } public boolean randomTeleport(double x, double y, double z, boolean particleEffects) { @@ -1827,7 +1836,7 @@ Level world = this.level(); if (world.hasChunkAt(blockposition)) { -@@ -3592,18 +4348,43 @@ +@@ -3592,18 +4356,43 @@ } if (flag2) { @@ -1875,7 +1884,7 @@ world.broadcastEntityEvent(this, (byte) 46); } -@@ -3613,7 +4394,7 @@ +@@ -3613,7 +4402,7 @@ entitycreature.getNavigation().stop(); } @@ -1884,7 +1893,7 @@ } } -@@ -3706,7 +4487,7 @@ +@@ -3706,7 +4495,7 @@ } public void stopSleeping() { @@ -1893,7 +1902,7 @@ Level world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3718,9 +4499,9 @@ +@@ -3718,9 +4507,9 @@ this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3); Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> { @@ -1905,7 +1914,7 @@ }); Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); -@@ -3740,7 +4521,7 @@ +@@ -3740,7 +4529,7 @@ @Nullable public Direction getBedOrientation() { @@ -1914,7 +1923,7 @@ return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null; } -@@ -3905,7 +4686,7 @@ +@@ -3905,7 +4694,7 @@ public float maxUpStep() { float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch index 6f5110cd1c..c4a7c3e124 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch @@ -14,7 +14,7 @@ if (holder != null) { - this.addEffect(new MobEffectInstance(holder, -1)); -+ this.addEffect(new MobEffectInstance(holder, -1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit ++ this.addEffect(new MobEffectInstance(holder, -1), null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN, world instanceof net.minecraft.server.level.ServerLevel); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index cd64eb79cd..6bbbc67254 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -123,12 +123,13 @@ private static Optional createEntityIgnoreException(ServerLevelAccessor world, CompoundTag nbt) { - try { -+ // CraftBukkit start -+ // try { - return EntityType.create(nbt, world.getLevel(), EntitySpawnReason.STRUCTURE); +- return EntityType.create(nbt, world.getLevel(), EntitySpawnReason.STRUCTURE); - } catch (Exception exception) { - return Optional.empty(); - } ++ // CraftBukkit start ++ // try { ++ return EntityType.create(nbt, world.getLevel(), EntitySpawnReason.STRUCTURE, true); // Paper - Don't fire sync event during generation + // } catch (Exception exception) { + // return Optional.empty(); + // } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java index e444662ee4..54c4434662 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/DelegatedGeneratorAccess.java @@ -90,15 +90,17 @@ public abstract class DelegatedGeneratorAccess implements WorldGenLevel { return this.handle.getLevel(); } - @Override - public void addFreshEntityWithPassengers(Entity entity) { - this.handle.addFreshEntityWithPassengers(entity); - } - - @Override - public void addFreshEntityWithPassengers(Entity entity, CreatureSpawnEvent.SpawnReason reason) { - this.handle.addFreshEntityWithPassengers(entity, reason); - } + // Paper start - Don't fire sync event during generation; don't override these methods so all entities are run through addFreshEntity + // @Override + // public void addFreshEntityWithPassengers(Entity entity) { + // this.handle.addFreshEntityWithPassengers(entity); + // } + // + // @Override + // public void addFreshEntityWithPassengers(Entity entity, CreatureSpawnEvent.SpawnReason reason) { + // this.handle.addFreshEntityWithPassengers(entity, reason); + // } + // Paper end - Don't fire sync event during generation; don't override these methods so all entities are run through addFreshEntity @Override public ServerLevel getMinecraftWorld() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java index 35ecf6f824..1d1fdcf104 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/TransformerGeneratorAccess.java @@ -39,21 +39,23 @@ public class TransformerGeneratorAccess extends DelegatedGeneratorAccess { return super.addFreshEntity(arg0, arg1); } - @Override - public void addFreshEntityWithPassengers(Entity entity) { - if (this.structureTransformer != null && !this.structureTransformer.transformEntity(entity)) { - return; - } - super.addFreshEntityWithPassengers(entity); - } - - @Override - public void addFreshEntityWithPassengers(Entity arg0, SpawnReason arg1) { - if (this.structureTransformer != null && !this.structureTransformer.transformEntity(arg0)) { - return; - } - super.addFreshEntityWithPassengers(arg0, arg1); - } + // Paper start - Don't fire sync event during generation; don't override these methods so all entities are run through addFreshEntity + // @Override + // public void addFreshEntityWithPassengers(Entity entity) { + // if (this.structureTransformer != null && !this.structureTransformer.transformEntity(entity)) { + // return; + // } + // super.addFreshEntityWithPassengers(entity); + // } + // + // @Override + // public void addFreshEntityWithPassengers(Entity arg0, SpawnReason arg1) { + // if (this.structureTransformer != null && !this.structureTransformer.transformEntity(arg0)) { + // return; + // } + // super.addFreshEntityWithPassengers(arg0, arg1); + // } + // Paper end - Don't fire sync event during generation; don't override these methods public boolean setCraftBlock(BlockPos position, CraftBlockState craftBlockState, int i, int j) { if (this.structureTransformer != null) {