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 20b894a4b0..3845d17a64 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 @@ -1,46 +1,11 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -54,7 +_,6 @@ - import net.minecraft.network.protocol.game.ClientboundDamageEventPacket; - import net.minecraft.network.protocol.game.ClientboundEntityEventPacket; - import net.minecraft.network.protocol.game.ClientboundExplodePacket; --import net.minecraft.network.protocol.game.ClientboundGameEventPacket; - import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; - import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; - import net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket; -@@ -120,6 +_,7 @@ - import net.minecraft.world.level.StructureManager; - import net.minecraft.world.level.WorldGenLevel; - import net.minecraft.world.level.biome.Biome; -+import net.minecraft.world.level.biome.BiomeSource; - import net.minecraft.world.level.block.Block; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.SnowLayerBlock; -@@ -145,7 +_,9 @@ - import net.minecraft.world.level.gameevent.DynamicGameEventListener; - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.level.gameevent.GameEventDispatcher; -+import net.minecraft.world.level.levelgen.FlatLevelSource; - import net.minecraft.world.level.levelgen.Heightmap; -+import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; - import net.minecraft.world.level.levelgen.structure.BoundingBox; - import net.minecraft.world.level.levelgen.structure.Structure; - import net.minecraft.world.level.levelgen.structure.StructureCheck; -@@ -161,7 +_,7 @@ - import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - import net.minecraft.world.level.storage.DimensionDataStorage; - import net.minecraft.world.level.storage.LevelStorageSource; --import net.minecraft.world.level.storage.ServerLevelData; -+import net.minecraft.world.level.storage.PrimaryLevelData; - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.phys.shapes.BooleanOp; @@ -182,7 +_,7 @@ final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; - public final ServerLevelData serverLevelData; -+ public final PrimaryLevelData serverLevelData; // CraftBukkit - type ++ public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(); public final PersistentEntitySectionManager entityManager; @@ -204,11 +169,11 @@ + this.serverLevelData.setWorld(this); + + if (biomeProvider != null) { -+ BiomeSource worldChunkManager = new org.bukkit.craftbukkit.generator.CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().lookupOrThrow(Registries.BIOME), chunkGenerator.getBiomeSource()); // Paper - add vanillaBiomeProvider -+ if (chunkGenerator instanceof NoiseBasedChunkGenerator cga) { -+ chunkGenerator = new NoiseBasedChunkGenerator(worldChunkManager, cga.settings); -+ } else if (chunkGenerator instanceof FlatLevelSource cpf) { -+ chunkGenerator = new FlatLevelSource(cpf.settings(), worldChunkManager); ++ net.minecraft.world.level.biome.BiomeSource worldChunkManager = new org.bukkit.craftbukkit.generator.CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().lookupOrThrow(Registries.BIOME), chunkGenerator.getBiomeSource()); // Paper - add vanillaBiomeProvider ++ if (chunkGenerator instanceof net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator cga) { ++ chunkGenerator = new net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator(worldChunkManager, cga.settings); ++ } else if (chunkGenerator instanceof net.minecraft.world.level.levelgen.FlatLevelSource cpf) { ++ chunkGenerator = new net.minecraft.world.level.levelgen.FlatLevelSource(cpf.settings(), worldChunkManager); + } + } + diff --git a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch index aa0d442fc8..37842106ce 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/server/players/GameProfileCache.java +++ b/net/minecraft/server/players/GameProfileCache.java -@@ -17,8 +_,6 @@ - import java.io.File; - import java.io.FileNotFoundException; - import java.io.IOException; --import java.io.Reader; --import java.io.Writer; - import java.nio.charset.StandardCharsets; - import java.text.DateFormat; - import java.text.ParseException; @@ -56,6 +_,10 @@ private final AtomicLong operationCount = new AtomicLong(); @Nullable @@ -135,15 +126,6 @@ } public void setExecutor(Executor exectutor) { -@@ -193,7 +_,7 @@ - - try { - Object var9; -- try (Reader reader = Files.newReader(this.file, StandardCharsets.UTF_8)) { -+ try (java.io.Reader reader = Files.newReader(this.file, StandardCharsets.UTF_8)) { - JsonArray jsonArray = this.gson.fromJson(reader, JsonArray.class); - if (jsonArray != null) { - DateFormat dateFormat = createDateFormat(); @@ -206,6 +_,11 @@ return (List)var9; @@ -169,8 +151,7 @@ String string = this.gson.toJson((JsonElement)jsonArray); + Runnable save = () -> { // Paper - Perf: Async GameProfileCache saving -- try (Writer writer = Files.newWriter(this.file, StandardCharsets.UTF_8)) { -+ try (java.io.Writer writer = Files.newWriter(this.file, StandardCharsets.UTF_8)) { + try (Writer writer = Files.newWriter(this.file, StandardCharsets.UTF_8)) { writer.write(string); } catch (IOException var9) { } 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 06d3a35857..4dfa987afe 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 @@ -1,63 +1,8 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -55,6 +_,8 @@ - import net.minecraft.network.protocol.Packet; - import net.minecraft.network.protocol.game.ClientGamePacketListener; - import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; -+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket; -+import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket; - import net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket; - import net.minecraft.network.protocol.game.VecDeltaCodec; - import net.minecraft.network.syncher.EntityDataAccessor; -@@ -97,8 +_,6 @@ - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.ClipContext; - import net.minecraft.world.level.Explosion; --import net.minecraft.world.level.ItemLike; --import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.Block; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.FenceGateBlock; -@@ -135,7 +_,151 @@ - import net.minecraft.world.scores.Team; +@@ -136,6 +_,114 @@ import org.slf4j.Logger; -+// CraftBukkit start -+import net.minecraft.world.level.GameRules; -+import net.minecraft.world.level.ItemLike; -+import net.minecraft.world.level.Level; -+import org.bukkit.Bukkit; -+import org.bukkit.Location; -+import org.bukkit.block.BlockFace; -+import org.bukkit.command.CommandSender; -+import org.bukkit.entity.Hanging; -+import org.bukkit.entity.Vehicle; -+import org.bukkit.event.entity.EntityCombustByEntityEvent; -+import org.bukkit.event.hanging.HangingBreakByEntityEvent; -+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; -+import org.bukkit.event.vehicle.VehicleEnterEvent; -+import org.bukkit.event.vehicle.VehicleExitEvent; -+import org.bukkit.craftbukkit.CraftWorld; -+import org.bukkit.craftbukkit.entity.CraftEntity; -+import org.bukkit.craftbukkit.entity.CraftPlayer; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.event.CraftPortalEvent; -+import org.bukkit.craftbukkit.util.CraftLocation; -+import org.bukkit.event.entity.EntityAirChangeEvent; -+import org.bukkit.event.entity.EntityCombustEvent; -+import org.bukkit.event.entity.EntityDismountEvent; -+import org.bukkit.event.entity.EntityDropItemEvent; -+import org.bukkit.event.entity.EntityMountEvent; -+import org.bukkit.event.entity.EntityPortalEvent; -+import org.bukkit.event.entity.EntityPoseChangeEvent; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.EntityTeleportEvent; -+import org.bukkit.event.entity.EntityUnleashEvent; -+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; -+import org.bukkit.event.player.PlayerTeleportEvent; -+import org.bukkit.plugin.PluginManager; -+// CraftBukkit end -+ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { + + // CraftBukkit start @@ -141,14 +86,14 @@ + // Paper end - Share random for entities to make them more random + public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + -+ private CraftEntity bukkitEntity; ++ private org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; + -+ public CraftEntity getBukkitEntity() { ++ public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntity() { + if (this.bukkitEntity == null) { + // Paper start - Folia schedulers + synchronized (this) { + if (this.bukkitEntity == null) { -+ return this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this); ++ return this.bukkitEntity = org.bukkit.craftbukkit.entity.CraftEntity.getEntity(this.level.getCraftServer(), this); + } + } + // Paper end - Folia schedulers @@ -156,7 +101,7 @@ + return this.bukkitEntity; + } + // Paper start -+ public CraftEntity getBukkitEntityRaw() { ++ public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntityRaw() { + return this.bukkitEntity; + } + // Paper end @@ -226,7 +171,7 @@ + public boolean fixedPose = false; // Paper - Expand Pose API + private final int despawnTime; // Paper - entity despawn time limit + -+ public void setOrigin(@javax.annotation.Nonnull Location location) { ++ public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) { + this.origin = location.toVector(); + this.originWorld = location.getWorld().getUID(); + } @@ -293,7 +238,7 @@ public void kill(ServerLevel level) { - this.remove(Entity.RemovalReason.KILLED); -+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause ++ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause this.gameEvent(GameEvent.ENTITY_DIE); } @@ -303,7 +248,7 @@ + this.discard(null); + } + -+ public final void discard(EntityRemoveEvent.Cause cause) { ++ public final void discard(org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { + this.remove(Entity.RemovalReason.DISCARDED, cause); + // CraftBukkit end } @@ -318,7 +263,7 @@ + List> list = this.entityData.packAll(); // Paper - Update EVERYTHING not just not default + + if (list != null && to.getBukkitEntity().canSee(this.getBukkitEntity())) { // Paper -+ to.connection.send(new ClientboundSetEntityDataPacket(this.getId(), list)); ++ to.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(this.getId(), list)); + } + } + // CraftBukkit end @@ -351,7 +296,7 @@ + values.add(synchedValue.value()); + } + -+ to.connection.send(new ClientboundSetEntityDataPacket(this.id, values)); ++ to.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(this.id, values)); + } + // Paper end + @@ -367,7 +312,7 @@ + this.setRemoved(reason, null); + } + -+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { ++ public void remove(Entity.RemovalReason entity_removalreason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { + this.setRemoved(entity_removalreason, cause); + // CraftBukkit end } @@ -385,7 +330,7 @@ + } + // Paper start - Don't fire sync event during generation + if (!this.generation) { -+ this.level.getCraftServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), org.bukkit.entity.Pose.values()[pose.ordinal()])); ++ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityPoseChangeEvent(this.getBukkitEntity(), org.bukkit.entity.Pose.values()[pose.ordinal()])); + } + // Paper end - Don't fire sync event during generation + // CraftBukkit end @@ -405,7 +350,7 @@ + if (yRot == Float.POSITIVE_INFINITY || yRot == Float.NEGATIVE_INFINITY) { + if (this instanceof ServerPlayer) { + this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid yaw"); -+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); ++ ((org.bukkit.craftbukkit.entity.CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); + } + yRot = 0; + } @@ -418,7 +363,7 @@ + if (xRot == Float.POSITIVE_INFINITY || xRot == Float.NEGATIVE_INFINITY) { + if (this instanceof ServerPlayer) { + this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid pitch"); -+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); ++ ((org.bukkit.craftbukkit.entity.CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); + } + xRot = 0; + } @@ -519,7 +464,7 @@ + // not on fire yet + org.bukkit.block.Block damager = (this.lastLavaContact == null) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.lastLavaContact); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); -+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); ++ org.bukkit.event.entity.EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); + this.level.getCraftServer().getPluginManager().callEvent(combustEvent); + + if (!combustEvent.isCancelled()) { @@ -547,7 +492,7 @@ + + public final void igniteForSeconds(float f, boolean callEvent) { + if (callEvent) { -+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f); ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustEvent(this.getBukkitEntity(), f); + this.level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -566,7 +511,7 @@ protected void onBelowWorld() { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause } public boolean isFree(double x, double y, double z) { @@ -583,22 +528,22 @@ } + // CraftBukkit start -+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) { -+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ if (this.horizontalCollision && this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) { ++ org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); + org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); + + if (movement.x > vec3.x) { -+ bl = bl.getRelative(BlockFace.EAST); ++ bl = bl.getRelative(org.bukkit.block.BlockFace.EAST); + } else if (movement.x < vec3.x) { -+ bl = bl.getRelative(BlockFace.WEST); ++ bl = bl.getRelative(org.bukkit.block.BlockFace.WEST); + } else if (movement.z > vec3.z) { -+ bl = bl.getRelative(BlockFace.SOUTH); ++ bl = bl.getRelative(org.bukkit.block.BlockFace.SOUTH); + } else if (movement.z < vec3.z) { -+ bl = bl.getRelative(BlockFace.NORTH); ++ bl = bl.getRelative(org.bukkit.block.BlockFace.NORTH); + } + + if (!bl.getType().isAir()) { -+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity ++ org.bukkit.event.vehicle.VehicleBlockCollisionEvent event = new org.bukkit.event.vehicle.VehicleBlockCollisionEvent(vehicle, bl, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity + this.level.getCraftServer().getPluginManager().callEvent(event); + } + } @@ -1021,8 +966,8 @@ + { + // Paper end - Call EntityDropItemEvent + // CraftBukkit start -+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); -+ Bukkit.getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return null; + } @@ -1037,10 +982,10 @@ - if (player.hasInfiniteMaterials()) { + // CraftBukkit start - fire PlayerUnleashEntityEvent + // Paper start - Expand EntityUnleashEvent -+ org.bukkit.event.player.PlayerUnleashEntityEvent event = CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.hasInfiniteMaterials()); ++ org.bukkit.event.player.PlayerUnleashEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerUnleashEntityEvent(this, player, hand, !player.hasInfiniteMaterials()); + if (event.isCancelled()) { + // Paper end - Expand EntityUnleashEvent -+ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); ++ ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); + return InteractionResult.PASS; + } + // CraftBukkit end @@ -1053,9 +998,9 @@ if (itemInHand.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { + // CraftBukkit start - fire PlayerLeashEntityEvent -+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(this, player, player, hand).isCancelled()) { + // ((ServerPlayer) player).resendItemInHands(); // SPIGOT-7615: Resend to fix client desync with used item // Paper - Fix inventory desync -+ ((ServerPlayer) player).connection.send(new ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); ++ ((ServerPlayer) player).connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(this, leashable.getLeashHolder())); + player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync + return InteractionResult.PASS; + } @@ -1082,21 +1027,21 @@ if (force || this.canRide(vehicle) && vehicle.canAddPassenger(this)) { + // CraftBukkit start -+ if (vehicle.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { -+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) vehicle.getBukkitEntity(), this.getBukkitEntity()); ++ if (vehicle.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && this.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { ++ org.bukkit.event.vehicle.VehicleEnterEvent event = new org.bukkit.event.vehicle.VehicleEnterEvent((org.bukkit.entity.Vehicle) vehicle.getBukkitEntity(), this.getBukkitEntity()); + // Suppress during worldgen + if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + } + if (event.isCancelled()) { + return false; + } + } + -+ EntityMountEvent event = new EntityMountEvent(this.getBukkitEntity(), vehicle.getBukkitEntity()); ++ org.bukkit.event.entity.EntityMountEvent event = new org.bukkit.event.entity.EntityMountEvent(this.getBukkitEntity(), vehicle.getBukkitEntity()); + // Suppress during worldgen + if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + } + if (event.isCancelled()) { + return false; @@ -1149,28 +1094,28 @@ throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { + // CraftBukkit start -+ CraftEntity craft = (CraftEntity) passenger.getBukkitEntity().getVehicle(); ++ org.bukkit.craftbukkit.entity.CraftEntity craft = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); + Entity orig = craft == null ? null : craft.getHandle(); -+ if (this.getBukkitEntity() instanceof Vehicle && passenger.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { -+ VehicleExitEvent event = new VehicleExitEvent( -+ (Vehicle) this.getBukkitEntity(), ++ if (this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle && passenger.getBukkitEntity() instanceof org.bukkit.entity.LivingEntity) { ++ org.bukkit.event.vehicle.VehicleExitEvent event = new org.bukkit.event.vehicle.VehicleExitEvent( ++ (org.bukkit.entity.Vehicle) this.getBukkitEntity(), + (org.bukkit.entity.LivingEntity) passenger.getBukkitEntity(), !suppressCancellation // Paper - Force entity dismount during teleportation + ); + // Suppress during worldgen + if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + } -+ CraftEntity craftn = (CraftEntity) passenger.getBukkitEntity().getVehicle(); ++ org.bukkit.craftbukkit.entity.CraftEntity craftn = (org.bukkit.craftbukkit.entity.CraftEntity) passenger.getBukkitEntity().getVehicle(); + Entity n = craftn == null ? null : craftn.getHandle(); + if (event.isCancelled() || n != orig) { + return false; + } + } + -+ EntityDismountEvent event = new EntityDismountEvent(passenger.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper - Force entity dismount during teleportation ++ org.bukkit.event.entity.EntityDismountEvent event = new org.bukkit.event.entity.EntityDismountEvent(passenger.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper - Force entity dismount during teleportation + // Suppress during worldgen + if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); ++ org.bukkit.Bukkit.getPluginManager().callEvent(event); + } + if (event.isCancelled()) { + return false; @@ -1220,7 +1165,7 @@ public void setSwimming(boolean swimming) { + // CraftBukkit start + if (this.valid && this.isSwimming() != swimming && this instanceof net.minecraft.world.entity.LivingEntity) { -+ if (CraftEventFactory.callToggleSwimEvent((net.minecraft.world.entity.LivingEntity) this, swimming).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callToggleSwimEvent((net.minecraft.world.entity.LivingEntity) this, swimming).isCancelled()) { + return; + } + } @@ -1264,7 +1209,7 @@ public void setAirSupply(int air) { - this.entityData.set(DATA_AIR_SUPPLY_ID, air); + // CraftBukkit start -+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), air); ++ org.bukkit.event.entity.EntityAirChangeEvent event = new org.bukkit.event.entity.EntityAirChangeEvent(this.getBukkitEntity(), air); + // Suppress during worldgen + if (this.valid) { + event.getEntity().getServer().getPluginManager().callEvent(event); @@ -1285,7 +1230,7 @@ + // CraftBukkit start + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = lightning.getBukkitEntity(); -+ final PluginManager pluginManager = Bukkit.getPluginManager(); ++ final org.bukkit.plugin.PluginManager pluginManager = org.bukkit.Bukkit.getPluginManager(); + // CraftBukkit end if (this.remainingFireTicks == 0) { - this.igniteForSeconds(8.0F); @@ -1293,7 +1238,7 @@ - - this.hurtServer(level, this.damageSources().lightningBolt(), 5.0F); + // CraftBukkit start - Call a combust event when lightning strikes -+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F); ++ org.bukkit.event.entity.EntityCombustByEntityEvent entityCombustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8.0F); + pluginManager.callEvent(entityCombustEvent); + if (!entityCombustEvent.isCancelled()) { + this.igniteForSeconds(entityCombustEvent.getDuration(), false); @@ -1306,8 +1251,8 @@ + } + + // CraftBukkit start -+ if (thisBukkitEntity instanceof Hanging) { -+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity); ++ if (thisBukkitEntity instanceof org.bukkit.entity.Hanging) { ++ org.bukkit.event.hanging.HangingBreakByEntityEvent hangingEvent = new org.bukkit.event.hanging.HangingBreakByEntityEvent((org.bukkit.entity.Hanging) thisBukkitEntity, stormBukkitEntity); + pluginManager.callEvent(hangingEvent); + + if (hangingEvent.isCancelled()) { @@ -1365,7 +1310,7 @@ public void restoreFrom(Entity entity) { + // Paper start - Forward CraftEntity in teleport command -+ CraftEntity bukkitEntity = entity.bukkitEntity; ++ org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity = entity.bukkitEntity; + if (bukkitEntity != null) { + bukkitEntity.setHandle(this); + this.bukkitEntity = bukkitEntity; @@ -1388,14 +1333,14 @@ + // CraftBukkit start + PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); + Vec3 velocity = absolutePosition.deltaMovement(); // Paper -+ Location to = CraftLocation.toBukkit(absolutePosition.position(), teleportTransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); ++ org.bukkit.Location to = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), teleportTransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + // Paper start - gateway-specific teleport event -+ final EntityTeleportEvent teleEvent; ++ final org.bukkit.event.entity.EntityTeleportEvent teleEvent; + if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level.getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) { + teleEvent = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), to, new org.bukkit.craftbukkit.block.CraftEndGateway(to.getWorld(), theEndGatewayBlockEntity)); + teleEvent.callEvent(); + } else { -+ teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to); ++ teleEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, to); + } + // Paper end - gateway-specific teleport event + if (teleEvent.isCancelled() || teleEvent.getTo() == null) { @@ -1403,12 +1348,12 @@ + } + if (!to.equals(teleEvent.getTo())) { + to = teleEvent.getTo(); -+ teleportTransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3.ZERO, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); ++ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(to), Vec3.ZERO, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); + // Paper start - Call EntityPortalExitEvent + velocity = Vec3.ZERO; + } + if (this.portalProcess != null) { // if in a portal -+ CraftEntity bukkitEntity = this.getBukkitEntity(); ++ org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity = this.getBukkitEntity(); + org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent( + bukkitEntity, + bukkitEntity.getLocation(), to.clone(), @@ -1420,7 +1365,7 @@ + if (!event.isCancelled() && event.getTo() != null && (!event.getTo().equals(event.getFrom()) || !event.getAfter().equals(event.getBefore()))) { + to = event.getTo().clone(); + velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter()); -+ teleportTransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), velocity, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); ++ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(to), velocity, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); + } + } + if (this.isRemoved()) { @@ -1462,7 +1407,7 @@ + this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause + if (this instanceof Leashable leashable && leashable.isLeashed()) { // Paper - only call if it is leashed + // Paper start - Expand EntityUnleashEvent -+ final EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, false); // CraftBukkit ++ final org.bukkit.event.entity.EntityUnleashEvent event = new org.bukkit.event.entity.EntityUnleashEvent(this.getBukkitEntity(), org.bukkit.event.entity.EntityUnleashEvent.UnleashReason.UNKNOWN, false); // CraftBukkit + event.callEvent(); + if (!event.isDropLeash()) { + leashable.removeLeash(); @@ -1478,9 +1423,9 @@ } + // CraftBukkit start -+ public CraftPortalEvent callPortalEvent(Entity entity, Location exit, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { ++ public org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent(Entity entity, org.bukkit.Location exit, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); -+ Location enter = bukkitEntity.getLocation(); ++ org.bukkit.Location enter = bukkitEntity.getLocation(); + + // Paper start + final org.bukkit.PortalType portalType = switch (cause) { @@ -1489,13 +1434,13 @@ + case END_GATEWAY -> org.bukkit.PortalType.END_GATEWAY; // not actually used yet + default -> org.bukkit.PortalType.CUSTOM; + }; -+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, true, creationRadius, portalType); ++ org.bukkit.event.entity.EntityPortalEvent event = new org.bukkit.event.entity.EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, true, creationRadius, portalType); + // Paper end + event.getEntity().getServer().getPluginManager().callEvent(event); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) { + return null; + } -+ return new CraftPortalEvent(event); ++ return new org.bukkit.craftbukkit.event.CraftPortalEvent(event); + } + // CraftBukkit end + @@ -1515,7 +1460,7 @@ - public boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera) { + // CraftBukkit start + public final boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera) { -+ return this.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, PlayerTeleportEvent.TeleportCause.UNKNOWN); ++ return this.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); + } + public boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end @@ -1629,13 +1574,13 @@ + } + + @Override -+ public CommandSender getBukkitSender(CommandSourceStack wrapper) { ++ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { + return Entity.this.getBukkitEntity(); + } + + @Override + public boolean acceptsSuccess() { -+ return ((ServerLevel) Entity.this.level()).getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK); ++ return ((ServerLevel) Entity.this.level()).getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_SENDCOMMANDFEEDBACK); + } + + @Override @@ -1731,8 +1676,8 @@ + } + + @Override -+ public final void setRemoved(Entity.RemovalReason removalReason, EntityRemoveEvent.Cause cause) { -+ CraftEventFactory.callEntityRemoveEvent(this, cause); ++ public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); + // CraftBukkit end + final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index 0eecee5ed4..5db64d6e7d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,60 +1,5 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -3,18 +_,6 @@ - import java.util.Objects; - import java.util.UUID; - import javax.annotation.Nullable; --import net.minecraft.core.BlockPos; --import net.minecraft.nbt.CompoundTag; --import net.minecraft.network.chat.Component; --import net.minecraft.network.syncher.EntityDataAccessor; --import net.minecraft.network.syncher.EntityDataSerializers; --import net.minecraft.network.syncher.SynchedEntityData; --import net.minecraft.server.level.ServerLevel; --import net.minecraft.sounds.SoundSource; --import net.minecraft.stats.Stats; --import net.minecraft.tags.FluidTags; --import net.minecraft.tags.ItemTags; --import net.minecraft.util.Mth; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.EntityType; -@@ -22,7 +_,6 @@ - import net.minecraft.world.entity.MoverType; - import net.minecraft.world.entity.SlotAccess; - import net.minecraft.world.entity.TraceableEntity; --import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.Item; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Explosion; -@@ -31,6 +_,27 @@ - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.level.portal.TeleportTransition; - import net.minecraft.world.phys.Vec3; -+import net.minecraft.core.BlockPos; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.network.chat.Component; -+import net.minecraft.network.syncher.EntityDataAccessor; -+import net.minecraft.network.syncher.EntityDataSerializers; -+import net.minecraft.network.syncher.SynchedEntityData; -+// CraftBukkit start -+import net.minecraft.server.MinecraftServer; -+import net.minecraft.server.level.ServerLevel; -+import net.minecraft.sounds.SoundSource; -+import net.minecraft.stats.Stats; -+import net.minecraft.tags.FluidTags; -+import net.minecraft.tags.ItemTags; -+import net.minecraft.util.Mth; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.entity.Player; -+import org.bukkit.event.entity.EntityPickupItemEvent; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.player.PlayerPickupItemEvent; -+// CraftBukkit end -+import org.bukkit.event.player.PlayerAttemptPickupItemEvent; // Paper - - public class ItemEntity extends Entity implements TraceableEntity { - private static final EntityDataAccessor DATA_ITEM = SynchedEntityData.defineId(ItemEntity.class, EntityDataSerializers.ITEM_STACK); @@ -49,6 +_,9 @@ @Nullable public UUID target; @@ -84,7 +29,7 @@ public void tick() { if (this.getItem().isEmpty()) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { @@ -117,12 +62,12 @@ - } + if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate + // CraftBukkit start - fire ItemDespawnEvent -+ if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { + this.age = 0; + return; + } + // CraftBukkit end -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } + } + } @@ -146,7 +91,7 @@ + return; + } + // CraftBukkit end -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } + } + // Spigot end @@ -196,7 +141,7 @@ private static void merge(ItemEntity destinationEntity, ItemStack destinationStack, ItemEntity originEntity, ItemStack originStack) { + // CraftBukkit start -+ if (!CraftEventFactory.callItemMergeEvent(originEntity, destinationEntity)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(originEntity, destinationEntity)) { + return; + } + // CraftBukkit end @@ -205,7 +150,7 @@ destinationEntity.age = Math.min(destinationEntity.age, originEntity.age); if (originStack.isEmpty()) { - originEntity.discard(); -+ originEntity.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause ++ originEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause } } @@ -214,7 +159,7 @@ return false; } else { + // CraftBukkit start -+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damageSource, amount)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damageSource, amount)) { + return false; + } + // CraftBukkit end @@ -224,7 +169,7 @@ if (this.health <= 0) { this.getItem().onDestroyed(this); - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } return true; @@ -240,7 +185,7 @@ compound.putShort("Health", (short)this.health); compound.putShort("Age", (short)this.age); compound.putShort("PickupDelay", (short)this.pickupDelay); -@@ -347,22 +_,95 @@ +@@ -347,9 +_,19 @@ } else { this.setItem(ItemStack.EMPTY); } @@ -261,10 +206,7 @@ } } - @Override -- public void playerTouch(Player entity) { -+ public void playerTouch(net.minecraft.world.entity.player.Player entity) { - if (!this.level().isClientSide) { +@@ -359,10 +_,73 @@ ItemStack item = this.getItem(); Item item1 = item.getItem(); int count = item.getCount(); @@ -275,7 +217,7 @@ + + // Paper start - PlayerAttemptPickupItemEvent + if (this.pickupDelay <= 0) { -+ PlayerAttemptPickupItemEvent attemptEvent = new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); ++ org.bukkit.event.player.PlayerAttemptPickupItemEvent attemptEvent = new org.bukkit.event.player.PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + this.level().getCraftServer().getPluginManager().callEvent(attemptEvent); + + flyAtPlayer = attemptEvent.getFlyAtPlayer(); @@ -291,7 +233,7 @@ + if (this.pickupDelay <= 0 && canHold > 0) { + item.setCount(canHold); + // Call legacy event -+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); ++ org.bukkit.event.player.PlayerPickupItemEvent playerEvent = new org.bukkit.event.player.PlayerPickupItemEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems()); + this.level().getCraftServer().getPluginManager().callEvent(playerEvent); + flyAtPlayer = playerEvent.getFlyAtPlayer(); // Paper @@ -306,7 +248,7 @@ + } + + // Call newer event afterwards -+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); ++ org.bukkit.event.entity.EntityPickupItemEvent entityEvent = new org.bukkit.event.entity.EntityPickupItemEvent(entity.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems()); + this.level().getCraftServer().getPluginManager().callEvent(entityEvent); + if (entityEvent.isCancelled()) { @@ -335,7 +277,7 @@ entity.take(this, count); if (item.isEmpty()) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause item.setCount(count); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch index f7754c7cbf..c60f509644 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -1,20 +1,5 @@ --- a/net/minecraft/world/inventory/BrewingStandMenu.java +++ b/net/minecraft/world/inventory/BrewingStandMenu.java -@@ -1,6 +_,5 @@ - package net.minecraft.world.inventory; - --import java.util.Optional; - import net.minecraft.advancements.CriteriaTriggers; - import net.minecraft.core.Holder; - import net.minecraft.core.component.DataComponents; -@@ -16,6 +_,7 @@ - import net.minecraft.world.item.alchemy.Potion; - import net.minecraft.world.item.alchemy.PotionBrewing; - import net.minecraft.world.item.alchemy.PotionContents; -+import java.util.Optional; - - public class BrewingStandMenu extends AbstractContainerMenu { - static final ResourceLocation EMPTY_SLOT_FUEL = ResourceLocation.withDefaultNamespace("container/slot/brewing_fuel"); @@ -33,29 +_,50 @@ private final Container brewingStand; public final ContainerData brewingStandData; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch index f7f4038d0e..9188002f34 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch @@ -1,29 +1,11 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -@@ -15,10 +_,16 @@ - import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.NbtUtils; - import net.minecraft.resources.ResourceKey; -+import net.minecraft.server.level.ServerChunkCache; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.util.datafix.DataFixTypes; - import net.minecraft.world.level.ChunkPos; --import net.minecraft.world.level.Level; -+import net.minecraft.world.level.LevelAccessor; - import net.minecraft.world.level.chunk.ChunkGenerator; -+// CraftBukkit start -+import java.util.concurrent.ExecutionException; -+import net.minecraft.world.level.chunk.status.ChunkStatus; -+import net.minecraft.world.level.dimension.LevelStem; - import net.minecraft.world.level.levelgen.structure.LegacyStructureDataHandler; - import net.minecraft.world.level.storage.DimensionDataStorage; - @@ -38,17 +_,63 @@ return this.worker.isOldChunkAround(pos, radius); } + // CraftBukkit start -+ private boolean check(ServerChunkCache cps, int x, int z) { ++ private boolean check(net.minecraft.server.level.ServerChunkCache cps, int x, int z) { + if (true) return true; // Paper - Perf: this isn't even needed anymore, light is purged updating to 1.14+, why are we holding up the conversion process reading chunk data off disk - return true, we need to set light populated to true so the converter recognizes the chunk as being "full" + ChunkPos pos = new ChunkPos(x, z); + if (cps != null) { @@ -36,7 +18,7 @@ + CompoundTag nbt; + try { + nbt = this.read(pos).get().orElse(null); -+ } catch (InterruptedException | ExecutionException ex) { ++ } catch (InterruptedException | java.util.concurrent.ExecutionException ex) { + throw new RuntimeException(ex); + } + if (nbt != null) { @@ -45,8 +27,8 @@ + return true; + } + -+ ChunkStatus status = ChunkStatus.byName(level.getString("Status")); -+ if (status != null && status.isOrAfter(ChunkStatus.FEATURES)) { ++ net.minecraft.world.level.chunk.status.ChunkStatus status = net.minecraft.world.level.chunk.status.ChunkStatus.byName(level.getString("Status")); ++ if (status != null && status.isOrAfter(net.minecraft.world.level.chunk.status.ChunkStatus.FEATURES)) { + return true; + } + } @@ -56,13 +38,13 @@ + public CompoundTag upgradeChunkTag( - ResourceKey levelKey, -+ ResourceKey levelKey, ++ ResourceKey levelKey, Supplier storage, CompoundTag chunkData, - Optional>> chunkGeneratorKey + Optional>> chunkGeneratorKey, + ChunkPos pos, -+ @Nullable LevelAccessor generatoraccess ++ @Nullable net.minecraft.world.level.LevelAccessor generatoraccess + // CraftBukkit end ) { int version = getVersion(chunkData); @@ -74,7 +56,7 @@ + if (version < 1466) { + CompoundTag level = chunkData.getCompound("Level"); + if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { -+ ServerChunkCache cps = (generatoraccess == null) ? null : ((ServerLevel) generatoraccess).getChunkSource(); ++ net.minecraft.server.level.ServerChunkCache cps = (generatoraccess == null) ? null : ((net.minecraft.server.level.ServerLevel) generatoraccess).getChunkSource(); + if (this.check(cps, pos.x - 1, pos.z) && this.check(cps, pos.x - 1, pos.z - 1) && this.check(cps, pos.x, pos.z - 1)) { + level.putBoolean("LightPopulated", true); + } @@ -90,7 +72,7 @@ + // Spigot start - SPIGOT-6806: Quick and dirty way to prevent below zero generation in old chunks, by setting the status to heightmap instead of empty + boolean stopBelowZero = false; -+ boolean belowZeroGenerationInExistingChunks = (generatoraccess != null) ? ((ServerLevel) generatoraccess).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; ++ boolean belowZeroGenerationInExistingChunks = (generatoraccess != null) ? ((net.minecraft.server.level.ServerLevel) generatoraccess).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; + + if (version <= 2730 && !belowZeroGenerationInExistingChunks) { + stopBelowZero = "full".equals(chunkData.getCompound("Level").getString("Status")); @@ -101,7 +83,7 @@ chunkData = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, chunkData, Math.max(1493, version)); + // Spigot start + if (stopBelowZero) { -+ chunkData.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(ChunkStatus.SPAWN).toString()); ++ chunkData.putString("Status", net.minecraft.core.registries.BuiltInRegistries.CHUNK_STATUS.getKey(net.minecraft.world.level.chunk.status.ChunkStatus.SPAWN).toString()); + } + // Spigot end removeDatafixingContext(chunkData); @@ -112,7 +94,7 @@ } - private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { -+ private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { // CraftBukkit ++ private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, Supplier storage) { // CraftBukkit LegacyStructureDataHandler legacyStructureDataHandler = this.legacyStructureHandler; if (legacyStructureDataHandler == null) { synchronized (this) { @@ -121,7 +103,7 @@ public static void injectDatafixingContext( - CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey -+ CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey // CraftBukkit ++ CompoundTag chunkData, ResourceKey levelKey, Optional>> chunkGeneratorKey // CraftBukkit ) { CompoundTag compoundTag = new CompoundTag(); compoundTag.putString("dimension", levelKey.location().toString()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index f363fd7dbb..23f014d704 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,33 +1,24 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -18,7 +_,7 @@ - import net.minecraft.resources.ResourceKey; - import net.minecraft.util.datafix.DataFixTypes; - import net.minecraft.world.level.ChunkPos; --import net.minecraft.world.level.Level; -+import net.minecraft.world.level.dimension.LevelStem; - import net.minecraft.world.level.storage.DimensionDataStorage; - - public class LegacyStructureDataHandler { @@ -217,17 +_,17 @@ } } - public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { - if (level == Level.OVERWORLD) { -+ public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { // CraftBukkit -+ if (level == LevelStem.OVERWORLD) { // CraftBukkit ++ public static LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey level, @Nullable DimensionDataStorage storage) { // CraftBukkit ++ if (level == net.minecraft.world.level.dimension.LevelStem.OVERWORLD) { // CraftBukkit return new LegacyStructureDataHandler( storage, ImmutableList.of("Monument", "Stronghold", "Village", "Mineshaft", "Temple", "Mansion"), ImmutableList.of("Village", "Mineshaft", "Mansion", "Igloo", "Desert_Pyramid", "Jungle_Pyramid", "Swamp_Hut", "Stronghold", "Monument") ); - } else if (level == Level.NETHER) { -+ } else if (level == LevelStem.NETHER) { // CraftBukkit ++ } else if (level == net.minecraft.world.level.dimension.LevelStem.NETHER) { // CraftBukkit List list = ImmutableList.of("Fortress"); return new LegacyStructureDataHandler(storage, list, list); - } else if (level == Level.END) { -+ } else if (level == LevelStem.END) { // CraftBukkit ++ } else if (level == net.minecraft.world.level.dimension.LevelStem.END) { // CraftBukkit List list = ImmutableList.of("EndCity"); return new LegacyStructureDataHandler(storage, list, list); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index e53e4b3cd9..9baa2a5f6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -26,8 +_,6 @@ - import net.minecraft.world.level.block.Mirror; - import net.minecraft.world.level.block.Rotation; - import net.minecraft.world.level.block.entity.BlockEntity; --import net.minecraft.world.level.block.entity.ChestBlockEntity; --import net.minecraft.world.level.block.entity.DispenserBlockEntity; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.chunk.ChunkGenerator; - import net.minecraft.world.level.levelgen.Heightmap; @@ -47,7 +_,7 @@ private Rotation rotation; protected int genDepth; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch index b94822ff02..55007e0dc7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/IglooPieces.java -@@ -13,8 +_,6 @@ - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.Mirror; - import net.minecraft.world.level.block.Rotation; --import net.minecraft.world.level.block.entity.BlockEntity; --import net.minecraft.world.level.block.entity.ChestBlockEntity; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.chunk.ChunkGenerator; - import net.minecraft.world.level.levelgen.Heightmap; @@ -102,10 +_,13 @@ protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch index 7153875623..ed5789e0f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -25,8 +_,6 @@ - import net.minecraft.world.level.block.ChestBlock; - import net.minecraft.world.level.block.Mirror; - import net.minecraft.world.level.block.Rotation; --import net.minecraft.world.level.block.entity.BlockEntity; --import net.minecraft.world.level.block.entity.ChestBlockEntity; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.chunk.ChunkGenerator; - import net.minecraft.world.level.levelgen.Heightmap; @@ -314,14 +_,20 @@ @Override protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch index 1821e06e5d..75de4affeb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch @@ -1,13 +1,5 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java -@@ -7,7 +_,6 @@ - import net.minecraft.core.Direction; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.util.RandomSource; --import net.minecraft.world.entity.EntityType; - import net.minecraft.world.level.ChunkPos; - import net.minecraft.world.level.StructureManager; - import net.minecraft.world.level.WorldGenLevel; @@ -870,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(5, 3, 6); if (box.isInside(worldPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index d6448bf4b9..dd0b1a8c19 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,13 +1,5 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -66,7 +_,6 @@ - import net.minecraft.world.level.Level; - import net.minecraft.world.level.LevelSettings; - import net.minecraft.world.level.WorldDataConfiguration; --import net.minecraft.world.level.dimension.DimensionType; - import net.minecraft.world.level.dimension.LevelStem; - import net.minecraft.world.level.levelgen.WorldDimensions; - import net.minecraft.world.level.levelgen.WorldGenSettings; @@ -145,6 +_,7 @@ PrimaryLevelData primaryLevelData = PrimaryLevelData.parse( dynamic, levelSettings, complete.specialWorldProperty(), worldGenSettings.options(), lifecycle