diff --git a/patches/unapplied/server/Add-PlayerAttackEntityCooldownResetEvent.patch b/patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerAttackEntityCooldownResetEvent.patch rename to patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch diff --git a/patches/unapplied/server/Add-phantom-creative-and-insomniac-controls.patch b/patches/server/Add-phantom-creative-and-insomniac-controls.patch similarity index 93% rename from patches/unapplied/server/Add-phantom-creative-and-insomniac-controls.patch rename to patches/server/Add-phantom-creative-and-insomniac-controls.patch index 41705d485b..fed3ec2fd1 100644 --- a/patches/unapplied/server/Add-phantom-creative-and-insomniac-controls.patch +++ b/patches/server/Add-phantom-creative-and-insomniac-controls.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/EntitySelector.java +++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java @@ -0,0 +0,0 @@ public final class EntitySelector { - return !entity.isSpectator(); }; public static final Predicate CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith); + public static final Predicate CAN_BE_PICKED = EntitySelector.NO_SPECTATORS.and(Entity::isPickable); + public static Predicate IS_INSOMNIAC = (player) -> net.minecraft.util.Mth.clamp(((net.minecraft.server.level.ServerPlayer) player).getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= 72000; // Paper - Add phantom creative and insomniac controls private EntitySelector() {} @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Phantom extends FlyingMob implements Enemy { Player entityhuman = (Player) iterator.next(); - if (Phantom.this.canAttack(entityhuman, TargetingConditions.DEFAULT)) { + if (Phantom.this.canAttack(worldserver, entityhuman, TargetingConditions.DEFAULT)) { + if (!level().paperConfig().entities.behavior.phantomsOnlyAttackInsomniacs || EntitySelector.IS_INSOMNIAC.test(entityhuman)) // Paper - Add phantom creative and insomniac controls Phantom.this.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason return true; diff --git a/patches/unapplied/server/Dead-Player-s-shouldn-t-be-able-to-move.patch b/patches/server/Dead-Player-s-shouldn-t-be-able-to-move.patch similarity index 100% rename from patches/unapplied/server/Dead-Player-s-shouldn-t-be-able-to-move.patch rename to patches/server/Dead-Player-s-shouldn-t-be-able-to-move.patch diff --git a/patches/unapplied/server/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch b/patches/server/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch similarity index 100% rename from patches/unapplied/server/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch rename to patches/server/Don-t-crash-if-player-is-attempted-to-be-removed-fro.patch diff --git a/patches/unapplied/server/Don-t-fire-BlockFade-on-worldgen-threads.patch b/patches/server/Don-t-fire-BlockFade-on-worldgen-threads.patch similarity index 84% rename from patches/unapplied/server/Don-t-fire-BlockFade-on-worldgen-threads.patch rename to patches/server/Don-t-fire-BlockFade-on-worldgen-threads.patch index fd1ce928c5..f35ff670ba 100644 --- a/patches/unapplied/server/Don-t-fire-BlockFade-on-worldgen-threads.patch +++ b/patches/server/Don-t-fire-BlockFade-on-worldgen-threads.patch @@ -10,12 +10,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java @@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock { @Override - protected BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) { + protected BlockState updateShape(BlockState state, LevelReader world, ScheduledTickAccess tickView, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState neighborState, RandomSource random) { // CraftBukkit start + if (!(world instanceof ServerLevel)) return this.canSurvive(state, world, pos) ? (BlockState) this.getStateWithAge(world, pos, (Integer) state.getValue(FireBlock.AGE)) : Blocks.AIR.defaultBlockState(); // Paper - don't fire events in world generation if (!this.canSurvive(state, world, pos)) { // Suppress during worldgen - if (!(world instanceof Level)) { + if (!(world instanceof Level world1)) { @@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock { return blockState.getHandle(); } diff --git a/patches/unapplied/server/Don-t-move-existing-players-to-world-spawn.patch b/patches/server/Don-t-move-existing-players-to-world-spawn.patch similarity index 100% rename from patches/unapplied/server/Don-t-move-existing-players-to-world-spawn.patch rename to patches/server/Don-t-move-existing-players-to-world-spawn.patch diff --git a/patches/unapplied/server/Don-t-run-entity-collision-code-if-not-needed.patch b/patches/server/Don-t-run-entity-collision-code-if-not-needed.patch similarity index 88% rename from patches/unapplied/server/Don-t-run-entity-collision-code-if-not-needed.patch rename to patches/server/Don-t-run-entity-collision-code-if-not-needed.patch index f65857cd30..3d07807e84 100644 --- a/patches/unapplied/server/Don-t-run-entity-collision-code-if-not-needed.patch +++ b/patches/server/Don-t-run-entity-collision-code-if-not-needed.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - if (this.level().isClientSide()) { + if (!(world instanceof ServerLevel worldserver)) { this.level().getEntities(EntityTypeTest.forClass(net.minecraft.world.entity.player.Player.class), this.getBoundingBox(), EntitySelector.pushableBy(this)).forEach(this::doPush); } else { + // Paper start - don't run getEntities if we're not going to use its result @@ -33,10 +33,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + // Paper end - don't run getEntities if we're not going to use its result - List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this)); + List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this)); if (!list.isEmpty()) { -- int i = this.level().getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); +- int i = worldserver.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); + // Paper - don't run getEntities if we're not going to use its result; moved up if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) { diff --git a/patches/unapplied/server/Don-t-tick-dead-players.patch b/patches/server/Don-t-tick-dead-players.patch similarity index 100% rename from patches/unapplied/server/Don-t-tick-dead-players.patch rename to patches/server/Don-t-tick-dead-players.patch diff --git a/patches/unapplied/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch b/patches/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch similarity index 82% rename from patches/unapplied/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch rename to patches/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch index 2a20979047..1e02d8d5a6 100644 --- a/patches/unapplied/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch +++ b/patches/server/Fire-PlayerJoinEvent-when-Player-is-actually-ready.patch @@ -66,7 +66,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + player.supressTrackerForLogin = true; + worldserver1.addNewPlayer(player); + this.server.getCustomBossEvents().onPlayerConnect(player); // see commented out section below worldserver.addPlayerJoin(entityplayer); -+ this.mountSavedVehicle(player, worldserver1, optional); ++ player.loadAndSpawnEnderpearls(optional); ++ player.loadAndSpawnParentVehicle(optional); + // Paper end - Fire PlayerJoinEvent when Player is actually ready // CraftBukkit start CraftPlayer bukkitPlayer = player.getBukkitEntity(); @@ -84,22 +85,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worldserver1 = player.serverLevel(); // CraftBukkit - Update in case join event changed it // CraftBukkit end this.sendActivePlayerEffects(player); -+ // Paper start - Fire PlayerJoinEvent when Player is actually ready; move vehicle into method so it can be called above - short circuit around that code -+ this.onPlayerJoinFinish(player, worldserver1, s1); -+ } -+ private void mountSavedVehicle(ServerPlayer player, ServerLevel worldserver1, Optional optional) { -+ // Paper end - Fire PlayerJoinEvent when Player is actually ready - if (optional.isPresent() && ((CompoundTag) optional.get()).contains("RootVehicle", 10)) { - CompoundTag nbttagcompound = ((CompoundTag) optional.get()).getCompound("RootVehicle"); - ServerLevel finalWorldServer = worldserver1; // CraftBukkit - decompile error -@@ -0,0 +0,0 @@ public abstract class PlayerList { - } - } - -+ // Paper start - Fire PlayerJoinEvent when Player is actually ready -+ } -+ public void onPlayerJoinFinish(ServerPlayer player, ServerLevel worldserver1, String s1) { -+ // Paper end - Fire PlayerJoinEvent when Player is actually ready +- player.loadAndSpawnEnderpearls(optional); +- player.loadAndSpawnParentVehicle(optional); ++ // Paper - move loading pearls / parent vehicle up player.initInventoryMenu(); // CraftBukkit - Moved from above, added world // Paper start - Configurable player collision; Add to collideRule team if needed diff --git a/patches/unapplied/server/Fix-item-duplication-and-teleport-issues.patch b/patches/server/Fix-item-duplication-and-teleport-issues.patch similarity index 85% rename from patches/unapplied/server/Fix-item-duplication-and-teleport-issues.patch rename to patches/server/Fix-item-duplication-and-teleport-issues.patch index 6d7e349aa4..ba0f38abbb 100644 --- a/patches/unapplied/server/Fix-item-duplication-and-teleport-issues.patch +++ b/patches/server/Fix-item-duplication-and-teleport-issues.patch @@ -28,14 +28,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return null; } // CraftBukkit end -- ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY() + (double) yOffset, this.getZ(), stack); -+ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY() + (double) yOffset, this.getZ(), stack.copy()); // Paper - copy so we can destroy original + ItemEntity entityitem = new ItemEntity(world, this.getX(), this.getY() + (double) yOffset, this.getZ(), stack); + stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe entityitem.setDefaultPickUpDelay(); // CraftBukkit start @@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - public Entity changeDimension(DimensionTransition teleportTarget) { + public Entity teleport(TeleportTransition teleportTarget) { Level world = this.level(); + // Paper start - Fix item duplication and teleport issues @@ -48,26 +47,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!this.isRemoved()) { // CraftBukkit start @@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - - if (entity2 != null) { - if (this != entity2) { -+ // Paper start - Fix item duplication and teleport issues -+ if (this instanceof Leashable leashable) { -+ leashable.dropLeash(true, true); // Paper drop lead -+ } -+ // Paper end - Fix item duplication and teleport issues - entity2.restoreFrom(this); - this.removeAfterChangingDimensions(); - // CraftBukkit start - Forward the CraftEntity to the new entity + gameprofilerfiller.pop(); + return null; + } else { ++ // Paper start - Fix item duplication and teleport issues ++ if (this instanceof Leashable leashable) { ++ leashable.dropLeash(true, true); // Paper drop lead ++ } ++ // Paper end - Fix item duplication and teleport issues + entity.restoreFrom(this); + this.removeAfterChangingDimensions(); + // CraftBukkit start - Forward the CraftEntity to the new entity @@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } - public boolean canChangeDimensions(Level from, Level to) { -- return true; -+ return this.isAlive() && this.valid; // Paper - Fix item duplication and teleport issues - } + public boolean canTeleport(Level from, Level to) { ++ if (!this.isAlive() || !this.valid) return false; // Paper - Fix item duplication and teleport issues + if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { + Iterator iterator = this.getPassengers().iterator(); - public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -138,7 +136,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); - EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(damageSource.getEntity())); + CraftWorld world = (CraftWorld) entity.getWorld(); @@ -0,0 +0,0 @@ public class CraftEventFactory { playDeathSound(victim, event); // Paper end diff --git a/patches/unapplied/server/Implement-Player-Client-Options-API.patch b/patches/server/Implement-Player-Client-Options-API.patch similarity index 100% rename from patches/unapplied/server/Implement-Player-Client-Options-API.patch rename to patches/server/Implement-Player-Client-Options-API.patch diff --git a/patches/unapplied/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch b/patches/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch similarity index 100% rename from patches/unapplied/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch rename to patches/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch diff --git a/patches/unapplied/server/Optimize-Pathfinding.patch b/patches/server/Optimize-Pathfinding.patch similarity index 100% rename from patches/unapplied/server/Optimize-Pathfinding.patch rename to patches/server/Optimize-Pathfinding.patch diff --git a/patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch b/patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch similarity index 98% rename from patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch rename to patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch index d3642f9353..3cf0490d7e 100644 --- a/patches/unapplied/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch +++ b/patches/server/Prevent-Double-PlayerChunkMap-adds-crashing-server.patch @@ -28,7 +28,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public void onTrackingStart(Entity entity) { org.spigotmc.AsyncCatcher.catchOp("entity register"); // Spigot @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entity instanceof ServerPlayer entityplayer) { ServerLevel.this.players.add(entityplayer); ServerLevel.this.updateSleepingPlayerList(); -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.inWorld = true; // CraftBukkit - Mark entity as in world entity.valid = true; // CraftBukkit diff --git a/patches/unapplied/server/Prevent-opening-inventories-when-frozen.patch b/patches/server/Prevent-opening-inventories-when-frozen.patch similarity index 100% rename from patches/unapplied/server/Prevent-opening-inventories-when-frozen.patch rename to patches/server/Prevent-opening-inventories-when-frozen.patch diff --git a/patches/unapplied/server/Prevent-teleporting-dead-entities.patch b/patches/server/Prevent-teleporting-dead-entities.patch similarity index 77% rename from patches/unapplied/server/Prevent-teleporting-dead-entities.patch rename to patches/server/Prevent-teleporting-dead-entities.patch index 45b4ea4b30..e58d952794 100644 --- a/patches/unapplied/server/Prevent-teleporting-dead-entities.patch +++ b/patches/server/Prevent-teleporting-dead-entities.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl } - public void internalTeleport(double d0, double d1, double d2, float f, float f1, Set set) { // Paper + public void internalTeleport(PositionMoveRotation positionmoverotation, Set set) { + // Paper start - Prevent teleporting dead entities + if (player.isRemoved()) { + LOGGER.info("Attempt to teleport removed player {} restricted", player.getScoreboardName()); @@ -19,6 +19,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + // Paper end - Prevent teleporting dead entities - // CraftBukkit start - if (Float.isNaN(f)) { - f = 0; + if (Float.isNaN(positionmoverotation.yRot())) { + positionmoverotation = new PositionMoveRotation(positionmoverotation.position(), positionmoverotation.deltaMovement(), 0, positionmoverotation.xRot()); + } diff --git a/patches/unapplied/server/Reduce-Either-Optional-allocation.patch b/patches/server/Reduce-Either-Optional-allocation.patch similarity index 100% rename from patches/unapplied/server/Reduce-Either-Optional-allocation.patch rename to patches/server/Reduce-Either-Optional-allocation.patch diff --git a/patches/unapplied/server/Reduce-memory-footprint-of-CompoundTag.patch b/patches/server/Reduce-memory-footprint-of-CompoundTag.patch similarity index 100% rename from patches/unapplied/server/Reduce-memory-footprint-of-CompoundTag.patch rename to patches/server/Reduce-memory-footprint-of-CompoundTag.patch diff --git a/patches/unapplied/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch b/patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch similarity index 100% rename from patches/unapplied/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch rename to patches/server/Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch diff --git a/patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch b/patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch similarity index 76% rename from patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch rename to patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch index 7a4188c21b..f5170691ed 100644 --- a/patches/unapplied/server/Validate-PickItem-Packet-and-kick-for-invalid.patch +++ b/patches/server/Validate-PickItem-Packet-and-kick-for-invalid.patch @@ -21,6 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed + // Paper end - validate pick item position - this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, this.player.getInventory().selected, this.player.getInventory().getItem(this.player.getInventory().selected))); - this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, packet.getSlot(), this.player.getInventory().getItem(packet.getSlot()))); - this.player.connection.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected)); + int i = this.player.getInventory().selected; + + this.player.connection.send(this.player.getInventory().createInventoryUpdatePacket(i)); diff --git a/patches/unapplied/server/Villager-Restocks-API.patch b/patches/server/Villager-Restocks-API.patch similarity index 100% rename from patches/unapplied/server/Villager-Restocks-API.patch rename to patches/server/Villager-Restocks-API.patch diff --git a/patches/unapplied/server/misc-debugging-dumps.patch b/patches/server/misc-debugging-dumps.patch similarity index 100% rename from patches/unapplied/server/misc-debugging-dumps.patch rename to patches/server/misc-debugging-dumps.patch