diff --git a/build.gradle.kts b/build.gradle.kts index f358c8b36a..4edd557e5d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -133,7 +133,7 @@ allprojects { tasks.collectAtsFromPatches { // Uncomment while updating for a new Minecraft version - extraPatchDir.set(layout.projectDirectory.dir("patches/unapplied/server")) + // extraPatchDir.set(layout.projectDirectory.dir("patches/unapplied/server")) } tasks.register("printMinecraftVersion") { diff --git a/patches/api/Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch index fc0d7814eb..cfbbcbfcf9 100644 --- a/patches/api/Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch +++ b/patches/api/Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -0,0 +0,0 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource - * @param hurtDirection hurt direction */ + @Deprecated void setHurtDirection(float hurtDirection); + + /** diff --git a/patches/api/Expose-LivingEntity-hurt-direction.patch b/patches/api/Expose-LivingEntity-hurt-direction.patch index f97c424a50..5272e803b9 100644 --- a/patches/api/Expose-LivingEntity-hurt-direction.patch +++ b/patches/api/Expose-LivingEntity-hurt-direction.patch @@ -4,6 +4,27 @@ Date: Sun, 13 Dec 2020 05:32:12 +0200 Subject: [PATCH] Expose LivingEntity hurt direction +diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/HumanEntity.java ++++ b/src/main/java/org/bukkit/entity/HumanEntity.java +@@ -0,0 +0,0 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder + */ + public void setCooldown(@NotNull Material material, int ticks); + ++ // Paper start ++ /** ++ * Sets player hurt direction ++ * ++ * @param hurtDirection hurt direction ++ */ ++ @Override ++ void setHurtDirection(float hurtDirection); ++ // Paper end ++ + /** + * Get the sleep ticks of the player. This value may be capped. + * diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java @@ -24,7 +45,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * Sets player hurt direction + * + * @param hurtDirection hurt direction ++ * @deprecated use {@link Player#setHurtDirection(float)} + */ ++ @Deprecated + void setHurtDirection(float hurtDirection); // Paper end } diff --git a/patches/api/add-isDeeplySleeping-to-HumanEntity.patch b/patches/api/add-isDeeplySleeping-to-HumanEntity.patch index b38c9afe8e..77563c5cd7 100644 --- a/patches/api/add-isDeeplySleeping-to-HumanEntity.patch +++ b/patches/api/add-isDeeplySleeping-to-HumanEntity.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -0,0 +0,0 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder - */ - public void setCooldown(@NotNull Material material, int ticks); + void setHurtDirection(float hurtDirection); + // Paper end + // Paper start + /** diff --git a/patches/server/Add-player-health-update-API.patch b/patches/server/Add-player-health-update-API.patch index 53d3ceaaf1..ee6dcf17ea 100644 --- a/patches/server/Add-player-health-update-API.patch +++ b/patches/server/Add-player-health-update-API.patch @@ -23,17 +23,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.getHandle().queuedHealthUpdatePacket = packet; } else { @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - } // Paper end } -- -+ + + @Override + public void sendHealthUpdate() { + this.sendHealthUpdate(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel()); + } + // Paper end -+ ++ public void injectScaledMaxHealth(Collection collection, boolean force) { if (!this.scaledHealth && !force) { return; diff --git a/patches/server/AsyncTabCompleteEvent.patch b/patches/server/AsyncTabCompleteEvent.patch index d0d3aa7044..d88698d78a 100644 --- a/patches/server/AsyncTabCompleteEvent.patch +++ b/patches/server/AsyncTabCompleteEvent.patch @@ -99,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers); -+ TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers, message.startsWith("/") || forceCommand, pos != null ? io.papermc.paper.util.MCUtil.toLocation(((CraftWorld) player.getWorld()).getHandle(), new BlockPos(pos)) : null); // Paper ++ TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers, message.startsWith("/") || forceCommand, pos != null ? io.papermc.paper.util.MCUtil.toLocation(((CraftWorld) player.getWorld()).getHandle(), BlockPos.containing(pos)) : null); // Paper this.getPluginManager().callEvent(tabEvent); return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index 53bd804d79..4b558d5ec1 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -680,7 +680,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + Player player = uuid != null ? Bukkit.getPlayer(uuid) : (name != null ? Bukkit.getPlayerExact(name) : null); + if (player == null) return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name); + -+ if (Objects.equals(uuid, player.getUniqueId()) && Objects.equals(name, player.getName())) { ++ if (java.util.Objects.equals(uuid, player.getUniqueId()) && java.util.Objects.equals(name, player.getName())) { + return new com.destroystokyo.paper.profile.CraftPlayerProfile((CraftPlayer) player); + } + diff --git a/patches/server/Disable-explosion-knockback.patch b/patches/server/Disable-explosion-knockback.patch index 8aa5906067..f9aae4f2fb 100644 --- a/patches/server/Disable-explosion-knockback.patch +++ b/patches/server/Disable-explosion-knockback.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -+ boolean knockbackCancelled = level.paperConfig().environment.disableExplosionKnockback && source.isExplosion() && this instanceof net.minecraft.world.entity.player.Player; // Paper - Disable explosion knockback ++ boolean knockbackCancelled = level.paperConfig().environment.disableExplosionKnockback && source.is(DamageTypeTags.IS_EXPLOSION) && this instanceof net.minecraft.world.entity.player.Player; // Paper - Disable explosion knockback if (flag1) { if (flag) { this.level.broadcastEntityEvent(this, (byte) 29); diff --git a/patches/server/Do-not-run-raytrace-logic-for-AIR.patch b/patches/server/Do-not-run-raytrace-logic-for-AIR.patch index ace415d876..36060b34da 100644 --- a/patches/server/Do-not-run-raytrace-logic-for-AIR.patch +++ b/patches/server/Do-not-run-raytrace-logic-for-AIR.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/BlockGetter.java +++ b/src/main/java/net/minecraft/world/level/BlockGetter.java @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { - return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), new BlockPos(raytrace1.getTo())); + return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); } // Paper end + if (iblockdata.isAir()) return null; // Paper - optimise air cases diff --git a/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch b/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch index eb5a9b30ca..f303ee61a8 100644 --- a/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch +++ b/patches/server/Don-t-lookup-fluid-state-when-raytracing.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/BlockGetter.java +++ b/src/main/java/net/minecraft/world/level/BlockGetter.java @@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor { - return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), new BlockPos(raytrace1.getTo())); + return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); } // Paper end - FluidState fluid = this.getFluidState(blockposition); diff --git a/patches/server/Expose-LivingEntity-hurt-direction.patch b/patches/server/Expose-LivingEntity-hurt-direction.patch index a86f75098a..10c1339219 100644 --- a/patches/server/Expose-LivingEntity-hurt-direction.patch +++ b/patches/server/Expose-LivingEntity-hurt-direction.patch @@ -4,6 +4,37 @@ Date: Sun, 13 Dec 2020 05:32:05 +0200 Subject: [PATCH] Expose LivingEntity hurt direction +diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { + private Optional lastDeathLocation; + @Nullable + public FishingHook fishing; +- protected float hurtDir; ++ public float hurtDir; // Paper - protected -> public + // Paper start + public boolean affectsSpawning = true; + // Paper end +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +@@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { + } + } + ++ // Paper start ++ @Override ++ public void setHurtDirection(float hurtDirection) { ++ this.getHandle().hurtDir = hurtDirection; ++ } ++ // Paper end ++ + @Override + public int getSleepTicks() { + return this.getHandle().sleepCounter; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -15,12 +46,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public float getHurtDirection() { -+ return getHandle().hurtDir; ++ return this.getHandle().getHurtDir(); + } + + @Override + public void setHurtDirection(float hurtDirection) { -+ getHandle().hurtDir = hurtDirection; ++ throw new UnsupportedOperationException("Cannot set the hurt direction on a non player"); + } // Paper end } diff --git a/patches/server/Flying-Fall-Damage.patch b/patches/server/Flying-Fall-Damage.patch index 63725e4ec4..55754d38c1 100644 --- a/patches/server/Flying-Fall-Damage.patch +++ b/patches/server/Flying-Fall-Damage.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - protected float hurtDir; + public float hurtDir; // Paper - protected -> public // Paper start public boolean affectsSpawning = true; + public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; diff --git a/patches/server/MC-Dev-fixes.patch b/patches/server/MC-Dev-fixes.patch index 24766fc43c..0745a0bc4c 100644 --- a/patches/server/MC-Dev-fixes.patch +++ b/patches/server/MC-Dev-fixes.patch @@ -52,6 +52,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return registry; } +diff --git a/src/main/java/net/minecraft/network/ConnectionProtocol.java b/src/main/java/net/minecraft/network/ConnectionProtocol.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/network/ConnectionProtocol.java ++++ b/src/main/java/net/minecraft/network/ConnectionProtocol.java +@@ -0,0 +0,0 @@ public enum ConnectionProtocol implements BundlerInfo.Provider { + + public void listAllPackets(Consumer>> consumer) { + this.classToId.keySet().stream().filter((type) -> { +- return type != BundleDelimiterPacket.class; ++ return !type.equals(BundleDelimiterPacket.class); // Paper - fix of some kind + }).forEach(consumer); + this.extraClasses.forEach(consumer); + } diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java diff --git a/patches/server/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch index 1c89be3621..5d88ba2d7a 100644 --- a/patches/server/More-Enchantment-API.patch +++ b/patches/server/More-Enchantment-API.patch @@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public void setHurtDirection(float hurtDirection) { - getHandle().hurtDir = hurtDirection; + throw new UnsupportedOperationException("Cannot set the hurt direction on a non player"); } + + public static MobType fromBukkitEntityCategory(EntityCategory entityCategory) { diff --git a/patches/server/Prevent-rayTrace-from-loading-chunks.patch b/patches/server/Prevent-rayTrace-from-loading-chunks.patch index 4b99d196db..dc072eaeaa 100644 --- a/patches/server/Prevent-rayTrace-from-loading-chunks.patch +++ b/patches/server/Prevent-rayTrace-from-loading-chunks.patch @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // copied the last function parameter (listed below) + Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); + -+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), new BlockPos(raytrace1.getTo())); ++ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo())); + } + // Paper end FluidState fluid = this.getFluidState(blockposition); diff --git a/patches/server/add-isDeeplySleeping-to-HumanEntity.patch b/patches/server/add-isDeeplySleeping-to-HumanEntity.patch index e911b3d4ae..42f780666f 100644 --- a/patches/server/add-isDeeplySleeping-to-HumanEntity.patch +++ b/patches/server/add-isDeeplySleeping-to-HumanEntity.patch @@ -9,11 +9,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - } } + // Paper end + // Paper start -+ @Override + public boolean isDeeplySleeping() { + return getHandle().isSleepingLongEnough(); + }