diff --git a/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch index 63b54969bc..3c501825ea 100644 --- a/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch +++ b/patches/api/Option-to-prevent-NBT-copy-in-smithing-recipes.patch @@ -54,3 +54,56 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end } +diff --git a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java ++++ b/src/main/java/org/bukkit/inventory/SmithingTransformRecipe.java +@@ -0,0 +0,0 @@ public class SmithingTransformRecipe extends SmithingRecipe { + super(key, result, base, addition); + this.template = template; + } ++ // Paper start ++ /** ++ * Create a smithing recipe to produce the specified result ItemStack. ++ * ++ * @param key The unique recipe key ++ * @param result The item you want the recipe to create. ++ * @param template The template item. ++ * @param base The base ingredient ++ * @param addition The addition ingredient ++ * @param copyNbt whether to copy the nbt from the input base item to the output ++ */ ++ public SmithingTransformRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { ++ super(key, result, base, addition, copyNbt); ++ this.template = template; ++ } ++ // Paper end + + /** + * Get the template recipe item. +diff --git a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java ++++ b/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java +@@ -0,0 +0,0 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe + super(key, new ItemStack(Material.AIR), base, addition); + this.template = template; + } ++ // Paper start ++ /** ++ * Create a smithing recipe to produce the specified result ItemStack. ++ * ++ * @param key The unique recipe key ++ * @param template The template item. ++ * @param base The base ingredient ++ * @param addition The addition ingredient ++ * @param copyNbt whether to copy the nbt from the input base item to the output ++ */ ++ public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyNbt) { ++ super(key, new ItemStack(Material.AIR), base, addition, copyNbt); ++ this.template = template; ++ } ++ // Paper end + + /** + * Get the template recipe item. diff --git a/patches/unapplied/server/Add-BlockBreakBlockEvent.patch b/patches/server/Add-BlockBreakBlockEvent.patch similarity index 96% rename from patches/unapplied/server/Add-BlockBreakBlockEvent.patch rename to patches/server/Add-BlockBreakBlockEvent.patch index ed4f673f11..431fd922f8 100644 --- a/patches/unapplied/server/Add-BlockBreakBlockEvent.patch +++ b/patches/server/Add-BlockBreakBlockEvent.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack tool) { + public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { if (world instanceof ServerLevel) { diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) { beforeDestroyingBlock(world, pos, state); } // Paper - add source parameter protected abstract void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state); - private static short getCacheKey(BlockPos blockposition, BlockPos blockposition1) { + private static short getCacheKey(BlockPos from, BlockPos to) { diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java diff --git a/patches/unapplied/server/Add-ElderGuardianAppearanceEvent.patch b/patches/server/Add-ElderGuardianAppearanceEvent.patch similarity index 88% rename from patches/unapplied/server/Add-ElderGuardianAppearanceEvent.patch rename to patches/server/Add-ElderGuardianAppearanceEvent.patch index 42cecfda15..03fc95e743 100644 --- a/patches/unapplied/server/Add-ElderGuardianAppearanceEvent.patch +++ b/patches/server/Add-ElderGuardianAppearanceEvent.patch @@ -41,8 +41,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super.customServerAiStep(); if ((this.tickCount + this.getId()) % 1200 == 0) { MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2); -- List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit -+ List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper +- List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit ++ List list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper list.forEach((entityplayer) -> { entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F)); diff --git a/patches/unapplied/server/Add-PlayerSetSpawnEvent.patch b/patches/server/Add-PlayerSetSpawnEvent.patch similarity index 96% rename from patches/unapplied/server/Add-PlayerSetSpawnEvent.patch rename to patches/server/Add-PlayerSetSpawnEvent.patch index 433aa31171..8661c41c98 100644 --- a/patches/unapplied/server/Add-PlayerSetSpawnEvent.patch +++ b/patches/server/Add-PlayerSetSpawnEvent.patch @@ -41,9 +41,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (this.bedBlocked(blockposition, enumdirection)) { return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { -- this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit -+ this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - PlayerSetSpawnEvent - if (this.level.isDay()) { +- this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit ++ this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - PlayerSetSpawnEvent + if (this.level().isDay()) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { diff --git a/patches/unapplied/server/Add-System.out-err-catcher.patch b/patches/server/Add-System.out-err-catcher.patch similarity index 100% rename from patches/unapplied/server/Add-System.out-err-catcher.patch rename to patches/server/Add-System.out-err-catcher.patch diff --git a/patches/unapplied/server/Add-a-bunch-of-missing-forceDrop-toggles.patch b/patches/server/Add-a-bunch-of-missing-forceDrop-toggles.patch similarity index 97% rename from patches/unapplied/server/Add-a-bunch-of-missing-forceDrop-toggles.patch rename to patches/server/Add-a-bunch-of-missing-forceDrop-toggles.patch index ad6f4819a6..c5f58814d7 100644 --- a/patches/unapplied/server/Add-a-bunch-of-missing-forceDrop-toggles.patch +++ b/patches/server/Add-a-bunch-of-missing-forceDrop-toggles.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Panda extends Animal { } - if (!this.level.isClientSide() && this.random.nextInt(700) == 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + if (!this.level().isClientSide() && this.random.nextInt(700) == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { + this.forceDrops = true; // Paper this.spawnAtLocation((ItemLike) Items.SLIME_BALL); + this.forceDrops = false; // Paper diff --git a/patches/unapplied/server/Add-back-EntityPortalExitEvent.patch b/patches/server/Add-back-EntityPortalExitEvent.patch similarity index 100% rename from patches/unapplied/server/Add-back-EntityPortalExitEvent.patch rename to patches/server/Add-back-EntityPortalExitEvent.patch diff --git a/patches/unapplied/server/Add-config-for-mobs-immune-to-default-effects.patch b/patches/server/Add-config-for-mobs-immune-to-default-effects.patch similarity index 100% rename from patches/unapplied/server/Add-config-for-mobs-immune-to-default-effects.patch rename to patches/server/Add-config-for-mobs-immune-to-default-effects.patch diff --git a/patches/unapplied/server/Add-methods-to-find-targets-for-lightning-strikes.patch b/patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch similarity index 100% rename from patches/unapplied/server/Add-methods-to-find-targets-for-lightning-strikes.patch rename to patches/server/Add-methods-to-find-targets-for-lightning-strikes.patch diff --git a/patches/unapplied/server/Add-missing-team-sidebar-display-slots.patch b/patches/server/Add-missing-team-sidebar-display-slots.patch similarity index 100% rename from patches/unapplied/server/Add-missing-team-sidebar-display-slots.patch rename to patches/server/Add-missing-team-sidebar-display-slots.patch diff --git a/patches/unapplied/server/Add-more-LimitedRegion-API.patch b/patches/server/Add-more-LimitedRegion-API.patch similarity index 100% rename from patches/unapplied/server/Add-more-LimitedRegion-API.patch rename to patches/server/Add-more-LimitedRegion-API.patch diff --git a/patches/unapplied/server/Added-EntityDamageItemEvent.patch b/patches/server/Added-EntityDamageItemEvent.patch similarity index 94% rename from patches/unapplied/server/Added-EntityDamageItemEvent.patch rename to patches/server/Added-EntityDamageItemEvent.patch index 08ad50844c..f3865d51bd 100644 --- a/patches/unapplied/server/Added-EntityDamageItemEvent.patch +++ b/patches/server/Added-EntityDamageItemEvent.patch @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 j = this.getDamageValue() + amount; @@ -0,0 +0,0 @@ public final class ItemStack { public void hurtAndBreak(int amount, T entity, Consumer breakCallback) { - if (!entity.level.isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) { + if (!entity.level().isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) { if (this.isDamageableItem()) { - if (this.hurt(amount, entity.getRandom(), entity instanceof ServerPlayer ? (ServerPlayer) entity : null)) { + if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent diff --git a/patches/unapplied/server/Adds-PlayerArmSwingEvent.patch b/patches/server/Adds-PlayerArmSwingEvent.patch similarity index 100% rename from patches/unapplied/server/Adds-PlayerArmSwingEvent.patch rename to patches/server/Adds-PlayerArmSwingEvent.patch diff --git a/patches/unapplied/server/Change-EnderEye-target-without-changing-other-things.patch b/patches/server/Change-EnderEye-target-without-changing-other-things.patch similarity index 100% rename from patches/unapplied/server/Change-EnderEye-target-without-changing-other-things.patch rename to patches/server/Change-EnderEye-target-without-changing-other-things.patch diff --git a/patches/unapplied/server/Clear-bucket-NBT-after-dispense.patch b/patches/server/Clear-bucket-NBT-after-dispense.patch similarity index 100% rename from patches/unapplied/server/Clear-bucket-NBT-after-dispense.patch rename to patches/server/Clear-bucket-NBT-after-dispense.patch diff --git a/patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch b/patches/server/Config-option-for-Piglins-guarding-chests.patch similarity index 79% rename from patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch rename to patches/server/Config-option-for-Piglins-guarding-chests.patch index a0492bbcc7..f1b6896efe 100644 --- a/patches/unapplied/server/Config-option-for-Piglins-guarding-chests.patch +++ b/patches/server/Config-option-for-Piglins-guarding-chests.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public static void angerNearbyPiglins(Player player, boolean blockOpen) { -+ if (!player.level.paperConfig().entities.behavior.piglinsGuardChests) return; // Paper - List list = player.level.getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D)); ++ if (!player.level().paperConfig().entities.behavior.piglinsGuardChests) return; // Paper + List list = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D)); list.stream().filter(PiglinAi::isIdle).filter((entitypiglin) -> { diff --git a/patches/unapplied/server/Configurable-item-frame-map-cursor-update-interval.patch b/patches/server/Configurable-item-frame-map-cursor-update-interval.patch similarity index 100% rename from patches/unapplied/server/Configurable-item-frame-map-cursor-update-interval.patch rename to patches/server/Configurable-item-frame-map-cursor-update-interval.patch diff --git a/patches/unapplied/server/Don-t-apply-cramming-damage-to-players.patch b/patches/server/Don-t-apply-cramming-damage-to-players.patch similarity index 100% rename from patches/unapplied/server/Don-t-apply-cramming-damage-to-players.patch rename to patches/server/Don-t-apply-cramming-damage-to-players.patch diff --git a/patches/unapplied/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch b/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch similarity index 100% rename from patches/unapplied/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch rename to patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch diff --git a/patches/unapplied/server/Fix-PlayerDropItemEvent-using-wrong-item.patch b/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch similarity index 94% rename from patches/unapplied/server/Fix-PlayerDropItemEvent-using-wrong-item.patch rename to patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch index ac0e217988..d33328b571 100644 --- a/patches/unapplied/server/Fix-PlayerDropItemEvent-using-wrong-item.patch +++ b/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch @@ -30,6 +30,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + itemstack.setCount(0); + itemstack = tmp; + // Paper end - ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), itemstack); + ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), itemstack); entityitem.setPickUpDelay(40); diff --git a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch similarity index 81% rename from patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch rename to patches/server/Fix-commands-from-signs-not-firing-command-events.patch index 8bfe96ac69..21fe8e800d 100644 --- a/patches/unapplied/server/Fix-commands-from-signs-not-firing-command-events.patch +++ b/patches/server/Fix-commands-from-signs-not-firing-command-events.patch @@ -61,33 +61,25 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntit index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C - private boolean renderMessagedFiltered; - private DyeColor color; - private boolean hasGlowingText; -+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger(); - - public SignBlockEntity(BlockPos pos, BlockState state) { - super(BlockEntityType.SIGN, pos, state); @@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C ClickEvent chatclickable = chatmodifier.getClickEvent(); if (chatclickable != null && chatclickable.getAction() == ClickEvent.Action.RUN_COMMAND) { -- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(player), chatclickable.getValue()); +- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(player, world, pos), chatclickable.getValue()); + // Paper start + String command = chatclickable.getValue().startsWith("/") ? chatclickable.getValue() : "/" + chatclickable.getValue(); + if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command); + } -+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent(player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState()); ++ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState()); + if (!event.callEvent()) { + return false; + } -+ player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage()); ++ player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage()); + // Paper end + flag1 = true; } } - @@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C String s = player == null ? "Sign" : player.getName().getString(); Object object = player == null ? Component.literal("Sign") : player.getDisplayName(); @@ -96,7 +88,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + CommandSource commandSource = this.level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this) { + @Override + public void sendSystemMessage(Component message) { -+ player.sendSystemMessage(message); ++ if (player != null) { ++ player.sendSystemMessage(message); ++ } + } + + @Override @@ -106,11 +100,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } : this; + // Paper end // CraftBukkit - this -- return new CommandSourceStack(this, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player); -+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player); // Paper +- return new CommandSourceStack(this, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); ++ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); // Paper } - public DyeColor getColor() { + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java diff --git a/patches/unapplied/server/Fix-dangerous-end-portal-logic.patch b/patches/server/Fix-dangerous-end-portal-logic.patch similarity index 96% rename from patches/unapplied/server/Fix-dangerous-end-portal-logic.patch rename to patches/server/Fix-dangerous-end-portal-logic.patch index d17c618531..1eafeba01a 100644 --- a/patches/unapplied/server/Fix-dangerous-end-portal-logic.patch +++ b/patches/server/Fix-dangerous-end-portal-logic.patch @@ -15,9 +15,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this)); } - // Paper end - optimise entity tracking + // Paper end + + // Paper start - make end portalling safe + public BlockPos portalBlock; + public ServerLevel portalWorld; @@ -48,9 +48,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.teleportTo(worldserver, null); + } + // Paper end - make end portalling safe - ++ public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); + this.passengers = ImmutableList.of(); @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } diff --git a/patches/unapplied/server/Fix-incorrect-message-for-outdated-client.patch b/patches/server/Fix-incorrect-message-for-outdated-client.patch similarity index 100% rename from patches/unapplied/server/Fix-incorrect-message-for-outdated-client.patch rename to patches/server/Fix-incorrect-message-for-outdated-client.patch diff --git a/patches/unapplied/server/Fix-incosistency-issue-with-empty-map-items-in-CB.patch b/patches/server/Fix-incosistency-issue-with-empty-map-items-in-CB.patch similarity index 100% rename from patches/unapplied/server/Fix-incosistency-issue-with-empty-map-items-in-CB.patch rename to patches/server/Fix-incosistency-issue-with-empty-map-items-in-CB.patch diff --git a/patches/unapplied/server/Fix-potions-splash-events.patch b/patches/server/Fix-potions-splash-events.patch similarity index 92% rename from patches/unapplied/server/Fix-potions-splash-events.patch rename to patches/server/Fix-potions-splash-events.patch index ce47191325..ee12e20a0c 100644 --- a/patches/unapplied/server/Fix-potions-splash-events.patch +++ b/patches/server/Fix-potions-splash-events.patch @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (showParticles) { // Paper int i = potionregistry.hasInstantEffects() ? 2007 : 2002; - this.level.levelEvent(i, this.blockPosition(), PotionUtils.getColor(itemstack)); + this.level().levelEvent(i, this.blockPosition(), PotionUtils.getColor(itemstack)); + } // Paper this.discard(); } @@ -43,9 +43,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final Predicate APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper + private boolean applyWater() { // Paper AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); -- List list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE); +- List list = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE); + // Paper start -+ List list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE); ++ List list = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE); + Map affected = new HashMap<>(); + java.util.Set rehydrate = new java.util.HashSet<>(); + java.util.Set extinguish = new java.util.HashSet<>(); @@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -- List list1 = this.level.getEntitiesOfClass(Axolotl.class, axisalignedbb); +- List list1 = this.level().getEntitiesOfClass(Axolotl.class, axisalignedbb); - Iterator iterator1 = list1.iterator(); - - while (iterator1.hasNext()) { @@ -102,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - private void applySplash(List statusEffects, @Nullable Entity entity) { + private boolean applySplash(List statusEffects, @Nullable Entity entity) { // Paper AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D); - List list1 = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb); + List list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb); Map affected = new HashMap(); // CraftBukkit @@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie if (d0 < 16.0D) { @@ -122,7 +122,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - private void makeAreaOfEffectCloud(ItemStack stack, Potion potion) { + private boolean makeAreaOfEffectCloud(ItemStack stack, Potion potion) { // Paper - AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ()); + AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); Entity entity = this.getOwner(); @@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie @@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud); - if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) { + if (!(event.isCancelled() || entityareaeffectcloud.isRemoved() || (noEffects && entityareaeffectcloud.effects.isEmpty() && entityareaeffectcloud.getPotion().getEffects().isEmpty()))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling - this.level.addFreshEntity(entityareaeffectcloud); + this.level().addFreshEntity(entityareaeffectcloud); } else { entityareaeffectcloud.discard(); } diff --git a/patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch b/patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch similarity index 100% rename from patches/unapplied/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch rename to patches/server/Fix-return-value-of-Block-applyBoneMeal-always-being.patch diff --git a/patches/unapplied/server/Fix-test-not-bootstrapping.patch b/patches/server/Fix-test-not-bootstrapping.patch similarity index 100% rename from patches/unapplied/server/Fix-test-not-bootstrapping.patch rename to patches/server/Fix-test-not-bootstrapping.patch diff --git a/patches/unapplied/server/Fixes-kick-event-leave-message-not-being-sent.patch b/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch similarity index 95% rename from patches/unapplied/server/Fixes-kick-event-leave-message-not-being-sent.patch rename to patches/server/Fixes-kick-event-leave-message-not-being-sent.patch index 56e3635b6c..8e4318ec31 100644 --- a/patches/unapplied/server/Fixes-kick-event-leave-message-not-being-sent.patch +++ b/patches/server/Fixes-kick-event-leave-message-not-being-sent.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent // CraftBukkit end public boolean isRealPlayer; // Paper - public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks + public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -65,13 +65,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class PlayerList { } - public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // Paper - return Component + public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component + // Paper start + return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : PaperAdventure.asAdventure(entityplayer.getDisplayName()))); + } + public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) { + // Paper end - ServerLevel worldserver = entityplayer.getLevel(); + ServerLevel worldserver = entityplayer.serverLevel(); entityplayer.awardStat(Stats.LEAVE_GAME); @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/patches/unapplied/server/Improve-boat-collision-performance.patch b/patches/server/Improve-boat-collision-performance.patch similarity index 100% rename from patches/unapplied/server/Improve-boat-collision-performance.patch rename to patches/server/Improve-boat-collision-performance.patch diff --git a/patches/unapplied/server/Line-Of-Sight-Changes.patch b/patches/server/Line-Of-Sight-Changes.patch similarity index 88% rename from patches/unapplied/server/Line-Of-Sight-Changes.patch rename to patches/server/Line-Of-Sight-Changes.patch index 9d4ceb4422..4fb1245c6b 100644 --- a/patches/unapplied/server/Line-Of-Sight-Changes.patch +++ b/patches/server/Line-Of-Sight-Changes.patch @@ -12,9 +12,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); -- return vec3d1.distanceTo(vec3d) > 128.0D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; +- return vec3d1.distanceTo(vec3d) > 128.0D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; + // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists -+ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr ++ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; } } @@ -60,12 +60,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public boolean hasLineOfSight(Location loc) { -+ if (this.getHandle().level != ((CraftWorld) loc.getWorld()).getHandle()) return false; ++ if (this.getHandle().level() != ((CraftWorld) loc.getWorld()).getHandle()) return false; + Vec3 vec3d = new Vec3(this.getHandle().getX(), this.getHandle().getEyeY(), this.getHandle().getZ()); + Vec3 vec3d1 = new Vec3(loc.getX(), loc.getY(), loc.getZ()); + if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks + -+ return this.getHandle().level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.getHandle())).getType() == HitResult.Type.MISS; ++ return this.getHandle().level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.getHandle())).getType() == HitResult.Type.MISS; + } + // Paper end + diff --git a/patches/unapplied/server/Make-EntityUnleashEvent-cancellable.patch b/patches/server/Make-EntityUnleashEvent-cancellable.patch similarity index 78% rename from patches/unapplied/server/Make-EntityUnleashEvent-cancellable.patch rename to patches/server/Make-EntityUnleashEvent-cancellable.patch index b6586e5795..1a6a597185 100644 --- a/patches/unapplied/server/Make-EntityUnleashEvent-cancellable.patch +++ b/patches/server/Make-EntityUnleashEvent-cancellable.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting { if (flag1 && this.isLeashed()) { // Paper start - drop leash variable - EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true); -- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit + EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true); +- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit + if (!event.callEvent()) { return flag1; } this.dropLeash(true, event.isDropLeash()); // Paper end @@ -22,20 +22,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java +++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java @@ -0,0 +0,0 @@ public abstract class PathfinderMob extends Mob { - if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper + if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper // Paper start - drop leash variable EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true); -- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit +- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit + if (!event.callEvent()) { return; } this.dropLeash(true, event.isDropLeash()); // Paper end } @@ -0,0 +0,0 @@ public abstract class PathfinderMob extends Mob { - if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper + if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper // Paper start - drop leash variable EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true); -- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit -+ if (!event.callEvent()) return; +- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit ++ if (!event.callEvent()) { return; } this.dropLeash(true, event.isDropLeash()); // Paper end this.goalSelector.disableControlFlag(Goal.Flag.MOVE); diff --git a/patches/unapplied/server/Make-hoppers-respect-inventory-max-stack-size.patch b/patches/server/Make-hoppers-respect-inventory-max-stack-size.patch similarity index 100% rename from patches/unapplied/server/Make-hoppers-respect-inventory-max-stack-size.patch rename to patches/server/Make-hoppers-respect-inventory-max-stack-size.patch diff --git a/patches/unapplied/server/Make-item-validations-configurable.patch b/patches/server/Make-item-validations-configurable.patch similarity index 100% rename from patches/unapplied/server/Make-item-validations-configurable.patch rename to patches/server/Make-item-validations-configurable.patch diff --git a/patches/unapplied/server/Missing-Entity-Behavior-API.patch b/patches/server/Missing-Entity-Behavior-API.patch similarity index 99% rename from patches/unapplied/server/Missing-Entity-Behavior-API.patch rename to patches/server/Missing-Entity-Behavior-API.patch index f15a52d6d8..719241c70c 100644 --- a/patches/unapplied/server/Missing-Entity-Behavior-API.patch +++ b/patches/server/Missing-Entity-Behavior-API.patch @@ -154,8 +154,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void aiStep() { super.aiStep(); -- if (!this.level.isClientSide) { -+ if (!this.level.isClientSide && !this.ageLocked) { // Paper +- if (!this.level().isClientSide) { ++ if (!this.level().isClientSide && !this.ageLocked) { // Paper this.setAge(this.age + 1); } @@ -325,10 +325,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true); @@ -0,0 +0,0 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder { this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); - this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level.getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit end -- this.level.broadcastEntityEvent(this, (byte) 16); -+ if (broadcastEntityEvent) this.level.broadcastEntityEvent(this, (byte) 16); // Paper - missing entity behaviour api - converting without entity event +- this.level().broadcastEntityEvent(this, (byte) 16); ++ if (broadcastEntityEvent) this.level().broadcastEntityEvent(this, (byte) 16); // Paper - missing entity behaviour api - converting without entity event } @Override diff --git a/patches/unapplied/server/More-CommandBlock-API.patch b/patches/server/More-CommandBlock-API.patch similarity index 100% rename from patches/unapplied/server/More-CommandBlock-API.patch rename to patches/server/More-CommandBlock-API.patch diff --git a/patches/unapplied/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch b/patches/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch similarity index 100% rename from patches/unapplied/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch rename to patches/server/Optimize-Biome-Mob-Lookups-for-Mob-Spawning.patch diff --git a/patches/unapplied/server/Optimize-entity-tracker-passenger-checks.patch b/patches/server/Optimize-entity-tracker-passenger-checks.patch similarity index 100% rename from patches/unapplied/server/Optimize-entity-tracker-passenger-checks.patch rename to patches/server/Optimize-entity-tracker-passenger-checks.patch diff --git a/patches/unapplied/server/Optimize-indirect-passenger-iteration.patch b/patches/server/Optimize-indirect-passenger-iteration.patch similarity index 94% rename from patches/unapplied/server/Optimize-indirect-passenger-iteration.patch rename to patches/server/Optimize-indirect-passenger-iteration.patch index 280f61edfd..c6ac7d02d0 100644 --- a/patches/unapplied/server/Optimize-indirect-passenger-iteration.patch +++ b/patches/server/Optimize-indirect-passenger-iteration.patch @@ -43,8 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return () -> { return this.getIndirectPassengersStream().iterator(); }; -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - // Paper end - rewrite chunk system + } public boolean hasExactlyOnePlayerPassenger() { + if (this.passengers.isEmpty()) { return false; } // Paper diff --git a/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch new file mode 100644 index 0000000000..faa1e5f9e1 --- /dev/null +++ b/patches/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch @@ -0,0 +1,147 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sun, 26 Sep 2021 12:57:28 -0700 +Subject: [PATCH] Option to prevent NBT copy in smithing recipes + + +diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java ++++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +@@ -0,0 +0,0 @@ public class SmithingTransformRecipe implements SmithingRecipe { + final Ingredient base; + final Ingredient addition; + final ItemStack result; ++ final boolean copyNBT; // Paper + + public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result) { ++ // Paper start ++ this(id, template, base, addition, result, true); ++ } ++ public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) { ++ this.copyNBT = copyNBT; ++ // Paper end + this.id = id; + this.template = template; + this.base = base; +@@ -0,0 +0,0 @@ public class SmithingTransformRecipe implements SmithingRecipe { + @Override + public ItemStack assemble(Container inventory, RegistryAccess registryManager) { + ItemStack itemstack = this.result.copy(); ++ if (this.copyNBT) { // Paper - copy nbt conditionally + CompoundTag nbttagcompound = inventory.getItem(1).getTag(); + + if (nbttagcompound != null) { + itemstack.setTag(nbttagcompound.copy()); + } ++ } // Paper + + return itemstack; + } +@@ -0,0 +0,0 @@ public class SmithingTransformRecipe implements SmithingRecipe { + public Recipe toBukkitRecipe() { + CraftItemStack result = CraftItemStack.asCraftMirror(this.result); + +- CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNBT); // Paper + + return recipe; + } +diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java ++++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +@@ -0,0 +0,0 @@ public class SmithingTrimRecipe implements SmithingRecipe { + final Ingredient template; + final Ingredient base; + final Ingredient addition; ++ final boolean copyNbt; // Paper + + public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition) { ++ // Paper start ++ this(id, template, base, addition, true); ++ } ++ public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) { ++ this.copyNbt = copyNbt; ++ // Paper end + this.id = id; + this.template = template; + this.base = base; +@@ -0,0 +0,0 @@ public class SmithingTrimRecipe implements SmithingRecipe { + return ItemStack.EMPTY; + } + +- ItemStack itemstack1 = itemstack.copy(); ++ ItemStack itemstack1 = this.copyNbt ? itemstack.copy() : new ItemStack(itemstack.getItem(), itemstack.getCount()); // Paper + + itemstack1.setCount(1); + ArmorTrim armortrim = new ArmorTrim((Holder) optional.get(), (Holder) optional1.get()); +@@ -0,0 +0,0 @@ public class SmithingTrimRecipe implements SmithingRecipe { + // CraftBukkit start + @Override + public Recipe toBukkitRecipe() { +- return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper + } + // CraftBukkit end + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java +@@ -0,0 +0,0 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem + public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { + super(key, result, template, base, addition); + } ++ // Paper start ++ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { ++ super(key, result, template, base, addition, copyNbt); ++ } ++ // Paper end + + public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) { + if (recipe instanceof CraftSmithingTransformRecipe) { + return (CraftSmithingTransformRecipe) recipe; + } +- CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); ++ CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper + return ret; + } + +@@ -0,0 +0,0 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem + public void addToCraftingManager() { + ItemStack result = this.getResult(); + +- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt())); // Paper + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java +@@ -0,0 +0,0 @@ public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements Craft + public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) { + super(key, template, base, addition); + } ++ // Paper start ++ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { ++ super(key, template, base, addition, copyNbt); ++ } ++ // Paper end + + public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) { + if (recipe instanceof CraftSmithingTrimRecipe) { + return (CraftSmithingTrimRecipe) recipe; + } +- CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition()); ++ CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper + return ret; + } + + @Override + public void addToCraftingManager() { +- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), this.willCopyNbt())); // Paper + } + } diff --git a/patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch b/patches/server/Prevent-AFK-kick-while-watching-end-credits.patch similarity index 86% rename from patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch rename to patches/server/Prevent-AFK-kick-while-watching-end-credits.patch index e32712acc4..d2d0c3192c 100644 --- a/patches/unapplied/server/Prevent-AFK-kick-while-watching-end-credits.patch +++ b/patches/server/Prevent-AFK-kick-while-watching-end-credits.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --this.dropSpamTickCount; } -- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) { -+ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60) && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits. +- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { ++ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits. this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854 this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause } diff --git a/patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch b/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch similarity index 100% rename from patches/unapplied/server/Rate-options-and-timings-for-sensors-and-behaviors.patch rename to patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch diff --git a/patches/unapplied/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch similarity index 100% rename from patches/unapplied/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch rename to patches/server/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch diff --git a/patches/unapplied/server/Stinger-API.patch b/patches/server/Stinger-API.patch similarity index 100% rename from patches/unapplied/server/Stinger-API.patch rename to patches/server/Stinger-API.patch diff --git a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch similarity index 96% rename from patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch rename to patches/server/Use-getChunkIfLoadedImmediately-in-places.patch index 196e898ad3..6fadb1fc8f 100644 --- a/patches/unapplied/server/Use-getChunkIfLoadedImmediately-in-places.patch +++ b/patches/server/Use-getChunkIfLoadedImmediately-in-places.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public abstract ResourceKey getTypeKey(); - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator) { // Paper diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java diff --git a/patches/unapplied/server/add-per-world-spawn-limits.patch b/patches/server/add-per-world-spawn-limits.patch similarity index 100% rename from patches/unapplied/server/add-per-world-spawn-limits.patch rename to patches/server/add-per-world-spawn-limits.patch diff --git a/patches/unapplied/server/Allow-skipping-writing-of-comments-to-server.propert.patch b/patches/unapplied/server/Allow-skipping-writing-of-comments-to-server.propert.patch deleted file mode 100644 index 35a15c68d3..0000000000 --- a/patches/unapplied/server/Allow-skipping-writing-of-comments-to-server.propert.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Professor Bloodstone -Date: Fri, 23 Jul 2021 02:32:04 +0200 -Subject: [PATCH] Allow skipping writing of comments to server.properties - -Makes less git noise, as it won't update the date every single time - -Use -DPaper.skipServerPropertiesComments=true flag to disable writing it - -diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/dedicated/Settings.java -+++ b/src/main/java/net/minecraft/server/dedicated/Settings.java -@@ -0,0 +0,0 @@ public abstract class Settings> { - - private static final Logger LOGGER = LogUtils.getLogger(); - public final Properties properties; -+ private static final boolean skipComments = Boolean.getBoolean("Paper.skipServerPropertiesComments"); // Paper - allow skipping server.properties comments - // CraftBukkit start - private OptionSet options = null; - -@@ -0,0 +0,0 @@ public abstract class Settings> { - } - // CraftBukkit end - OutputStream outputstream = Files.newOutputStream(path); -+ // Paper start - disable writing comments to properties file -+ java.io.BufferedOutputStream bufferedOutputStream = !skipComments ? new java.io.BufferedOutputStream(outputstream) : new java.io.BufferedOutputStream(outputstream) { -+ private boolean isRightAfterNewline = true; // If last written char was newline -+ private boolean isComment = false; // Are we writing comment currently? -+ -+ @Override -+ public void write(@org.jetbrains.annotations.NotNull byte[] b) throws IOException { -+ this.write(b, 0, b.length); -+ } -+ -+ @Override -+ public void write(@org.jetbrains.annotations.NotNull byte[] bbuf, int off, int len) throws IOException { -+ int latest_offset = off; // The latest offset, updated when comment ends -+ for (int index = off; index < off + len; ++index ) { -+ byte c = bbuf[index]; -+ boolean isNewline = (c == '\n' || c == '\r'); -+ if (isNewline && isComment) { -+ // Comment has ended -+ isComment = false; -+ latest_offset = index+1; -+ } -+ if (c == '#' && isRightAfterNewline) { -+ isComment = true; -+ if (index != latest_offset) { -+ // We got some non-comment data earlier -+ super.write(bbuf, latest_offset, index-latest_offset); -+ } -+ } -+ isRightAfterNewline = isNewline; // Store for next iteration -+ -+ } -+ if (latest_offset < off+len && !isComment) { -+ // We have some unwritten data, that isn't part of a comment -+ super.write(bbuf, latest_offset, (off + len) - latest_offset); -+ } -+ } -+ }; -+ // Paper end - - try { -- this.properties.store(outputstream, "Minecraft server properties"); -+ this.properties.store(bufferedOutputStream, "Minecraft server properties"); // Paper - use bufferedOutputStream - } catch (Throwable throwable) { - if (outputstream != null) { - try { diff --git a/patches/unapplied/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch b/patches/unapplied/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch deleted file mode 100644 index 1840822982..0000000000 --- a/patches/unapplied/server/Option-to-prevent-NBT-copy-in-smithing-recipes.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Sun, 26 Sep 2021 12:57:28 -0700 -Subject: [PATCH] Option to prevent NBT copy in smithing recipes - - -diff --git a/src/main/java/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java b/src/main/java/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java -+++ b/src/main/java/net/minecraft/world/item/crafting/LegacyUpgradeRecipe.java -@@ -0,0 +0,0 @@ public class LegacyUpgradeRecipe implements SmithingRecipe { - final Ingredient addition; - final ItemStack result; - private final ResourceLocation id; -+ final boolean copyNBT; // Paper - - public LegacyUpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result) { -+ // Paper start -+ this(id, base, addition, result, true); -+ } -+ public LegacyUpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) { -+ this.copyNBT = copyNBT; -+ // Paper end - this.id = id; - this.base = base; - this.addition = addition; -@@ -0,0 +0,0 @@ public class LegacyUpgradeRecipe implements SmithingRecipe { - @Override - public ItemStack assemble(Container inventory, RegistryAccess registryManager) { - ItemStack itemstack = this.result.copy(); -+ if (this.copyNBT) { // Paper - copy nbt conditionally - CompoundTag nbttagcompound = inventory.getItem(0).getTag(); - - if (nbttagcompound != null) { - itemstack.setTag(nbttagcompound.copy()); - } -+ } // Paper - - return itemstack; - } -@@ -0,0 +0,0 @@ public class LegacyUpgradeRecipe implements SmithingRecipe { - public Recipe toBukkitRecipe() { - CraftItemStack result = CraftItemStack.asCraftMirror(this.result); - -- CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); -+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNBT); // Paper - - return recipe; - } -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java -@@ -0,0 +0,0 @@ import org.bukkit.inventory.RecipeChoice; - import org.bukkit.inventory.SmithingRecipe; - - public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe { -+ @Deprecated // Paper - public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition) { - super(key, result, base, addition); - } -+ // Paper start -+ public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition, boolean copyNbt) { -+ super(key, result, base, addition, copyNbt); -+ } -+ // Paper end - - public static CraftSmithingRecipe fromBukkitRecipe(SmithingRecipe recipe) { - if (recipe instanceof CraftSmithingRecipe) { - return (CraftSmithingRecipe) recipe; - } -- CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition()); -+ CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper - return ret; - } - -@@ -0,0 +0,0 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe { - public void addToCraftingManager() { - ItemStack result = this.getResult(); - -- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.LegacyUpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.LegacyUpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt())); // Paper - } - }