From 0047482c6f3bb600cf0c2dd03bdde4047de2b7c4 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Wed, 23 Oct 2024 17:58:11 +0200 Subject: [PATCH] Some more work --- .../Fix-harming-potion-dupe.patch | 0 ...et-Material-from-Boats-and-Minecarts.patch | 2 +- .../server/Add-BlockFailedDispenseEvent.patch | 2 +- .../server/Add-EntityLoadCrossbowEvent.patch | 4 ++-- .../Add-PlayerFlowerPotManipulateEvent.patch | 2 +- .../Add-PlayerLecternPageChangeEvent.patch | 0 .../Add-PlayerLoomPatternSelectEvent.patch | 0 .../Add-ServerResourcesReloadedEvent.patch | 2 +- .../server/Add-TargetHitEvent.patch | 0 .../server/Add-WorldGameRuleChangeEvent.patch | 10 ++++++---- ...ld-settings-for-mobs-picking-up-loot.patch | 10 +++++----- .../Additional-Block-Material-API.patch | 0 ...mob-spawner-spawn-egg-transformation.patch | 0 ...onfigurable-door-breaking-difficulty.patch | 0 ...pty-commands-shall-not-be-dispatched.patch | 0 ...Fix-Not-a-string-Map-Conversion-spam.patch | 19 +++++-------------- ...act-event-not-being-called-sometimes.patch | 12 ++++++------ .../Fix-nerfed-slime-when-splitting.patch | 10 +++++----- .../MC-4-Fix-item-position-desync.patch | 0 .../server/Zombie-API-breaking-doors.patch | 0 20 files changed, 33 insertions(+), 40 deletions(-) rename patches/{unapplied/server => later}/Fix-harming-potion-dupe.patch (100%) rename patches/{unapplied => }/server/API-to-get-Material-from-Boats-and-Minecarts.patch (96%) rename patches/{unapplied => }/server/Add-BlockFailedDispenseEvent.patch (97%) rename patches/{unapplied => }/server/Add-EntityLoadCrossbowEvent.patch (96%) rename patches/{unapplied => }/server/Add-PlayerFlowerPotManipulateEvent.patch (98%) rename patches/{unapplied => }/server/Add-PlayerLecternPageChangeEvent.patch (100%) rename patches/{unapplied => }/server/Add-PlayerLoomPatternSelectEvent.patch (100%) rename patches/{unapplied => }/server/Add-ServerResourcesReloadedEvent.patch (96%) rename patches/{unapplied => }/server/Add-TargetHitEvent.patch (100%) rename patches/{unapplied => }/server/Add-WorldGameRuleChangeEvent.patch (96%) rename patches/{unapplied => }/server/Add-world-settings-for-mobs-picking-up-loot.patch (80%) rename patches/{unapplied => }/server/Additional-Block-Material-API.patch (100%) rename patches/{unapplied => }/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch (100%) rename patches/{unapplied => }/server/Configurable-door-breaking-difficulty.patch (100%) rename patches/{unapplied => }/server/Empty-commands-shall-not-be-dispatched.patch (100%) rename patches/{unapplied => }/server/Fix-Not-a-string-Map-Conversion-spam.patch (71%) rename patches/{unapplied => }/server/Fix-interact-event-not-being-called-sometimes.patch (85%) rename patches/{unapplied => }/server/Fix-nerfed-slime-when-splitting.patch (58%) rename patches/{unapplied => }/server/MC-4-Fix-item-position-desync.patch (100%) rename patches/{unapplied => }/server/Zombie-API-breaking-doors.patch (100%) diff --git a/patches/unapplied/server/Fix-harming-potion-dupe.patch b/patches/later/Fix-harming-potion-dupe.patch similarity index 100% rename from patches/unapplied/server/Fix-harming-potion-dupe.patch rename to patches/later/Fix-harming-potion-dupe.patch diff --git a/patches/unapplied/server/API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch similarity index 96% rename from patches/unapplied/server/API-to-get-Material-from-Boats-and-Minecarts.patch rename to patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch index b5b0bcc8e3..bd516cb2f0 100644 --- a/patches/unapplied/server/API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java -@@ -0,0 +0,0 @@ public class CraftBoat extends CraftVehicle implements Boat { +@@ -0,0 +0,0 @@ public abstract class CraftBoat extends CraftVehicle implements Boat { this.getHandle().landBoats = workOnLand; } diff --git a/patches/unapplied/server/Add-BlockFailedDispenseEvent.patch b/patches/server/Add-BlockFailedDispenseEvent.patch similarity index 97% rename from patches/unapplied/server/Add-BlockFailedDispenseEvent.patch rename to patches/server/Add-BlockFailedDispenseEvent.patch index 43156fa42d..d425134361 100644 --- a/patches/unapplied/server/Add-BlockFailedDispenseEvent.patch +++ b/patches/server/Add-BlockFailedDispenseEvent.patch @@ -35,7 +35,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b 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 { +@@ -0,0 +0,0 @@ populateFields(victim, event); // Paper - make cancellable return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion()); } // Paper end - WitchReadyPotionEvent diff --git a/patches/unapplied/server/Add-EntityLoadCrossbowEvent.patch b/patches/server/Add-EntityLoadCrossbowEvent.patch similarity index 96% rename from patches/unapplied/server/Add-EntityLoadCrossbowEvent.patch rename to patches/server/Add-EntityLoadCrossbowEvent.patch index 2d3a60ade9..a87f20cd7d 100644 --- a/patches/unapplied/server/Add-EntityLoadCrossbowEvent.patch +++ b/patches/server/Add-EntityLoadCrossbowEvent.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/CrossbowItem.java +++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java @@ -0,0 +0,0 @@ public class CrossbowItem extends ProjectileWeaponItem { - public void releaseUsing(ItemStack stack, Level world, LivingEntity user, int remainingUseTicks) { + public boolean releaseUsing(ItemStack stack, Level world, LivingEntity user, int remainingUseTicks) { int i = this.getUseDuration(stack, user) - remainingUseTicks; float f = getPowerForTime(i, stack, user); - if (f >= 1.0F && !isCharged(stack) && tryLoadProjectiles(user, stack)) { @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(user.getBukkitLivingEntity(), stack.asBukkitMirror(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(user.getUsedItemHand())); + if (!event.callEvent() || !tryLoadProjectiles(user, stack, event.shouldConsumeItem()) || !event.shouldConsumeItem()) { + if (user instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote(); -+ return; ++ return false; + } + // Paper end - Add EntityLoadCrossbowEvent CrossbowItem.ChargingSounds chargingSounds = this.getChargingSounds(stack); diff --git a/patches/unapplied/server/Add-PlayerFlowerPotManipulateEvent.patch b/patches/server/Add-PlayerFlowerPotManipulateEvent.patch similarity index 98% rename from patches/unapplied/server/Add-PlayerFlowerPotManipulateEvent.patch rename to patches/server/Add-PlayerFlowerPotManipulateEvent.patch index fca138a6b3..52073a5365 100644 --- a/patches/unapplied/server/Add-PlayerFlowerPotManipulateEvent.patch +++ b/patches/server/Add-PlayerFlowerPotManipulateEvent.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/block/FlowerPotBlock.java @@ -0,0 +0,0 @@ public class FlowerPotBlock extends Block { } else if (!this.isEmpty()) { - return ItemInteractionResult.CONSUME; + return InteractionResult.CONSUME; } else { + // Paper start - Add PlayerFlowerPotManipulateEvent + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, pos); diff --git a/patches/unapplied/server/Add-PlayerLecternPageChangeEvent.patch b/patches/server/Add-PlayerLecternPageChangeEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerLecternPageChangeEvent.patch rename to patches/server/Add-PlayerLecternPageChangeEvent.patch diff --git a/patches/unapplied/server/Add-PlayerLoomPatternSelectEvent.patch b/patches/server/Add-PlayerLoomPatternSelectEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerLoomPatternSelectEvent.patch rename to patches/server/Add-PlayerLoomPatternSelectEvent.patch diff --git a/patches/unapplied/server/Add-ServerResourcesReloadedEvent.patch b/patches/server/Add-ServerResourcesReloadedEvent.patch similarity index 96% rename from patches/unapplied/server/Add-ServerResourcesReloadedEvent.patch rename to patches/server/Add-ServerResourcesReloadedEvent.patch index d6362f14d4..58cf39b6e8 100644 --- a/patches/unapplied/server/Add-ServerResourcesReloadedEvent.patch +++ b/patches/server/Add-ServerResourcesReloadedEvent.patch @@ -23,8 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Stream stream = dataPacks.stream(); // CraftBukkit - decompile error PackRepository resourcepackrepository = this.packRepository; @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop gameRule = GameRule.getByName(rule); + io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, gameRule, value); + if (!event.callEvent()) return false; + // Paper end - Add WorldGameRuleChangeEvent - GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule)); + + GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule)); - handle.deserialize(value); + handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent handle.onChanged(this.getHandle()); return true; } @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { + Preconditions.checkArgument(newValue != null, "GameRule value cannot be null"); if (!this.isGameRule(rule.getName())) return false; - + // Paper start - Add WorldGameRuleChangeEvent + io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(this, null, rule, String.valueOf(newValue)); + if (!event.callEvent()) return false; + // Paper end - Add WorldGameRuleChangeEvent - GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName())); + + GameRules.Value handle = this.getHandle().getGameRules().getRule(this.getGameRulesNMS().get(rule.getName())); - handle.deserialize(newValue.toString()); + handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent handle.onChanged(this.getHandle()); diff --git a/patches/unapplied/server/Add-world-settings-for-mobs-picking-up-loot.patch b/patches/server/Add-world-settings-for-mobs-picking-up-loot.patch similarity index 80% rename from patches/unapplied/server/Add-world-settings-for-mobs-picking-up-loot.patch rename to patches/server/Add-world-settings-for-mobs-picking-up-loot.patch index 6925d0ada4..ceab3d4b20 100644 --- a/patches/unapplied/server/Add-world-settings-for-mobs-picking-up-loot.patch +++ b/patches/server/Add-world-settings-for-mobs-picking-up-loot.patch @@ -22,11 +22,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -0,0 +0,0 @@ public class Zombie extends Monster { - Object object = super.finalizeSpawn(world, difficulty, spawnReason, entityData); float f = difficulty.getSpecialMultiplier(); -- this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * f); -+ this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.zombies || randomsource.nextFloat() < 0.55F * f); // Paper - Add world settings for mobs picking up loot - if (object == null) { - object = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(randomsource), true); + if (spawnReason != EntitySpawnReason.CONVERSION) { +- this.setCanPickUpLoot(randomsource.nextFloat() < 0.55F * f); ++ this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.zombies || randomsource.nextFloat() < 0.55F * f); // Paper - Add world settings for mobs picking up loot } + + if (object == null) { diff --git a/patches/unapplied/server/Additional-Block-Material-API.patch b/patches/server/Additional-Block-Material-API.patch similarity index 100% rename from patches/unapplied/server/Additional-Block-Material-API.patch rename to patches/server/Additional-Block-Material-API.patch diff --git a/patches/unapplied/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch b/patches/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch similarity index 100% rename from patches/unapplied/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch rename to patches/server/Allow-disabling-mob-spawner-spawn-egg-transformation.patch diff --git a/patches/unapplied/server/Configurable-door-breaking-difficulty.patch b/patches/server/Configurable-door-breaking-difficulty.patch similarity index 100% rename from patches/unapplied/server/Configurable-door-breaking-difficulty.patch rename to patches/server/Configurable-door-breaking-difficulty.patch diff --git a/patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch b/patches/server/Empty-commands-shall-not-be-dispatched.patch similarity index 100% rename from patches/unapplied/server/Empty-commands-shall-not-be-dispatched.patch rename to patches/server/Empty-commands-shall-not-be-dispatched.patch diff --git a/patches/unapplied/server/Fix-Not-a-string-Map-Conversion-spam.patch b/patches/server/Fix-Not-a-string-Map-Conversion-spam.patch similarity index 71% rename from patches/unapplied/server/Fix-Not-a-string-Map-Conversion-spam.patch rename to patches/server/Fix-Not-a-string-Map-Conversion-spam.patch index 44d3d8784d..029db2c29f 100644 --- a/patches/unapplied/server/Fix-Not-a-string-Map-Conversion-spam.patch +++ b/patches/server/Fix-Not-a-string-Map-Conversion-spam.patch @@ -15,23 +15,14 @@ diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSaved index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -0,0 +0,0 @@ import net.minecraft.core.component.DataComponents; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.NbtOps; -+import net.minecraft.nbt.NumericTag; -+import net.minecraft.nbt.StringTag; - import net.minecraft.nbt.Tag; - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.chat.Component; @@ -0,0 +0,0 @@ public class MapItemSavedData extends SavedData { } - public static MapItemSavedData load(CompoundTag nbt, HolderLookup.Provider registryLookup) { + public static MapItemSavedData load(CompoundTag nbt, HolderLookup.Provider registries) { - DataResult> dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, nbt.get("dimension"))); // CraftBukkit - decompile error + // Paper start - fix "Not a string" spam + Tag dimension = nbt.get("dimension"); -+ if (dimension instanceof NumericTag && ((NumericTag) dimension).getAsInt() >= CraftWorld.CUSTOM_DIMENSION_OFFSET) { ++ if (dimension instanceof final net.minecraft.nbt.NumericTag numericTag && numericTag.getAsInt() >= CraftWorld.CUSTOM_DIMENSION_OFFSET) { + long least = nbt.getLong("UUIDLeast"); + long most = nbt.getLong("UUIDMost"); + @@ -39,12 +30,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + UUID uuid = new UUID(most, least); + CraftWorld world = (CraftWorld) Bukkit.getWorld(uuid); + if (world != null) { -+ dimension = StringTag.valueOf("minecraft:" + world.getName().toLowerCase(java.util.Locale.ENGLISH)); ++ dimension = net.minecraft.nbt.StringTag.valueOf("minecraft:" + world.getName().toLowerCase(java.util.Locale.ENGLISH)); + } else { -+ dimension = StringTag.valueOf("bukkit:_invalidworld_"); ++ dimension = net.minecraft.nbt.StringTag.valueOf("bukkit:_invalidworld_"); + } + } else { -+ dimension = StringTag.valueOf("bukkit:_invalidworld_"); ++ dimension = net.minecraft.nbt.StringTag.valueOf("bukkit:_invalidworld_"); + } + } + DataResult> dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, dimension)); // CraftBukkit - decompile error diff --git a/patches/unapplied/server/Fix-interact-event-not-being-called-sometimes.patch b/patches/server/Fix-interact-event-not-being-called-sometimes.patch similarity index 85% rename from patches/unapplied/server/Fix-interact-event-not-being-called-sometimes.patch rename to patches/server/Fix-interact-event-not-being-called-sometimes.patch index 10ce5822d9..5608186c16 100644 --- a/patches/unapplied/server/Fix-interact-event-not-being-called-sometimes.patch +++ b/patches/server/Fix-interact-event-not-being-called-sometimes.patch @@ -15,14 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED); + } else if (enuminteractionresult instanceof InteractionResult.Success) { + InteractionResult.Success enuminteractionresult_d = (InteractionResult.Success) enuminteractionresult; - this.player.sendSystemMessage(ichatmutablecomponent, true); -- } else if (enuminteractionresult.shouldSwing()) { -+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper - Call interact event - this.player.swing(enumhand, true); +- if (enuminteractionresult_d.swingSource() == InteractionResult.SwingSource.SERVER) { ++ if (enuminteractionresult_d.swingSource() == InteractionResult.SwingSource.SERVER && !this.player.gameMode.interactResult) { + this.player.swing(enumhand, true); + } } - } @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl double d3 = Math.max(this.player.blockInteractionRange(), this.player.entityInteractionRange()); // SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time diff --git a/patches/unapplied/server/Fix-nerfed-slime-when-splitting.patch b/patches/server/Fix-nerfed-slime-when-splitting.patch similarity index 58% rename from patches/unapplied/server/Fix-nerfed-slime-when-splitting.patch rename to patches/server/Fix-nerfed-slime-when-splitting.patch index 5924b58851..4140dc3d41 100644 --- a/patches/unapplied/server/Fix-nerfed-slime-when-splitting.patch +++ b/patches/server/Fix-nerfed-slime-when-splitting.patch @@ -9,10 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Slime.java +++ b/src/main/java/net/minecraft/world/entity/monster/Slime.java @@ -0,0 +0,0 @@ public class Slime extends Mob implements Enemy { - entityslime.setPersistenceRequired(); - } + float f3 = ((float) (l / 2) - 0.5F) * f1; + Slime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { // CraftBukkit + entityslime.aware = this.aware; // Paper - Fix nerfed slime when splitting - entityslime.setCustomName(ichatbasecomponent); - entityslime.setNoAi(flag); - entityslime.setInvulnerable(this.isInvulnerable()); + entityslime.setSize(j, true); + entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F); + // CraftBukkit start diff --git a/patches/unapplied/server/MC-4-Fix-item-position-desync.patch b/patches/server/MC-4-Fix-item-position-desync.patch similarity index 100% rename from patches/unapplied/server/MC-4-Fix-item-position-desync.patch rename to patches/server/MC-4-Fix-item-position-desync.patch diff --git a/patches/unapplied/server/Zombie-API-breaking-doors.patch b/patches/server/Zombie-API-breaking-doors.patch similarity index 100% rename from patches/unapplied/server/Zombie-API-breaking-doors.patch rename to patches/server/Zombie-API-breaking-doors.patch