From 42a2ccff550ee239e4c7a4b19c9e297563285cc7 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 20 Dec 2024 12:00:24 +0100 Subject: [PATCH] Remove dead diff, some name/diff cleanup --- .../net/minecraft/server/Bootstrap.java.patch | 8 +-- .../server/ServerFunctionManager.java.patch | 11 ---- .../server/ServerTickRateManager.java.patch | 50 ------------------- .../util/worldupdate/WorldUpgrader.java.patch | 10 ++-- .../damagesource/DamageSources.java.patch | 4 +- .../world/effect/MobEffectUtil.java.patch | 25 ++++++---- .../entity/ai/behavior/AcquirePoi.java.patch | 2 +- .../PrepareRamNearestTarget.java.patch | 8 +-- .../horse/AbstractChestedHorse.java.patch | 13 ++--- 9 files changed, 34 insertions(+), 97 deletions(-) delete mode 100644 paper-server/patches/sources/net/minecraft/server/ServerFunctionManager.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/server/ServerTickRateManager.java.patch diff --git a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch index 20a795954e..c2cbc6a238 100644 --- a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch @@ -8,7 +8,7 @@ if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); } else { -@@ -54,11 +_,78 @@ +@@ -54,11 +_,80 @@ EntitySelectorOptions.bootStrap(); DispenseItemBehavior.bootStrap(); CauldronInteraction.bootStrap(); @@ -22,7 +22,9 @@ wrapStreams(); bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); } -+ // CraftBukkit start - easier than fixing the decompile ++ // CraftBukkit start ++ // TODO Check what of this is needed, maybe report it to Mojira. if deemed relevant, move to the respective classes ++ // Used in CraftLegacy + net.minecraft.util.datafix.fixes.BlockStateData.register(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); + net.minecraft.util.datafix.fixes.BlockStateData.register(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); + net.minecraft.util.datafix.fixes.BlockStateData.register(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); @@ -41,7 +43,7 @@ + net.minecraft.util.datafix.fixes.BlockStateData.register(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); + net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(323, "minecraft:oak_sign"); + -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); ++ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, "{Name:'minecraft:portal',Properties:{axis:'x'}}", "{Name:'minecraft:portal',Properties:{axis:'x'}}"); + + net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); + net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); diff --git a/paper-server/patches/sources/net/minecraft/server/ServerFunctionManager.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerFunctionManager.java.patch deleted file mode 100644 index f78aa0e5e9..0000000000 --- a/paper-server/patches/sources/net/minecraft/server/ServerFunctionManager.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/ServerFunctionManager.java -+++ b/net/minecraft/server/ServerFunctionManager.java -@@ -34,7 +_,7 @@ - } - - public CommandDispatcher getDispatcher() { -- return this.server.getCommands().getDispatcher(); -+ return this.server.getCommands().getDispatcher(); // CraftBukkit // Paper - Don't override command dispatcher - } - - public void tick() { diff --git a/paper-server/patches/sources/net/minecraft/server/ServerTickRateManager.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerTickRateManager.java.patch deleted file mode 100644 index 2c1e737818..0000000000 --- a/paper-server/patches/sources/net/minecraft/server/ServerTickRateManager.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- a/net/minecraft/server/ServerTickRateManager.java -+++ b/net/minecraft/server/ServerTickRateManager.java -@@ -58,8 +_,14 @@ - } - - public boolean stopSprinting() { -+ // CraftBukkit start - add sendLog parameter -+ return this.stopSprinting(true); -+ } -+ -+ public boolean stopSprinting(boolean sendLog) { -+ // CraftBukkit end - add sendLog parameter - if (this.remainingSprintTicks > 0L) { -- this.finishTickSprint(); -+ this.finishTickSprint(sendLog); // CraftBukkit - add sendLog parameter - return true; - } else { - return false; -@@ -76,14 +_,20 @@ - return flag; - } - -- private void finishTickSprint() { -+ private void finishTickSprint(boolean sendLog) { // CraftBukkit - add sendLog parameter - long l = this.scheduledCurrentSprintTicks - this.remainingSprintTicks; - double d = Math.max(1.0, (double)this.sprintTimeSpend) / TimeUtil.NANOSECONDS_PER_MILLISECOND; - int i = (int)(TimeUtil.MILLISECONDS_PER_SECOND * l / d); - String string = String.format("%.2f", l == 0L ? this.millisecondsPerTick() : d / l); - this.scheduledCurrentSprintTicks = 0L; - this.sprintTimeSpend = 0L; -- this.server.createCommandSourceStack().sendSuccess(() -> Component.translatable("commands.tick.sprint.report", i, string), true); -+ // CraftBukkit start - add sendLog parameter -+ if (sendLog) { -+ this.server.createCommandSourceStack().sendSuccess(() -> { -+ return Component.translatable("commands.tick.sprint.report", i, string); -+ }, true); -+ } -+ // CraftBukkit end - this.remainingSprintTicks = 0L; - this.setFrozen(this.previousIsFrozen); - this.server.onTickRateChanged(); -@@ -97,7 +_,7 @@ - this.remainingSprintTicks--; - return true; - } else { -- this.finishTickSprint(); -+ this.finishTickSprint(true); // CraftBukkit - add sendLog parameter - return false; - } - } diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index 5f0dc70ca1..ac9d8ccaca 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -9,14 +9,12 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -357,9 +_,7 @@ - if (compoundTag != null) { +@@ -358,7 +_,7 @@ int version = ChunkStorage.getVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); -- CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( + CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( - dimension, () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer() -- ); -+ CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag(Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null); // CraftBukkit ++ Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null // CraftBukkit + ); ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getInt("xPos"), compoundTag1.getInt("zPos")); if (!chunkPos1.equals(chunkPos)) { - WorldUpgrader.LOGGER.warn("Chunk {} has invalid position {}", chunkPos, chunkPos1); diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch index 9e1a0a8d8b..f13f6629d4 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSources.java.patch @@ -42,8 +42,8 @@ + return this.badRespawnPointExplosion(position, null); + } + -+ public DamageSource badRespawnPointExplosion(Vec3 vec3d, org.bukkit.block.BlockState blockState) { -+ return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState); ++ public DamageSource badRespawnPointExplosion(Vec3 position, org.bukkit.block.BlockState blockState) { ++ return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), position).directBlockState(blockState); + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch index eeeb7fd665..16be8c5818 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectUtil.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffectUtil.java +++ b/net/minecraft/world/effect/MobEffectUtil.java -@@ -47,18 +_,31 @@ +@@ -47,18 +_,38 @@ public static List addEffectToPlayersAround( ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration ) { @@ -17,28 +17,31 @@ + // Paper end - Add ElderGuardianAppearanceEvent + // CraftBukkit end Holder effect1 = effect.getEffect(); -- List players = level.getPlayers( + List players = level.getPlayers( - serverPlayer -> serverPlayer.gameMode.isSurvival() -- && (source == null || !source.isAlliedTo(serverPlayer)) -- && pos.closerThan(serverPlayer.position(), radius) -- && ( ++ // Paper start - Add ElderGuardianAppearanceEvent ++ serverPlayer -> { ++ final boolean condition = serverPlayer.gameMode.isSurvival() + && (source == null || !source.isAlliedTo(serverPlayer)) + && pos.closerThan(serverPlayer.position(), radius) + && ( - !serverPlayer.hasEffect(effect1) - || serverPlayer.getEffect(effect1).getAmplifier() < effect.getAmplifier() - || serverPlayer.getEffect(effect1).endsWithin(duration - 1) - ) - ); - players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source)); -+ List players = level.getPlayers((entityplayer) -> { -+ // Paper start - Add ElderGuardianAppearanceEvent -+ boolean condition = entityplayer.gameMode.isSurvival() && (source == null || !source.isAlliedTo((Entity) entityplayer)) && pos.closerThan(entityplayer.position(), radius) && (!entityplayer.hasEffect(effect1) || entityplayer.getEffect(effect1).getAmplifier() < effect.getAmplifier() || entityplayer.getEffect(effect1).endsWithin(duration - 1)); ++ !serverPlayer.hasEffect(effect1) ++ || serverPlayer.getEffect(effect1).getAmplifier() < effect.getAmplifier() ++ || serverPlayer.getEffect(effect1).endsWithin(duration - 1) ++ ); + if (condition) { -+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true ++ return playerPredicate == null || playerPredicate.test(serverPlayer); // Only test the player AFTER it is true + } else { + return false; + } -+ // Paper end - Add ElderGuardianAppearanceEvent + }); -+ ++ // Paper end - Add ElderGuardianAppearanceEvent + players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source, cause)); // CraftBukkit return players; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch index 512a8a9953..777259cb86 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AcquirePoi.java.patch @@ -4,7 +4,7 @@ return false; } else { mutableLong.setValue(time + 20L + level.getRandom().nextInt(20)); -+ if (mob.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck ++ if (mob.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck // TODO Modifies Vanilla behavior, add config option PoiManager poiManager = level.getPoiManager(); map.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); Predicate predicate1 = pos -> { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch index 6df8611d59..41b07e6724 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java.patch @@ -5,13 +5,13 @@ nearestVisibleLivingEntities -> nearestVisibleLivingEntities.findClosest(livingEntity -> this.ramTargeting.test(level, entity, livingEntity)) ) + // CraftBukkit start -+ .map((entityliving) -> { -+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entity, entityliving, (entityliving instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); ++ .map((livingEntity) -> { ++ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(entity, livingEntity, (livingEntity instanceof net.minecraft.server.level.ServerPlayer) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); + if (event.isCancelled() || event.getTarget() == null) { + return null; + } -+ entityliving = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); -+ return entityliving; ++ livingEntity = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); ++ return livingEntity; + }) + // CraftBukkit end .ifPresent(entity1 -> this.chooseRamPosition(entity, entity1)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch index bc6f934031..9fbe146a0c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch @@ -1,20 +1,15 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -@@ -69,9 +_,17 @@ +@@ -69,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); -+ //this.setChest(false); // Paper - moved to post death logic ++ // Paper start - moved to post death logic + } + } -+ -+ // Paper start + protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) { -+ if (this.hasChest() && (event == null || !event.isCancelled())) { ++ if (this.hasChest() && !event.isCancelled()) { ++ // Paper end - moved to post death logic this.setChest(false); } } -+ // Paper end - - @Override - public void addAdditionalSaveData(CompoundTag compound) {