From 649ade0d966ba5e873d91aec756e577bc562b9a5 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Tue, 22 Oct 2024 22:00:33 +0200 Subject: [PATCH] Some work --- ...-to-control-if-armor-stands-can-move.patch | 2 +- patches/server/Add-EntityZapEvent.patch | 103 ++++++++++++++++++ .../server/Add-ProjectileCollideEvent.patch | 0 ...setting-for-proxy-online-mode-status.patch | 0 .../Add-source-to-PlayerExpChangeEvent.patch | 0 .../Allow-Reloading-of-Command-Aliases.patch | 0 ...blocking-on-Network-Manager-creation.patch | 0 .../Bound-Treasure-Maps-to-World-Border.patch | 0 .../Cache-user-authenticator-threads.patch | 0 ...figurable-Cartographer-Treasure-Maps.patch | 2 +- .../Configurable-flying-kick-messages.patch | 0 ...onfigurable-packet-in-spam-threshold.patch | 0 ...e-profiles-that-have-no-UUID-and-no-.patch | 0 ...-entity-nbt-data-from-falling-blocks.patch | 0 .../server/Firework-API-s.patch | 18 +-- .../server/Fix-global-sound-handling.patch | 69 ++++++------ ...ptimise-BlockState-s-hashCode-equals.patch | 20 +--- ...ize-Level.hasChunkAt-BlockPosition-Z.patch | 0 ...vent-Pathfinding-out-of-World-Border.patch | 0 .../Properly-fix-item-duplication-bug.patch | 0 .../server/String-based-Action-Bar-API.patch | 0 .../unapplied/server/Add-EntityZapEvent.patch | 48 -------- 22 files changed, 152 insertions(+), 110 deletions(-) rename patches/{unapplied => }/server/Add-API-methods-to-control-if-armor-stands-can-move.patch (96%) create mode 100644 patches/server/Add-EntityZapEvent.patch rename patches/{unapplied => }/server/Add-ProjectileCollideEvent.patch (100%) rename patches/{unapplied => }/server/Add-setting-for-proxy-online-mode-status.patch (100%) rename patches/{unapplied => }/server/Add-source-to-PlayerExpChangeEvent.patch (100%) rename patches/{unapplied => }/server/Allow-Reloading-of-Command-Aliases.patch (100%) rename patches/{unapplied => }/server/Avoid-blocking-on-Network-Manager-creation.patch (100%) rename patches/{unapplied => }/server/Bound-Treasure-Maps-to-World-Border.patch (100%) rename patches/{unapplied => }/server/Cache-user-authenticator-threads.patch (100%) rename patches/{unapplied => }/server/Configurable-Cartographer-Treasure-Maps.patch (97%) rename patches/{unapplied => }/server/Configurable-flying-kick-messages.patch (100%) rename patches/{unapplied => }/server/Configurable-packet-in-spam-threshold.patch (100%) rename patches/{unapplied => }/server/Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch (100%) rename patches/{unapplied => }/server/Filter-bad-block-entity-nbt-data-from-falling-blocks.patch (100%) rename patches/{unapplied => }/server/Firework-API-s.patch (87%) rename patches/{unapplied => }/server/Fix-global-sound-handling.patch (72%) rename patches/{unapplied => }/server/Optimise-BlockState-s-hashCode-equals.patch (71%) rename patches/{unapplied => }/server/Optimize-Level.hasChunkAt-BlockPosition-Z.patch (100%) rename patches/{unapplied => }/server/Prevent-Pathfinding-out-of-World-Border.patch (100%) rename patches/{unapplied => }/server/Properly-fix-item-duplication-bug.patch (100%) rename patches/{unapplied => }/server/String-based-Action-Bar-API.patch (100%) delete mode 100644 patches/unapplied/server/Add-EntityZapEvent.patch diff --git a/patches/unapplied/server/Add-API-methods-to-control-if-armor-stands-can-move.patch b/patches/server/Add-API-methods-to-control-if-armor-stands-can-move.patch similarity index 96% rename from patches/unapplied/server/Add-API-methods-to-control-if-armor-stands-can-move.patch rename to patches/server/Add-API-methods-to-control-if-armor-stands-can-move.patch index f0d3138b8c..08e57ad190 100644 --- a/patches/unapplied/server/Add-API-methods-to-control-if-armor-stands-can-move.patch +++ b/patches/server/Add-API-methods-to-control-if-armor-stands-can-move.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java @@ -0,0 +0,0 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { public boolean hasEquipmentLock(EquipmentSlot equipmentSlot, LockType lockType) { - return (this.getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterFlag() + lockType.ordinal() * 8)) != 0; + return (this.getHandle().disabledSlots & (1 << CraftEquipmentSlot.getNMS(equipmentSlot).getFilterBit(lockType.ordinal() * 8))) != 0; } + // Paper start + @Override diff --git a/patches/server/Add-EntityZapEvent.patch b/patches/server/Add-EntityZapEvent.patch new file mode 100644 index 0000000000..193fd81daa --- /dev/null +++ b/patches/server/Add-EntityZapEvent.patch @@ -0,0 +1,103 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaBlend +Date: Sun, 16 Oct 2016 23:19:30 -0700 +Subject: [PATCH] Add EntityZapEvent + + +diff --git a/src/main/java/net/minecraft/world/entity/ConversionParams.java b/src/main/java/net/minecraft/world/entity/ConversionParams.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/ConversionParams.java ++++ b/src/main/java/net/minecraft/world/entity/ConversionParams.java +@@ -0,0 +0,0 @@ public record ConversionParams(ConversionType type, boolean keepEquipment, boole + public interface AfterConversion { + void finalizeConversion(T convertedEntity); + } ++ ++ // Paper start - entity zap event - allow conversion to be cancelled during finalization ++ @FunctionalInterface ++ public interface CancellingAfterConversion { ++ boolean finalizeConversionOrCancel(final T convertedEntity); ++ } ++ // Paper start - entity zap event - allow conversion to be cancelled during finalization + } +diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/Mob.java ++++ b/src/main/java/net/minecraft/world/entity/Mob.java +@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + + @Nullable + public T convertTo(EntityType entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.AfterConversion conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // Paper start - entity zap event - allow cancellation of conversion post creation ++ return this.convertTo(entitytypes, conversionparams, entityspawnreason, e -> { conversionparams_a.finalizeConversion(e); return true; }, transformReason, spawnReason); ++ } ++ @Nullable ++ public T convertTo(EntityType entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.CancellingAfterConversion conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // Paper end - entity zap event - allow cancellation of conversion post creation + // CraftBukkit end + if (this.isRemoved()) { + return null; +@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + return null; + } else { + conversionparams.type().convert(this, t0, conversionparams); +- conversionparams_a.finalizeConversion(t0); ++ if (!conversionparams_a.finalizeConversionOrCancel(t0)) return null; // Paper - entity zap event - return null if conversion was cancelled + Level world = this.level(); + + // CraftBukkit start +@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + + @Nullable + public T convertTo(EntityType entitytypes, ConversionParams conversionparams, ConversionParams.AfterConversion conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // Paper start - entity zap event - allow cancellation of conversion post creation ++ return this.convertTo(entitytypes, conversionparams, e -> { conversionparams_a.finalizeConversion(e); return true; }, transformReason, spawnReason); ++ } ++ public T convertTo(EntityType entitytypes, ConversionParams conversionparams, ConversionParams.CancellingAfterConversion conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { ++ // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason); + // CraftBukkit end + } +diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java ++++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java +@@ -0,0 +0,0 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + @Override + public void thunderHit(ServerLevel world, LightningBolt lightning) { + if (world.getDifficulty() != Difficulty.PEACEFUL) { +- Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); ++ // Paper - Add EntityZapEvent; move log down, event can cancel + Witch entitywitch = (Witch) this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), (entitywitch1) -> { ++ // Paper start - Add EntityZapEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, entitywitch1).isCancelled()) { ++ return false; ++ } ++ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down ++ // Paper end - Add EntityZapEvent + entitywitch1.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null); + entitywitch1.setPersistenceRequired(); + this.releaseAllPois(); ++ return true; // Paper start - Add EntityZapEvent + }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit + + if (entitywitch == null) { +diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +@@ -0,0 +0,0 @@ public class CraftEventFactory { + return !event.isCancelled(); + } + ++ // Paper start ++ public static com.destroystokyo.paper.event.entity.EntityZapEvent callEntityZapEvent(Entity entity, Entity lightning, Entity changedEntity) { ++ com.destroystokyo.paper.event.entity.EntityZapEvent event = new com.destroystokyo.paper.event.entity.EntityZapEvent(entity.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), changedEntity.getBukkitEntity()); ++ entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); ++ return event; ++ } ++ // Paper end ++ + public static boolean callEntityChangeBlockEvent(Entity entity, BlockPos position, net.minecraft.world.level.block.state.BlockState newBlock) { + return CraftEventFactory.callEntityChangeBlockEvent(entity, position, newBlock, false); + } diff --git a/patches/unapplied/server/Add-ProjectileCollideEvent.patch b/patches/server/Add-ProjectileCollideEvent.patch similarity index 100% rename from patches/unapplied/server/Add-ProjectileCollideEvent.patch rename to patches/server/Add-ProjectileCollideEvent.patch diff --git a/patches/unapplied/server/Add-setting-for-proxy-online-mode-status.patch b/patches/server/Add-setting-for-proxy-online-mode-status.patch similarity index 100% rename from patches/unapplied/server/Add-setting-for-proxy-online-mode-status.patch rename to patches/server/Add-setting-for-proxy-online-mode-status.patch diff --git a/patches/unapplied/server/Add-source-to-PlayerExpChangeEvent.patch b/patches/server/Add-source-to-PlayerExpChangeEvent.patch similarity index 100% rename from patches/unapplied/server/Add-source-to-PlayerExpChangeEvent.patch rename to patches/server/Add-source-to-PlayerExpChangeEvent.patch diff --git a/patches/unapplied/server/Allow-Reloading-of-Command-Aliases.patch b/patches/server/Allow-Reloading-of-Command-Aliases.patch similarity index 100% rename from patches/unapplied/server/Allow-Reloading-of-Command-Aliases.patch rename to patches/server/Allow-Reloading-of-Command-Aliases.patch diff --git a/patches/unapplied/server/Avoid-blocking-on-Network-Manager-creation.patch b/patches/server/Avoid-blocking-on-Network-Manager-creation.patch similarity index 100% rename from patches/unapplied/server/Avoid-blocking-on-Network-Manager-creation.patch rename to patches/server/Avoid-blocking-on-Network-Manager-creation.patch diff --git a/patches/unapplied/server/Bound-Treasure-Maps-to-World-Border.patch b/patches/server/Bound-Treasure-Maps-to-World-Border.patch similarity index 100% rename from patches/unapplied/server/Bound-Treasure-Maps-to-World-Border.patch rename to patches/server/Bound-Treasure-Maps-to-World-Border.patch diff --git a/patches/unapplied/server/Cache-user-authenticator-threads.patch b/patches/server/Cache-user-authenticator-threads.patch similarity index 100% rename from patches/unapplied/server/Cache-user-authenticator-threads.patch rename to patches/server/Cache-user-authenticator-threads.patch diff --git a/patches/unapplied/server/Configurable-Cartographer-Treasure-Maps.patch b/patches/server/Configurable-Cartographer-Treasure-Maps.patch similarity index 97% rename from patches/unapplied/server/Configurable-Cartographer-Treasure-Maps.patch rename to patches/server/Configurable-Cartographer-Treasure-Maps.patch index e06edd4c2f..172fadb7aa 100644 --- a/patches/unapplied/server/Configurable-Cartographer-Treasure-Maps.patch +++ b/patches/server/Configurable-Cartographer-Treasure-Maps.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java @@ -0,0 +0,0 @@ public class ExplorationMapFunction extends LootItemConditionalFunction { - Vec3 vec3 = context.getParamOrNull(LootContextParams.ORIGIN); + Vec3 vec3 = context.getOptionalParameter(LootContextParams.ORIGIN); if (vec3 != null) { ServerLevel serverLevel = context.getLevel(); + // Paper start - Configurable cartographer treasure maps diff --git a/patches/unapplied/server/Configurable-flying-kick-messages.patch b/patches/server/Configurable-flying-kick-messages.patch similarity index 100% rename from patches/unapplied/server/Configurable-flying-kick-messages.patch rename to patches/server/Configurable-flying-kick-messages.patch diff --git a/patches/unapplied/server/Configurable-packet-in-spam-threshold.patch b/patches/server/Configurable-packet-in-spam-threshold.patch similarity index 100% rename from patches/unapplied/server/Configurable-packet-in-spam-threshold.patch rename to patches/server/Configurable-packet-in-spam-threshold.patch diff --git a/patches/unapplied/server/Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch b/patches/server/Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch similarity index 100% rename from patches/unapplied/server/Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch rename to patches/server/Don-t-lookup-game-profiles-that-have-no-UUID-and-no-.patch diff --git a/patches/unapplied/server/Filter-bad-block-entity-nbt-data-from-falling-blocks.patch b/patches/server/Filter-bad-block-entity-nbt-data-from-falling-blocks.patch similarity index 100% rename from patches/unapplied/server/Filter-bad-block-entity-nbt-data-from-falling-blocks.patch rename to patches/server/Filter-bad-block-entity-nbt-data-from-falling-blocks.patch diff --git a/patches/unapplied/server/Firework-API-s.patch b/patches/server/Firework-API-s.patch similarity index 87% rename from patches/unapplied/server/Firework-API-s.patch rename to patches/server/Firework-API-s.patch index 49c6ae34e8..2e353b05e4 100644 --- a/patches/unapplied/server/Firework-API-s.patch +++ b/patches/server/Firework-API-s.patch @@ -65,21 +65,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java +++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java @@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem { - vec3.z + (double)direction.getStepZ() * 0.15, - itemStack + itemStack + ), + serverLevel, +- itemStack ++ itemStack, f -> f.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID() // Paper - firework api - assign spawning entity uuid ); -+ fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper - level.addFreshEntity(fireworkRocketEntity); itemStack.shrink(1); } @@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item implements ProjectileItem { + if (user.isFallFlying()) { ItemStack itemStack = user.getItemInHand(hand); - if (!world.isClientSide) { - FireworkRocketEntity fireworkRocketEntity = new FireworkRocketEntity(world, itemStack, user); -+ fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper - world.addFreshEntity(fireworkRocketEntity); + if (world instanceof ServerLevel serverLevel) { +- Projectile.spawnProjectile(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack); ++ Projectile.spawnProjectile(new FireworkRocketEntity(world, itemStack, user), serverLevel, itemStack, f -> f.spawningEntity = user.getUUID()); // Paper - firework api - assign spawning entity uuid itemStack.consume(1, user); user.awardStat(Stats.ITEM_USED.get(this)); + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java diff --git a/patches/unapplied/server/Fix-global-sound-handling.patch b/patches/server/Fix-global-sound-handling.patch similarity index 72% rename from patches/unapplied/server/Fix-global-sound-handling.patch rename to patches/server/Fix-global-sound-handling.patch index 5d4073b197..9dd613d1ce 100644 --- a/patches/unapplied/server/Fix-global-sound-handling.patch +++ b/patches/server/Fix-global-sound-handling.patch @@ -14,7 +14,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 @Override public void levelEvent(@Nullable Player player, int eventId, BlockPos pos, int data) { @@ -23,22 +23,40 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public int getLogicalHeight() { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + 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(); ++ } ++ ++ public double getGlobalSoundRangeSquared(java.util.function.Function rangeFunction) { ++ final double range = rangeFunction.apply(this.spigotConfig); ++ return range <= 0 ? 64.0 * 64.0 : range * range; // 64 is taken from default in ServerLevel#levelEvent ++ } ++ // Paper end - respect global sound events gamerule ++ + @Override + public CrashReportCategory fillReportDetails(CrashReport report) { + CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report); diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java @@ -0,0 +0,0 @@ public class EnderDragon extends Mob implements Enemy { // CraftBukkit start - Use relative location for far away sounds - // this.level().globalLevelEvent(1028, this.blockPosition(), 0); - int viewDistance = ((ServerLevel) this.level()).getCraftServer().getViewDistance() * 16; -- for (net.minecraft.server.level.ServerPlayer player : this.level().getServer().getPlayerList().players) { -+ for (net.minecraft.server.level.ServerPlayer player : this.level().getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule + // worldserver.globalLevelEvent(1028, this.blockPosition(), 0); + int viewDistance = worldserver.getCraftServer().getViewDistance() * 16; +- for (net.minecraft.server.level.ServerPlayer player : worldserver.getServer().getPlayerList().players) { ++ for (net.minecraft.server.level.ServerPlayer player : worldserver.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule double deltaX = this.getX() - player.getX(); double deltaZ = this.getZ() - player.getZ(); double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -- if ( this.level().spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > this.level().spigotConfig.dragonDeathSoundRadius * this.level().spigotConfig.dragonDeathSoundRadius ) continue; // Spigot -+ final double soundRadiusSquared = this.level().getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule -+ if ( !this.level().getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule +- if ( worldserver.spigotConfig.dragonDeathSoundRadius > 0 && distanceSquared > worldserver.spigotConfig.dragonDeathSoundRadius * worldserver.spigotConfig.dragonDeathSoundRadius ) continue; // Spigot ++ final double soundRadiusSquared = worldserver.getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule ++ if ( !worldserver.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule if (distanceSquared > viewDistance * viewDistance) { double deltaLength = Math.sqrt(distanceSquared); double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; @@ -46,18 +64,18 @@ diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob +@@ -0,0 +0,0 @@ public class WitherBoss extends Monster implements RangedAttackMob { // CraftBukkit start - Use relative location for far away sounds - // this.level().globalLevelEvent(1023, new BlockPosition(this), 0); - int viewDistance = ((ServerLevel) this.level()).getCraftServer().getViewDistance() * 16; + // worldserver.globalLevelEvent(1023, new BlockPosition(this), 0); + int viewDistance = world.getCraftServer().getViewDistance() * 16; - for (ServerPlayer player : (List) MinecraftServer.getServer().getPlayerList().players) { -+ for (ServerPlayer player : this.level().getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule ++ for (ServerPlayer player : world.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule double deltaX = this.getX() - player.getX(); double deltaZ = this.getZ() - player.getZ(); double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; -- if ( this.level().spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > this.level().spigotConfig.witherSpawnSoundRadius * this.level().spigotConfig.witherSpawnSoundRadius ) continue; // Spigot -+ final double soundRadiusSquared = this.level().getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule -+ if ( !this.level().getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule +- if ( world.spigotConfig.witherSpawnSoundRadius > 0 && distanceSquared > world.spigotConfig.witherSpawnSoundRadius * world.spigotConfig.witherSpawnSoundRadius ) continue; // Spigot ++ final double soundRadiusSquared = world.getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule ++ if ( !world.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared ) continue; // Spigot // Paper - respect global sound events gamerule if (distanceSquared > viewDistance * viewDistance) { double deltaLength = Math.sqrt(distanceSquared); double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; @@ -66,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/EnderEyeItem.java +++ b/src/main/java/net/minecraft/world/item/EnderEyeItem.java @@ -0,0 +0,0 @@ public class EnderEyeItem extends Item { - // world.b(1038, blockposition1.c(1, 0, 1), 0); + // world.globalLevelEvent(1038, blockposition1.offset(1, 0, 1), 0); int viewDistance = world.getCraftServer().getViewDistance() * 16; BlockPos soundPos = blockposition1.offset(1, 0, 1); - for (ServerPlayer player : world.getServer().getPlayerList().players) { @@ -80,22 +98,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (distanceSquared > viewDistance * viewDistance) { double deltaLength = Math.sqrt(distanceSquared); double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - return this.id; - } - } -+ // 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(); -+ } -+ -+ public double getGlobalSoundRangeSquared(java.util.function.Function rangeFunction) { -+ final double range = rangeFunction.apply(this.spigotConfig); -+ return range <= 0 ? 64.0 * 64.0 : range * range; // 64 is taken from default in ServerLevel#levelEvent -+ } -+ // Paper end - respect global sound events gamerule - } diff --git a/patches/unapplied/server/Optimise-BlockState-s-hashCode-equals.patch b/patches/server/Optimise-BlockState-s-hashCode-equals.patch similarity index 71% rename from patches/unapplied/server/Optimise-BlockState-s-hashCode-equals.patch rename to patches/server/Optimise-BlockState-s-hashCode-equals.patch index 5cb8e70b12..9e925ce409 100644 --- a/patches/unapplied/server/Optimise-BlockState-s-hashCode-equals.patch +++ b/patches/server/Optimise-BlockState-s-hashCode-equals.patch @@ -8,26 +8,12 @@ object identity checks safely. Use a simpler optimized hashcode -diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java -+++ b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java -@@ -0,0 +0,0 @@ public class BooleanProperty extends Property { - return value.toString(); - } - -- @Override -- public boolean equals(Object object) { -+ public boolean equals_unused(Object object) { // Paper - Perf: Optimize hashCode/equals - if (this == object) { - return true; - } else { diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java +++ b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java -@@ -0,0 +0,0 @@ public class EnumProperty & StringRepresentable> extends Prope - return value.getSerializedName(); +@@ -0,0 +0,0 @@ public final class EnumProperty & StringRepresentable> extends + return this.ordinalToIndex[enum_.ordinal()]; } - @Override @@ -40,7 +26,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/Inte index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java +++ b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java -@@ -0,0 +0,0 @@ public class IntegerProperty extends Property { +@@ -0,0 +0,0 @@ public final class IntegerProperty extends Property { return this.values; } diff --git a/patches/unapplied/server/Optimize-Level.hasChunkAt-BlockPosition-Z.patch b/patches/server/Optimize-Level.hasChunkAt-BlockPosition-Z.patch similarity index 100% rename from patches/unapplied/server/Optimize-Level.hasChunkAt-BlockPosition-Z.patch rename to patches/server/Optimize-Level.hasChunkAt-BlockPosition-Z.patch diff --git a/patches/unapplied/server/Prevent-Pathfinding-out-of-World-Border.patch b/patches/server/Prevent-Pathfinding-out-of-World-Border.patch similarity index 100% rename from patches/unapplied/server/Prevent-Pathfinding-out-of-World-Border.patch rename to patches/server/Prevent-Pathfinding-out-of-World-Border.patch diff --git a/patches/unapplied/server/Properly-fix-item-duplication-bug.patch b/patches/server/Properly-fix-item-duplication-bug.patch similarity index 100% rename from patches/unapplied/server/Properly-fix-item-duplication-bug.patch rename to patches/server/Properly-fix-item-duplication-bug.patch diff --git a/patches/unapplied/server/String-based-Action-Bar-API.patch b/patches/server/String-based-Action-Bar-API.patch similarity index 100% rename from patches/unapplied/server/String-based-Action-Bar-API.patch rename to patches/server/String-based-Action-Bar-API.patch diff --git a/patches/unapplied/server/Add-EntityZapEvent.patch b/patches/unapplied/server/Add-EntityZapEvent.patch deleted file mode 100644 index a0cbb2a00a..0000000000 --- a/patches/unapplied/server/Add-EntityZapEvent.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaBlend -Date: Sun, 16 Oct 2016 23:19:30 -0700 -Subject: [PATCH] Add EntityZapEvent - - -diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/npc/Villager.java -+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -0,0 +0,0 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - @Override - public void thunderHit(ServerLevel world, LightningBolt lightning) { - if (world.getDifficulty() != Difficulty.PEACEFUL) { -- Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); -+ // Paper - Add EntityZapEvent; move log down, event can cancel - Witch entitywitch = (Witch) EntityType.WITCH.create(world); - - if (entitywitch != null) { -+ // Paper start - Add EntityZapEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, entitywitch).isCancelled()) { -+ return; -+ } -+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down -+ // Paper end - Add EntityZapEvent -+ - entitywitch.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); - entitywitch.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null); - entitywitch.setNoAi(this.isNoAi()); -diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -0,0 +0,0 @@ public class CraftEventFactory { - return !event.isCancelled(); - } - -+ // Paper start -+ public static com.destroystokyo.paper.event.entity.EntityZapEvent callEntityZapEvent(Entity entity, Entity lightning, Entity changedEntity) { -+ com.destroystokyo.paper.event.entity.EntityZapEvent event = new com.destroystokyo.paper.event.entity.EntityZapEvent(entity.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), changedEntity.getBukkitEntity()); -+ entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); -+ return event; -+ } -+ // Paper end -+ - public static boolean callEntityChangeBlockEvent(Entity entity, BlockPos position, net.minecraft.world.level.block.state.BlockState newBlock) { - return CraftEventFactory.callEntityChangeBlockEvent(entity, position, newBlock, false); - }