From 91978953f390db54a60a79c8fa6fc7bca848b77b Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Fri, 25 Oct 2024 20:09:45 +0200 Subject: [PATCH] fix some issues --- patches/server/Add-EntityFertilizeEggEvent.patch | 2 +- patches/server/Add-TameableDeathMessageEvent.patch | 2 +- patches/server/Allow-changing-the-EnderDragon-podium.patch | 2 +- patches/server/Expand-EntityUnleashEvent.patch | 3 ++- .../server/Fix-piston-physics-inconsistency-MC-188840.patch | 3 ++- .../Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch | 2 +- patches/server/Optimize-Bit-Operations-by-inlining.patch | 2 +- patches/server/Restore-vanilla-entity-drops-behavior.patch | 2 +- patches/server/Timings-v2.patch | 2 -- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/patches/server/Add-EntityFertilizeEggEvent.patch b/patches/server/Add-EntityFertilizeEggEvent.patch index 12d26513db..fa884c6e28 100644 --- a/patches/server/Add-EntityFertilizeEggEvent.patch +++ b/patches/server/Add-EntityFertilizeEggEvent.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (getServerLevel((Level) this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper; -+ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), randomsource.nextInt(7) + 1, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event ++ if (event.getExperience() > 0) this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), event.getExperience(), org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, entityplayer)); // Paper - Add EntityFertilizeEggEvent event } } diff --git a/patches/server/Add-TameableDeathMessageEvent.patch b/patches/server/Add-TameableDeathMessageEvent.patch index f658c3d6fd..1a33637577 100644 --- a/patches/server/Add-TameableDeathMessageEvent.patch +++ b/patches/server/Add-TameableDeathMessageEvent.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Add TameableDeathMessageEvent + io.papermc.paper.event.entity.TameableDeathMessageEvent event = new io.papermc.paper.event.entity.TameableDeathMessageEvent((org.bukkit.entity.Tameable) getBukkitEntity(), io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getCombatTracker().getDeathMessage())); + if (event.callEvent()) { -+ entityplayer.sendSystemMessage(this.getCombatTracker().getDeathMessage()); ++ entityplayer.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.deathMessage())); + } + // Paper end - Add TameableDeathMessageEvent } diff --git a/patches/server/Allow-changing-the-EnderDragon-podium.patch b/patches/server/Allow-changing-the-EnderDragon-podium.patch index a438ad2c73..09510fdcfc 100644 --- a/patches/server/Allow-changing-the-EnderDragon-podium.patch +++ b/patches/server/Allow-changing-the-EnderDragon-podium.patch @@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private void findNewTarget(ServerLevel world) { if (this.currentPath != null && this.currentPath.isDone()) { - BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin())); -+ BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, new BlockPos(this.dragon.getPodium())); // Paper - Allow changing the EnderDragon podium ++ BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium int i = this.dragon.getDragonFight() == null ? 0 : this.dragon.getDragonFight().getCrystalsAlive(); if (this.dragon.getRandom().nextInt(i + 3) == 0) { this.dragon.getPhaseManager().setPhase(EnderDragonPhase.LANDING_APPROACH); diff --git a/patches/server/Expand-EntityUnleashEvent.patch b/patches/server/Expand-EntityUnleashEvent.patch index 44a0e6cd51..0a0bcb2c5a 100644 --- a/patches/server/Expand-EntityUnleashEvent.patch +++ b/patches/server/Expand-EntityUnleashEvent.patch @@ -51,10 +51,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (leashable_a != null && leashable_a.leashHolder != null) { if (!entity.isAlive() || !leashable_a.leashHolder.isAlive()) { - world.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(entity.getBukkitEntity(), (!entity.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit +- Leashable.dropLeash(entity, true, world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin + // Paper start - Expand EntityUnleashEvent + final EntityUnleashEvent event = new EntityUnleashEvent(entity.getBukkitEntity(), (!entity.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE, world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved); + event.callEvent(); - Leashable.dropLeash(entity, true, world.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !entity.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin ++ Leashable.dropLeash(entity, true, event.isDropLeash()); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin + // Paper end - Expand EntityUnleashEvent } diff --git a/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch index a2b717d0d8..dd52970dd3 100644 --- a/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch +++ b/patches/server/Fix-piston-physics-inconsistency-MC-188840.patch @@ -50,12 +50,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 map.remove(blockposition3); iblockdata2 = (BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(PistonBaseBlock.FACING, dir); world.setBlock(blockposition3, iblockdata2, 68); +- world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(j), dir, extend, false)); + // Paper start - fix a variety of piston desync dupes + if (!allowDesync) { + iblockdata1 = world.getBlockState(oldPos); + map.replace(oldPos, iblockdata1); + } - world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, (BlockState) list1.get(j), dir, extend, false)); ++ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockposition3, iblockdata2, allowDesync ? (BlockState) list1.get(j) : iblockdata1, dir, extend, false)); + if (!allowDesync) { + world.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block + } diff --git a/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch index dae75bbe37..3e61c87315 100644 --- a/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch +++ b/patches/server/Only-set-despawnTimer-for-Wandering-Traders-spawned-.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit -+ WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, trader -> trader.setDespawnDelay(48000), blockposition2, EntitySpawnReason.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBu // Paper - set despawnTimer before spawn events calledkkit ++ WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, trader -> trader.setDespawnDelay(48000), blockposition2, EntitySpawnReason.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit // Paper - set despawnTimer before spawn events called if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { diff --git a/patches/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch index 895ee41942..7d7f2d776f 100644 --- a/patches/server/Optimize-Bit-Operations-by-inlining.patch +++ b/patches/server/Optimize-Bit-Operations-by-inlining.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - private static final long PACKED_Y_MASK = (1L << PACKED_Y_LENGTH) - 1L; - private static final long PACKED_Z_MASK = (1L << PACKED_HORIZONTAL_LENGTH) - 1L; + // Paper start - Optimize Bit Operations by inlining -+ private static final int PACKED_HORIZONTAL_LENGTH = 26; ++ public static final int PACKED_HORIZONTAL_LENGTH = 26; + public static final int PACKED_Y_LENGTH = 12; + private static final long PACKED_X_MASK = 67108863; + private static final long PACKED_Y_MASK = 4095; diff --git a/patches/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch index 3f8277df30..b5a27a9a29 100644 --- a/patches/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -179,7 +179,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); CraftWorld world = (CraftWorld) entity.getWorld(); - EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, drops, victim.getExpReward(world.getHandle(), damageSource.getEntity())); -+ EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(world.getHandle(), damageSource.getEntity())); // Paper - Restore vanilla drops behavior, victim.getExpReward(world.getHandle(), damageSource.getEntity())); ++ EntityDeathEvent event = new EntityDeathEvent(entity, bukkitDamageSource, new io.papermc.paper.util.TransformingRandomAccessList<>(drops, Entity.DefaultDrop::stack, FROM_FUNCTION), victim.getExpReward(world.getHandle(), damageSource.getEntity())); // Paper - Restore vanilla drops behavior populateFields(victim, event); // Paper - make cancellable Bukkit.getServer().getPluginManager().callEvent(event); diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch index a569fd9d3d..990dc8b33a 100644 --- a/patches/server/Timings-v2.patch +++ b/patches/server/Timings-v2.patch @@ -1359,7 +1359,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.inactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "inactiveTick"); + this.passengerTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerTick"); + this.passengerInactiveTickTimer = co.aikar.timings.MinecraftTimings.getEntityTimings(id, "passengerInactiveTick"); -+ this.id = id; + // Paper end this.builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this); this.factory = factory; @@ -1373,7 +1372,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public final co.aikar.timings.Timing inactiveTickTimer; + public final co.aikar.timings.Timing passengerTickTimer; + public final co.aikar.timings.Timing passengerInactiveTickTimer; -+ private final String id; + // Paper end public boolean trackDeltas() { return this != EntityType.PLAYER && this != EntityType.LLAMA_SPIT && this != EntityType.WITHER && this != EntityType.BAT && this != EntityType.ITEM_FRAME && this != EntityType.GLOW_ITEM_FRAME && this != EntityType.LEASH_KNOT && this != EntityType.PAINTING && this != EntityType.END_CRYSTAL && this != EntityType.EVOKER_FANGS;