diff --git a/patches/api/Add-More-Creeper-API.patch b/patches/api/Add-More-Creeper-API.patch index 7039036a63..f2d97ceac7 100644 --- a/patches/api/Add-More-Creeper-API.patch +++ b/patches/api/Add-More-Creeper-API.patch @@ -75,9 +75,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Creeper.java +++ b/src/main/java/org/bukkit/entity/Creeper.java @@ -0,0 +0,0 @@ public interface Creeper extends Monster { - * griefing gamerule. */ - public void ignite(); + @Nullable + public Entity getIgniter(); + // Paper start + + /** diff --git a/patches/api/Experimental-annotations-change.patch b/patches/api/Experimental-annotations-change.patch index 9122059b35..e3483773e0 100644 --- a/patches/api/Experimental-annotations-change.patch +++ b/patches/api/Experimental-annotations-change.patch @@ -72,13 +72,14 @@ diff --git a/src/main/java/org/bukkit/block/TrialSpawner.java b/src/main/java/or index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/TrialSpawner.java +++ b/src/main/java/org/bukkit/block/TrialSpawner.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.ApiStatus; +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; /** * Represents a captured state of a trial spawner. */ -@ApiStatus.Experimental public interface TrialSpawner extends TileState { - } + + /** diff --git a/src/main/java/org/bukkit/block/Vault.java b/src/main/java/org/bukkit/block/Vault.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Vault.java diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index 4d4b2d3ae3..8b5ab41325 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -1631,8 +1631,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -0,0 +0,0 @@ public class ShapedRecipe extends CraftingRecipe { - * @param ingredient The ingredient. * @return The changed recipe, so you can chain calls. + * @throws IllegalArgumentException if the {@code key} is a space character * @throws IllegalArgumentException if the {@code key} does not appear in the shape. + * @deprecated use {@link #setIngredient(char, RecipeChoice)} */ diff --git a/patches/api/Fix-issues-with-recipe-API.patch b/patches/api/Fix-issues-with-recipe-API.patch index c7d0ba81c7..7d09c16547 100644 --- a/patches/api/Fix-issues-with-recipe-API.patch +++ b/patches/api/Fix-issues-with-recipe-API.patch @@ -215,7 +215,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java +++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java @@ -0,0 +0,0 @@ public class ShapedRecipe extends CraftingRecipe { - public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient) { + Preconditions.checkArgument(key != ' ', "Space in recipe shape must represent no ingredient"); Preconditions.checkArgument(ingredients.containsKey(key), "Symbol does not appear in the shape:", key); - ingredients.put(key, ingredient); diff --git a/patches/api/Mob-Spawner-API-Enhancements.patch b/patches/api/Mob-Spawner-API-Enhancements.patch index dfdcb12161..524c83d8aa 100644 --- a/patches/api/Mob-Spawner-API-Enhancements.patch +++ b/patches/api/Mob-Spawner-API-Enhancements.patch @@ -4,14 +4,14 @@ Date: Fri, 19 Apr 2019 12:41:19 -0500 Subject: [PATCH] Mob Spawner API Enhancements -diff --git a/src/main/java/org/bukkit/block/CreatureSpawner.java b/src/main/java/org/bukkit/block/CreatureSpawner.java +diff --git a/src/main/java/org/bukkit/spawner/Spawner.java b/src/main/java/org/bukkit/spawner/Spawner.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/block/CreatureSpawner.java -+++ b/src/main/java/org/bukkit/block/CreatureSpawner.java -@@ -0,0 +0,0 @@ public interface CreatureSpawner extends TileState { +--- a/src/main/java/org/bukkit/spawner/Spawner.java ++++ b/src/main/java/org/bukkit/spawner/Spawner.java +@@ -0,0 +0,0 @@ public interface Spawner extends BaseSpawner { + * @param maxNearbyEntities the maximum number of nearby, similar, entities */ - @NotNull - public List getPotentialSpawns(); + public void setMaxNearbyEntities(int maxNearbyEntities); + + // Paper start + /** diff --git a/patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch b/patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch index 0a98ed6f03..216814077b 100644 --- a/patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch +++ b/patches/server/Add-PlayerAttackEntityCooldownResetEvent.patch @@ -9,11 +9,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { + } - EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption); if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player) { - ((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired + // Paper start - PlayerAttackEntityCooldownResetEvent ++ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired + if (damagesource.getEntity() instanceof ServerPlayer) { + ServerPlayer player = (ServerPlayer) damagesource.getEntity(); + if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackStrengthScale(0F)).callEvent()) { @@ -24,5 +25,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - PlayerAttackEntityCooldownResetEvent } - if (event.isCancelled()) { - return false; + + // Resistance diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 6fd3ee4ca8..7fd76c1acc 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -487,8 +487,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot if (this.getHandle().connection == null) return; -- this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message)); -+ this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message), org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause +- this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true)); ++ this.getHandle().connection.disconnect(CraftChatMessage.fromStringOrEmpty(message, true), org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause } // Paper start @@ -526,8 +526,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Kick all players for ( ServerPlayer p : com.google.common.collect.ImmutableList.copyOf( MinecraftServer.getServer().getPlayerList().players ) ) { -- p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage ) ); -+ p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage ), org.bukkit.event.player.PlayerKickEvent.Cause.RESTART_COMMAND); // Paper - kick event reason (cause is never used)) +- p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage, true ) ); ++ p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage, true ), org.bukkit.event.player.PlayerKickEvent.Cause.RESTART_COMMAND); // Paper - kick event reason (cause is never used)) } // Give the socket a chance to send the packets try diff --git a/patches/server/Add-critical-damage-API.patch b/patches/server/Add-critical-damage-API.patch index 880a4ea7fb..08a6899c3f 100644 --- a/patches/server/Add-critical-damage-API.patch +++ b/patches/server/Add-critical-damage-API.patch @@ -43,9 +43,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 float f7 = this.getEnchantedDamage(entityliving2, f6, damagesource) * f2; // CraftBukkit start - Only apply knockback if the damage hits -- if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) { -+ if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f7)) { // Paper - add critical damage API - entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events +- if (!entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) { ++ if (!entityliving2.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f7)) { // Paper - add critical damage API + continue; } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java diff --git a/patches/server/Add-drops-to-shear-events.patch b/patches/server/Add-drops-to-shear-events.patch index 11d83f391a..0750f0254a 100644 --- a/patches/server/Add-drops-to-shear-events.patch +++ b/patches/server/Add-drops-to-shear-events.patch @@ -237,29 +237,71 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Bogged.java +++ b/src/main/java/net/minecraft/world/entity/monster/Bogged.java @@ -0,0 +0,0 @@ public class Bogged extends AbstractSkeleton implements Shearable { + + if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { + // CraftBukkit start +- if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) { +- this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients +- return InteractionResult.PASS; ++ // Paper start - expose drops in event ++ java.util.List drops = generateDefaultDrops(); ++ final org.bukkit.event.player.PlayerShearEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand, drops); ++ if (event != null) { ++ if (event.isCancelled()) { ++ if (player instanceof final net.minecraft.server.level.ServerPlayer serverPlayer) this.resendPossiblyDesyncedDataValues(java.util.List.of(Bogged.DATA_SHEARED), serverPlayer); ++ return InteractionResult.PASS; ++ } ++ drops = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getDrops()); ++ // Paper end - expose drops in event + } + // CraftBukkit end +- this.shear(SoundSource.PLAYERS); ++ this.shear(SoundSource.PLAYERS, drops); // Paper - expose drops in event + this.gameEvent(GameEvent.SHEAR, player); + if (!this.level().isClientSide) { + itemstack.hurtAndBreak(1, player, getSlotForHand(hand)); +@@ -0,0 +0,0 @@ public class Bogged extends AbstractSkeleton implements Shearable { + + @Override + public void shear(SoundSource shearedSoundCategory) { ++ // Paper start - shear drop API ++ this.shear(shearedSoundCategory, generateDefaultDrops()); ++ } ++ ++ @Override ++ public void shear(SoundSource shearedSoundCategory, java.util.List drops) { ++ // Paper end - shear drop API + this.level().playSound((Player) null, (Entity) this, SoundEvents.BOGGED_SHEAR, shearedSoundCategory, 1.0F, 1.0F); +- this.spawnShearedMushrooms(); ++ this.spawnDrops(drops); // Paper - shear drop API + this.setSheared(true); } private void spawnShearedMushrooms() { -+ // Paper start - shear drops API -+ this.generateShearedMushrooms(stack -> { ++ // Paper start - shear drops API ++ this.spawnDrops(generateDefaultDrops()); // Only here for people calling spawnSheardMushrooms. Not used otherwise. ++ } ++ private void spawnDrops(java.util.List drops) { ++ drops.forEach(stack -> { + this.forceDrops = true; + this.spawnAtLocation(stack, this.getBbHeight()); + this.forceDrops = false; + }); + } + private void generateShearedMushrooms(java.util.function.Consumer stackConsumer) { -+ // Paper end - shear drops API - if (this.level() instanceof ServerLevel serverLevel) { - LootTable lootTable = serverLevel.getServer().reloadableRegistries().getLootTable(BuiltInLootTables.BOGGED_SHEAR); - LootParams lootParams = new LootParams.Builder(serverLevel) -@@ -0,0 +0,0 @@ public class Bogged extends AbstractSkeleton implements Shearable { - .create(LootContextParamSets.SHEARING); ++ // Paper end - shear drops API + Level world = this.level(); - for (ItemStack itemStack : lootTable.getRandomItems(lootParams)) { -- this.spawnAtLocation(itemStack, this.getBbHeight()); -+ stackConsumer.accept(itemStack); // Paper + if (world instanceof ServerLevel worldserver) { +@@ -0,0 +0,0 @@ public class Bogged extends AbstractSkeleton implements Shearable { + while (objectlistiterator.hasNext()) { + ItemStack itemstack = (ItemStack) objectlistiterator.next(); + +- this.spawnAtLocation(itemstack, this.getBbHeight()); ++ stackConsumer.accept(itemstack); // Paper } } + } + // Paper start - shear drops API diff --git a/patches/server/Add-entity-knockback-events.patch b/patches/server/Add-entity-knockback-events.patch index 0e85944597..2d9075bc8a 100644 --- a/patches/server/Add-entity-knockback-events.patch +++ b/patches/server/Add-entity-knockback-events.patch @@ -216,14 +216,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - - // CraftBukkit start - Only apply knockback if the damage hits - if (entityliving2.hurt(this.damageSources().playerAttack(this).sweep(), f7)) { -- entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // CraftBukkit -+ entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events + continue; } // CraftBukkit end +- entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F))); ++ entityliving2.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK); // CraftBukkit // Paper - knockback events + // entityliving2.hurt(damagesource, f7); // CraftBukkit - moved up Level world = this.level(); + diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java diff --git a/patches/server/Add-missing-forceDrop-toggles.patch b/patches/server/Add-missing-forceDrop-toggles.patch index 3ee3c929f5..f939302057 100644 --- a/patches/server/Add-missing-forceDrop-toggles.patch +++ b/patches/server/Add-missing-forceDrop-toggles.patch @@ -56,20 +56,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10; -diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java -+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java -@@ -0,0 +0,0 @@ public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder serialize(Builder builder) { -+ ImmutableMap.Builder serialize(ImmutableMap.Builder builder) { ++ com.google.common.collect.ImmutableMap.Builder serialize(com.google.common.collect.ImmutableMap.Builder builder) { // Paper - adventure - fqn as it conflicts with adventure book builder super.serialize(builder); if (this.hasTitle()) { diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index 6c4e97188a..4c6366224a 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -142,7 +142,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(Main.class.getPackage().getImplementationVendor()); // Paper Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -3); + deadline.add(Calendar.DAY_OF_YEAR, -7); diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java diff --git a/patches/server/Expose-server-build-information.patch b/patches/server/Expose-server-build-information.patch index d8e55aad30..03079ac7bb 100644 --- a/patches/server/Expose-server-build-information.patch +++ b/patches/server/Expose-server-build-information.patch @@ -610,7 +610,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static boolean useConsole = true; @@ -0,0 +0,0 @@ public class Main { - deadline.add(Calendar.DAY_OF_YEAR, -3); + deadline.add(Calendar.DAY_OF_YEAR, -7); if (buildDate.before(deadline.getTime())) { System.err.println("*** Error, this build is outdated ***"); - System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); diff --git a/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch b/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch index db3dc2316a..13e20f4fba 100644 --- a/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch +++ b/patches/server/Fix-PlayerDropItemEvent-using-wrong-item.patch @@ -36,9 +36,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { - if (retainOwnership) { + if (flag1) { if (!itemstack1.isEmpty()) { -- this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), stack.getCount()); +- this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), itemstack.getCount()); + this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), itemstack1.getCount()); // Paper - Fix PlayerDropItemEvent using wrong item } diff --git a/patches/server/Fix-helmet-damage-reduction-inconsistencies.patch b/patches/server/Fix-helmet-damage-reduction-inconsistencies.patch index f6d810cca7..941d4cfb61 100644 --- a/patches/server/Fix-helmet-damage-reduction-inconsistencies.patch +++ b/patches/server/Fix-helmet-damage-reduction-inconsistencies.patch @@ -11,9 +11,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- 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 { - Map> modifierFunctions = new EnumMap<>(DamageModifier.class); - modifiers.put(DamageModifier.BASE, rawDamage); - modifierFunctions.put(DamageModifier.BASE, CraftEventFactory.ZERO); + modifiers.put(DamageModifier.FREEZING, freezingModifier); + modifierFunctions.put(DamageModifier.FREEZING, freezing); + } - if (source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) { + if (source.is(DamageTypeTags.DAMAGES_HELMET)) { // Paper modifiers.put(DamageModifier.HARD_HAT, hardHatModifier); diff --git a/patches/server/Fix-this-stupid-bullshit.patch b/patches/server/Fix-this-stupid-bullshit.patch index 2748352d35..85aca2d071 100644 --- a/patches/server/Fix-this-stupid-bullshit.patch +++ b/patches/server/Fix-this-stupid-bullshit.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -0,0 +0,0 @@ public class Main { Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -3); + deadline.add(Calendar.DAY_OF_YEAR, -7); if (buildDate.before(deadline.getTime())) { - System.err.println("*** Error, this build is outdated ***"); + // Paper start - This is some stupid bullshit diff --git a/patches/server/General-ItemMeta-fixes.patch b/patches/server/General-ItemMeta-fixes.patch index 9a236fa5db..430abc1236 100644 --- a/patches/server/General-ItemMeta-fixes.patch +++ b/patches/server/General-ItemMeta-fixes.patch @@ -457,45 +457,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 static final int MAX_PAGE_LENGTH = WritableBookContent.PAGE_EDIT_LENGTH; // SPIGOT-6911: Use Minecraft limits // We store the pages in their raw original text representation. See SPIGOT-5063, SPIGOT-5350, SPIGOT-3206 -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java -@@ -0,0 +0,0 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta { - } - } - -- this.resolved = SerializableMeta.getObject(Boolean.class, map, CraftMetaBookSigned.RESOLVED.BUKKIT, true); -- this.generation = SerializableMeta.getObject(Integer.class, map, CraftMetaBookSigned.GENERATION.BUKKIT, true); -+ this.resolved = SerializableMeta.getBoolean(map, CraftMetaBookSigned.RESOLVED.BUKKIT); // Paper - General ItemMeta fixes -+ this.generation = SerializableMeta.getObjectOptionally(Integer.class, map, CraftMetaBookSigned.GENERATION.BUKKIT, true).orElse(0); // Paper - General ItemMeta Fixes - } - - @Override -@@ -0,0 +0,0 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta { - for (Component page : this.pages) { - list.add(Filterable.passThrough(page)); - } -- itemData.put(CraftMetaBookSigned.BOOK_CONTENT, new WrittenBookContent(Filterable.from(FilteredText.passThrough(this.title)), this.author, this.generation, list, this.resolved)); -+ itemData.put(CraftMetaBookSigned.BOOK_CONTENT, new WrittenBookContent(Filterable.from(FilteredText.passThrough(this.title == null ? "" : this.title)), this.author == null ? "" : this.author, this.generation, list, this.resolved)); - } - } - -@@ -0,0 +0,0 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta { - } - - if (this.pages != null) { -- builder.put(CraftMetaBookSigned.BOOK_PAGES.BUKKIT, ImmutableList.copyOf(this.pages)); -+ // Paper start - deserialization expects json -+ final List jsonPages = new ArrayList<>(this.pages.size()); -+ for (final Component page : this.pages) { -+ jsonPages.add(CraftChatMessage.toJSON(page)); -+ } -+ builder.put(CraftMetaBookSigned.BOOK_PAGES.BUKKIT, ImmutableList.copyOf(jsonPages)); -+ // Paper end - deserialization expects json - } - - if (this.resolved) { diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java @@ -740,22 +701,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 effects.add((FireworkEffect) obj); } } -@@ -0,0 +0,0 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { - } - - List effects = new ArrayList<>(); -- for (FireworkEffect effect : this.effects) { -- effects.add(CraftMetaFirework.getExplosion(effect)); -+ // Paper start - fix NPE with effects list being null -+ if (this.effects != null) { -+ for (FireworkEffect effect : this.effects) { -+ effects.add(CraftMetaFirework.getExplosion(effect)); -+ } - } -+ // Paper end - - itemTag.put(CraftMetaFirework.FIREWORKS, new Fireworks(this.power, effects)); - } @@ -0,0 +0,0 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta { } diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index dc092408dc..9d5df0a96e 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -468,7 +468,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 event.setKeepInventory(keepInventory); event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel + populateFields(victim, event); // Paper - make cancellable - org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); + // Paper start - make cancellable + if (event.isCancelled()) { diff --git a/patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch b/patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch index ec1dc98b8c..090b7a1374 100644 --- a/patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch +++ b/patches/server/Improve-fix-EntityTargetLivingEntityEvent.patch @@ -33,16 +33,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (event.isCancelled()) { return false; } -- if (event.getTarget() == null) { -- memoryaccessor.erase(); -- return true; -- } -- entityliving = ((CraftLivingEntity) event.getTarget()).getHandle(); -+ // if (event.getTarget() == null) { // Paper - this is wrong, you are skipping the forgetCallback -+ // memoryaccessor.erase(); -+ // return true; -+ // } -+ // entityliving = ((CraftLivingEntity) event.getTarget()).getHandle(); - // CraftBukkit end - forgetCallback.accept(entityinsentient, entityliving); - memoryaccessor.erase(); diff --git a/patches/server/Improve-item-default-attribute-API.patch b/patches/server/Improve-item-default-attribute-API.patch index ae1011d824..6bf8372375 100644 --- a/patches/server/Improve-item-default-attribute-API.patch +++ b/patches/server/Improve-item-default-attribute-API.patch @@ -3,8 +3,6 @@ From: Jake Potrebic Date: Sat, 8 May 2021 15:01:54 -0700 Subject: [PATCH] Improve item default attribute API -Also fixes an issue where upstream isn't -actually getting the correct default attributes diff --git a/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java b/src/main/java/org/bukkit/craftbukkit/attribute/CraftAttributeInstance.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -37,24 +35,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public Multimap getDefaultAttributeModifiers(EquipmentSlot slot) { -- ImmutableMultimap.Builder defaultAttributes = ImmutableMultimap.builder(); + // Paper start - improve/fix item default attribute API + final net.minecraft.world.entity.EquipmentSlot nmsSlot = CraftEquipmentSlot.getNMS(slot); + return this.getDefaultAttributeModifiers(sg -> sg.test(nmsSlot)); + } ++ ++ private Multimap getDefaultAttributeModifiers(final java.util.function.Predicate slotPredicate) { ++ // Paper end - improve/fix item default attribute API + ImmutableMultimap.Builder defaultAttributes = ImmutableMultimap.builder(); -- ItemAttributeModifiers nmsDefaultAttributes = this.item.getDefaultAttributeModifiers(); + ItemAttributeModifiers nmsDefaultAttributes = this.item.components().getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); + if (nmsDefaultAttributes.modifiers().isEmpty()) { + nmsDefaultAttributes = this.item.getDefaultAttributeModifiers(); + } +- - nmsDefaultAttributes.forEach(CraftEquipmentSlot.getNMS(slot), (key, value) -> { - Attribute attribute = CraftAttribute.minecraftToBukkit(key.value()); - defaultAttributes.put(attribute, CraftAttributeInstance.convert(value, slot)); - }); -+ private Multimap getDefaultAttributeModifiers(final java.util.function.Predicate slotPredicate) { -+ final ImmutableMultimap.Builder defaultAttributes = ImmutableMultimap.builder(); -+ ItemAttributeModifiers nmsDefaultAttributes = this.item.components().getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY); -+ if (nmsDefaultAttributes.modifiers().isEmpty()) { -+ // we have to check both places cause for some reason vanilla puts default modifiers for armor in a different place -+ nmsDefaultAttributes = this.item.getDefaultAttributeModifiers(); -+ } ++ // Paper start - improve/fix item default attribute API + for (final net.minecraft.world.item.component.ItemAttributeModifiers.Entry entry : nmsDefaultAttributes.modifiers()) { + if (!slotPredicate.test(entry.slot())) continue; + final Attribute attribute = CraftAttribute.minecraftHolderToBukkit(entry.attribute()); @@ -73,15 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Multimap getDefaultAttributeModifiers(Material material, EquipmentSlot slot) { -- ImmutableMultimap.Builder defaultAttributes = ImmutableMultimap.builder(); -- -- ItemAttributeModifiers nmsDefaultAttributes = CraftMagicNumbers.getItem(material).getDefaultAttributeModifiers(); -- nmsDefaultAttributes.forEach(CraftEquipmentSlot.getNMS(slot), (key, value) -> { -- Attribute attribute = CraftAttribute.minecraftToBukkit(key.value()); -- defaultAttributes.put(attribute, CraftAttributeInstance.convert(value, slot)); -- }); -- -- return defaultAttributes.build(); +- return material.getDefaultAttributeModifiers(slot); + // Paper start - delegate to method on ItemType + final org.bukkit.inventory.ItemType item = material.asItemType(); + Preconditions.checkArgument(item != null, material + " is not an item and does not have default attributes"); diff --git a/patches/server/Mob-Spawner-API-Enhancements.patch b/patches/server/Mob-Spawner-API-Enhancements.patch index d288aca7e1..daa9026b3a 100644 --- a/patches/server/Mob-Spawner-API-Enhancements.patch +++ b/patches/server/Mob-Spawner-API-Enhancements.patch @@ -72,40 +72,148 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.entity.CraftEntityType; + import org.bukkit.entity.EntitySnapshot; + import org.bukkit.entity.EntityType; + +-public class CraftCreatureSpawner extends CraftBlockEntityState implements CreatureSpawner { ++public class CraftCreatureSpawner extends CraftBlockEntityState implements CreatureSpawner, org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic { // Paper - more spawner API + + public CraftCreatureSpawner(World world, SpawnerBlockEntity tileEntity) { + super(world, tileEntity); @@ -0,0 +0,0 @@ public class CraftCreatureSpawner extends CraftBlockEntityState(nms.slotDropChances().entrySet().stream().collect(Collectors.toMap((entry) -> CraftEquipmentSlot.getSlot(entry.getKey()), Map.Entry::getValue))) )).orElse(null); } + -+ // Paper start ++ // Paper start - more spawner API + @Override + public boolean isActivated() { -+ this.requirePlaced(); -+ return this.getSnapshot().getSpawner().isNearPlayer(this.world.getHandle(), this.getPosition()); ++ requirePlaced(); ++ return org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic.super.isActivated(); + } + + @Override + public void resetTimer() { -+ this.requirePlaced(); -+ this.getSnapshot().getSpawner().delay(this.world.getHandle(), this.getPosition()); ++ requirePlaced(); ++ org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic.super.resetTimer(); + } + + @Override -+ public void setSpawnedItem(org.bukkit.inventory.ItemStack itemStack) { ++ public void setNextSpawnData(final SpawnData spawnData) { ++ this.getSpawner().setNextSpawnData(this.isPlaced() ? this.getInternalWorld() : null, this.getInternalPosition(), spawnData); ++ } ++ ++ @Override ++ public BaseSpawner getSpawner() { ++ return this.getSnapshot().getSpawner(); ++ } ++ ++ @Override ++ public net.minecraft.core.BlockPos getInternalPosition() { ++ return this.getPosition(); ++ } ++ ++ @Override ++ public net.minecraft.world.level.Level getInternalWorld() { ++ return this.world.getHandle(); ++ } ++ // Paper end - more spawner API + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartMobSpawner.java +@@ -0,0 +0,0 @@ import org.bukkit.entity.EntitySnapshot; + import org.bukkit.entity.EntityType; + import org.bukkit.entity.minecart.SpawnerMinecart; + +-final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart { ++final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMinecart, org.bukkit.craftbukkit.spawner.PaperSharedSpawnerLogic { // Paper - more spawner API + CraftMinecartMobSpawner(CraftServer server, MinecartSpawner entity) { + super(server, entity); + } +@@ -0,0 +0,0 @@ final class CraftMinecartMobSpawner extends CraftMinecart implements SpawnerMine + public String toString() { + return "CraftMinecartMobSpawner"; + } ++ ++ // Paper start - more spawner API ++ @Override ++ public net.minecraft.world.level.BaseSpawner getSpawner() { ++ return this.getHandle().getSpawner(); ++ } ++ ++ @Override ++ public net.minecraft.world.level.Level getInternalWorld() { ++ return this.getHandle().level(); ++ } ++ ++ @Override ++ public net.minecraft.core.BlockPos getInternalPosition() { ++ return this.getHandle().blockPosition(); ++ } ++ // Paper end - more spawner API + } +diff --git a/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java b/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/main/java/org/bukkit/craftbukkit/spawner/PaperSharedSpawnerLogic.java +@@ -0,0 +0,0 @@ ++package org.bukkit.craftbukkit.spawner; ++ ++import com.google.common.base.Preconditions; ++import java.util.Optional; ++import net.minecraft.core.BlockPos; ++import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.nbt.CompoundTag; ++import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.level.BaseSpawner; ++import net.minecraft.world.level.Level; ++import net.minecraft.world.level.SpawnData; ++import org.bukkit.craftbukkit.inventory.CraftItemStack; ++import org.bukkit.inventory.ItemStack; ++import org.bukkit.spawner.Spawner; ++ ++/** ++ * A common parent interface for both the {@link org.bukkit.craftbukkit.block.CraftCreatureSpawner} and minecart mob spawner. ++ */ ++public interface PaperSharedSpawnerLogic extends Spawner { ++ ++ BaseSpawner getSpawner(); ++ ++ Level getInternalWorld(); ++ ++ BlockPos getInternalPosition(); ++ ++ default boolean isActivated() { ++ return this.getSpawner().isNearPlayer(this.getInternalWorld(), this.getInternalPosition()); ++ } ++ ++ default void resetTimer() { ++ this.getSpawner().delay(this.getInternalWorld(), this.getInternalPosition()); ++ } ++ ++ default void setNextSpawnData(SpawnData spawnData) { ++ this.getSpawner().setNextSpawnData(this.getInternalWorld(), this.getInternalPosition(), spawnData); ++ } ++ ++ default void setSpawnedItem(final ItemStack itemStack) { + Preconditions.checkArgument(itemStack != null && !itemStack.getType().isAir(), "spawners cannot spawn air"); -+ net.minecraft.world.item.ItemStack item = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(itemStack); -+ net.minecraft.nbt.CompoundTag entity = new net.minecraft.nbt.CompoundTag(); -+ entity.putString("id", net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.getKey(net.minecraft.world.entity.EntityType.ITEM).toString()); -+ entity.put("Item", item.save(this.world.getHandle().registryAccess())); -+ this.getSnapshot().getSpawner().setNextSpawnData( -+ this.isPlaced() ? this.world.getHandle() : null, -+ this.getPosition(), ++ ++ final net.minecraft.world.item.ItemStack item = CraftItemStack.asNMSCopy(itemStack); ++ final CompoundTag entity = new CompoundTag(); ++ entity.putString(Entity.ID_TAG, BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ITEM).toString()); ++ entity.put("Item", item.save(this.getInternalWorld().registryAccess())); ++ ++ this.setNextSpawnData( + new net.minecraft.world.level.SpawnData( + entity, + java.util.Optional.empty(), -+ Optional.ofNullable(this.getSnapshot().getSpawner().nextSpawnData).flatMap(SpawnData::equipment) ++ Optional.ofNullable(this.getSpawner().nextSpawnData).flatMap(SpawnData::equipment) + ) + ); + } -+ // Paper end - } ++} diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index e28d21536f..0032ec1cf0 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -265,5 +265,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entity.connection.internalTeleport(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch(), nms); + // Paper end - Teleport API } else { + entity.portalProcess = null; // SPIGOT-7785: there is no need to carry this over as it contains the old world/location and we might run into trouble if there is a portal in the same spot in both worlds // The respawn reason should never be used if the passed location is non null. - this.server.getHandle().respawn(entity, true, Entity.RemovalReason.CHANGED_DIMENSION, null, to); diff --git a/patches/server/Optimize-Hoppers.patch b/patches/server/Optimize-Hoppers.patch index 8a331095ea..801ee0f9ac 100644 --- a/patches/server/Optimize-Hoppers.patch +++ b/patches/server/Optimize-Hoppers.patch @@ -380,6 +380,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (!itemstack.isEmpty()) { - int j = itemstack.getCount(); - // CraftBukkit start - Call event when pushing items into other inventories +- ItemStack original = itemstack.copy(); - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(blockEntity.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - - Inventory destinationInventory; @@ -395,7 +396,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - InventoryMoveItemEvent event = new InventoryMoveItemEvent(blockEntity.getOwner().getInventory(), oitemstack, destinationInventory, true); - world.getCraftServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- blockEntity.setItem(i, itemstack); +- blockEntity.setItem(i, original); - blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot - return false; - } @@ -423,6 +424,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // if (!itemstack.isEmpty()) { + // int j = itemstack.getCount(); + // // CraftBukkit start - Call event when pushing items into other inventories ++ // ItemStack original = itemstack.copy(); + // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(blockEntity.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot + + // Inventory destinationInventory; @@ -438,7 +440,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentityhopper.getOwner().getInventory(), oitemstack, destinationInventory, true); + // world.getCraftServer().getPluginManager().callEvent(event); + // if (event.isCancelled()) { -+ // blockEntity.setItem(i, itemstack); ++ // blockEntity.setItem(i, original); + // blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot + // return false; + // } @@ -484,6 +486,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { - int j = itemstack.getCount(); - // CraftBukkit start - Call event on collection of items from inventories into the hopper +- ItemStack original = itemstack.copy(); - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - - Inventory sourceInventory; @@ -500,7 +503,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- iinventory.setItem(i, itemstack); +- iinventory.setItem(i, original); - - if (ihopper instanceof HopperBlockEntity) { - ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot @@ -524,6 +527,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return hopperPull(world, ihopper, iinventory, itemstack, i); + // int j = itemstack.getCount(); + // // CraftBukkit start - Call event on collection of items from inventories into the hopper ++ // ItemStack original = itemstack.copy(); + // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot + + // Inventory sourceInventory; @@ -540,7 +544,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + // Bukkit.getServer().getPluginManager().callEvent(event); + // if (event.isCancelled()) { -+ // iinventory.setItem(i, itemstack); ++ // iinventory.setItem(i, original); + + // if (ihopper instanceof HopperBlockEntity) { + // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot diff --git a/patches/server/Prioritize-Minecraft-commands-in-function-parsing.patch b/patches/server/Prioritize-Minecraft-commands-in-function-parsing-an.patch similarity index 100% rename from patches/server/Prioritize-Minecraft-commands-in-function-parsing.patch rename to patches/server/Prioritize-Minecraft-commands-in-function-parsing-an.patch diff --git a/patches/server/Properly-handle-async-calls-to-restart-the-server.patch b/patches/server/Properly-handle-async-calls-to-restart-the-server.patch index 7b1d6c3e29..819007a2b3 100644 --- a/patches/server/Properly-handle-async-calls-to-restart-the-server.patch +++ b/patches/server/Properly-handle-async-calls-to-restart-the-server.patch @@ -119,7 +119,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - // Kick all players - for ( ServerPlayer p : (List) MinecraftServer.getServer().getPlayerList().players ) - { -- p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage ) ); +- p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage, true ) ); - } - // Give the socket a chance to send the packets - try @@ -138,7 +138,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Kick all players + for ( ServerPlayer p : com.google.common.collect.ImmutableList.copyOf( MinecraftServer.getServer().getPlayerList().players ) ) + { -+ p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage ) ); ++ p.connection.disconnect( CraftChatMessage.fromStringOrEmpty( SpigotConfig.restartMessage, true ) ); + } + // Give the socket a chance to send the packets + try diff --git a/patches/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch index 36e87eb8a0..b61377ee9c 100644 --- a/patches/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.isRemoved()) { return; } -- java.util.List loot = new java.util.ArrayList(this.getInventory().getContainerSize()); +- java.util.List loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); + List loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator(); @@ -31,24 +31,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) this.dropFromLootTable(damageSource, this.lastHurtByPlayerTime > 0); -- for (org.bukkit.inventory.ItemStack item : this.drops) { -- loot.add(item); -- } -+ loot.addAll(this.drops); // Paper +- this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag); ++ // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove. + + loot.addAll(this.drops); this.drops.clear(); // SPIGOT-5188: make sure to clear - } // Paper - fix player loottables running when mob loot gamerule is false - -@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { - } - - @Override -- public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership) { -- ItemEntity entityitem = super.drop(stack, throwRandomly, retainOwnership); -+ public ItemEntity drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean callDropEvent) { // Paper - Restore vanilla drops behavior; override method with most params -+ ItemEntity entityitem = super.drop(stack, throwRandomly, retainOwnership, callDropEvent); // Paper - Restore vanilla drops behavior; override method with most params - - if (entityitem == null) { - return null; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java @@ -238,8 +225,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - Restore vanilla drops behavior if (stack == null || stack.getType() == Material.AIR) continue; -- world.dropItem(entity.getLocation(), stack); -+ drop.runConsumer(world, entity.getLocation()); // Paper - Restore vanilla drops behavior +- victim.drop(CraftItemStack.asNMSCopy(stack), true, false, false); // SPIGOT-7800, SPIGOT-7801: Vanilla Behaviour for dropped items ++ drop.runConsumer(entity.getWorld(), entity.getLocation()); // Paper - Restore vanilla drops behavior } return event; diff --git a/patches/server/Revert-to-vanilla-handling-of-LivingEntity-actuallyH.patch b/patches/server/Revert-to-vanilla-handling-of-LivingEntity-actuallyH.patch index 352c9b049b..2009404712 100644 --- a/patches/server/Revert-to-vanilla-handling-of-LivingEntity-actuallyH.patch +++ b/patches/server/Revert-to-vanilla-handling-of-LivingEntity-actuallyH.patch @@ -9,14 +9,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - } + } - // CraftBukkit start -- protected boolean actuallyHurt(final DamageSource damagesource, float f) { // void -> boolean, add final -+ protected boolean actuallyHurt(final DamageSource damagesource, float f) { // void -> boolean, add final // Paper - return false ONLY if event cancelled - if (!this.isInvulnerableTo(damagesource)) { - final boolean human = this instanceof net.minecraft.world.entity.player.Player; - float originalDamage = f; + // CraftBukkit start +- if (!this.actuallyHurt(source, (float) event.getFinalDamage() - this.lastHurt, event)) { ++ final float actualDamage = (float) event.getFinalDamage() - this.lastHurt; // Paper - revert to vanilla damage - move out for diff on change ++ if (!this.actuallyHurt(source, actualDamage, event)) { // Paper - revert to vanilla damage - move out for diff on change + return false; + } ++ if (this instanceof ServerPlayer && actualDamage == 0.0F) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0. + // CraftBukkit end + this.lastHurt = amount; + flag1 = false; +@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { + if (!this.actuallyHurt(source, (float) event.getFinalDamage(), event)) { + return false; + } ++ if (this instanceof ServerPlayer && event.getFinalDamage() == 0.0F) return false; // Paper - revert to vanilla damage - players are not affected by damage that is 0. + this.lastHurt = amount; + this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks + // this.actuallyHurt(damagesource, f); @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { return true; diff --git a/patches/server/fix-player-loottables-running-when-mob-loot-gamerule.patch b/patches/server/fix-player-loottables-running-when-mob-loot-gamerule.patch index 69f1a5d9d1..3973a896aa 100644 --- a/patches/server/fix-player-loottables-running-when-mob-loot-gamerule.patch +++ b/patches/server/fix-player-loottables-running-when-mob-loot-gamerule.patch @@ -15,9 +15,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) this.dropFromLootTable(damageSource, this.lastHurtByPlayerTime > 0); - for (org.bukkit.inventory.ItemStack item : this.drops) { - loot.add(item); - } + this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag); + + loot.addAll(this.drops); this.drops.clear(); // SPIGOT-5188: make sure to clear + } // Paper - fix player loottables running when mob loot gamerule is false diff --git a/patches/server/improve-checking-handled-tags-in-itemmeta.patch b/patches/server/improve-checking-handled-tags-in-itemmeta.patch index 91accdc79e..d1f23d3efb 100644 --- a/patches/server/improve-checking-handled-tags-in-itemmeta.patch +++ b/patches/server/improve-checking-handled-tags-in-itemmeta.patch @@ -533,7 +533,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - CraftMetaFirework.FIREWORKS.TYPE, - CraftMetaEnchantedBook.STORED_ENCHANTMENTS.TYPE, - CraftMetaCharge.EXPLOSION.TYPE, -- CraftMetaBlockState.BLOCK_ENTITY_TAG.TYPE, - CraftMetaKnowledgeBook.BOOK_RECIPES.TYPE, - CraftMetaTropicalFishBucket.ENTITY_TAG.TYPE, - CraftMetaTropicalFishBucket.BUCKET_ENTITY_TAG.TYPE, diff --git a/work/Bukkit b/work/Bukkit index 2b4b6d1424..e86f4dc4bb 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 2b4b6d14241d3d96eb6b7d1888176146dc5895d4 +Subproject commit e86f4dc4bb897d2ad627763e46c9ed08b090f0f3 diff --git a/work/CraftBukkit b/work/CraftBukkit index 68603b1c11..c3ceeb6f79 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 68603b1c1162f168efdfe8d989d8795587ef9842 +Subproject commit c3ceeb6f79b4258d3c966f34aeafb7ca6d72e41a diff --git a/work/Spigot b/work/Spigot index 146439e88c..491f367502 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit 146439e88cdda2de5ce54c2a9d6a6cdd9aa8bc1b +Subproject commit 491f36750240694ded097bb893aa03d5f7bb81d8