diff --git a/patches/unapplied/server/Add-PlayerShieldDisableEvent.patch b/patches/server/Add-PlayerShieldDisableEvent.patch similarity index 75% rename from patches/unapplied/server/Add-PlayerShieldDisableEvent.patch rename to patches/server/Add-PlayerShieldDisableEvent.patch index 180adfc264..74b7a27397 100644 --- a/patches/unapplied/server/Add-PlayerShieldDisableEvent.patch +++ b/patches/server/Add-PlayerShieldDisableEvent.patch @@ -20,11 +20,11 @@ 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 void blockUsingShield(LivingEntity attacker) { - super.blockUsingShield(attacker); - if (attacker.canDisableShield()) { -- this.disableShield(); -+ this.disableShield(attacker); // Paper - Add PlayerShieldDisableEvent + ItemStack itemstack = this.getItemBlockingWith(); + + if (attacker.canDisableShield() && itemstack != null) { +- this.disableShield(itemstack); ++ this.disableShield(itemstack, attacker); // Paper - Add PlayerShieldDisableEvent } } @@ -33,19 +33,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerShieldDisableEvent - public void disableShield() { -- this.getCooldowns().addCooldown(Items.SHIELD, 100); + public void disableShield(ItemStack shield) { +- this.getCooldowns().addCooldown(shield, 100); + // Paper start - Add PlayerShieldDisableEvent -+ this.disableShield(null); ++ this.disableShield(shield, null); + } -+ public void disableShield(@Nullable LivingEntity attacker) { ++ public void disableShield(ItemStack shield, @Nullable LivingEntity attacker) { + final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null; + if (finalAttacker != null) { + final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100); + if (!shieldDisableEvent.callEvent()) return; -+ this.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown()); ++ this.getCooldowns().addCooldown(shield, shieldDisableEvent.getCooldown()); + } else { -+ this.getCooldowns().addCooldown(Items.SHIELD, 100); ++ this.getCooldowns().addCooldown(shield, 100); + } + // Paper end - Add PlayerShieldDisableEvent this.stopUsingItem(); diff --git a/patches/unapplied/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch b/patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch similarity index 100% rename from patches/unapplied/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch rename to patches/server/Add-PlayerTradeEvent-and-PlayerPurchaseEvent.patch diff --git a/patches/unapplied/server/Add-ShulkerDuplicateEvent.patch b/patches/server/Add-ShulkerDuplicateEvent.patch similarity index 100% rename from patches/unapplied/server/Add-ShulkerDuplicateEvent.patch rename to patches/server/Add-ShulkerDuplicateEvent.patch diff --git a/patches/unapplied/server/Add-api-for-spawn-egg-texture-colors.patch b/patches/server/Add-api-for-spawn-egg-texture-colors.patch similarity index 100% rename from patches/unapplied/server/Add-api-for-spawn-egg-texture-colors.patch rename to patches/server/Add-api-for-spawn-egg-texture-colors.patch diff --git a/patches/unapplied/server/Expose-LootTable-of-DecoratedPot.patch b/patches/server/Expose-LootTable-of-DecoratedPot.patch similarity index 100% rename from patches/unapplied/server/Expose-LootTable-of-DecoratedPot.patch rename to patches/server/Expose-LootTable-of-DecoratedPot.patch diff --git a/patches/unapplied/server/Fixup-NamespacedKey-handling.patch b/patches/server/Fixup-NamespacedKey-handling.patch similarity index 100% rename from patches/unapplied/server/Fixup-NamespacedKey-handling.patch rename to patches/server/Fixup-NamespacedKey-handling.patch diff --git a/patches/unapplied/server/Properly-handle-experience-dropping-on-block-break.patch b/patches/server/Properly-handle-experience-dropping-on-block-break.patch similarity index 100% rename from patches/unapplied/server/Properly-handle-experience-dropping-on-block-break.patch rename to patches/server/Properly-handle-experience-dropping-on-block-break.patch diff --git a/patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch b/patches/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch similarity index 74% rename from patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch rename to patches/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch index 19364e547a..dfebc6b050 100644 --- a/patches/unapplied/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch +++ b/patches/server/Reduce-allocation-of-Vec3D-by-entity-tracker.patch @@ -43,17 +43,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -0,0 +0,0 @@ public class ServerEntity { - i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F); - j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F); - Vec3 vec3d = this.entity.trackingPosition(); -- boolean flag1 = this.positionCodec.delta(vec3d).lengthSqr() >= 7.62939453125E-6D; -+ // Paper start - reduce allocation of Vec3D here -+ Vec3 base = this.positionCodec.base; -+ double vec3d_dx = vec3d.x - base.x; -+ double vec3d_dy = vec3d.y - base.y; -+ double vec3d_dz = vec3d.z - base.z; -+ boolean flag1 = (vec3d_dx * vec3d_dx + vec3d_dy * vec3d_dy + vec3d_dz * vec3d_dz) >= 7.62939453125E-6D; -+ // Paper end - reduce allocation of Vec3D here - Packet packet1 = null; - boolean flag2 = flag1 || this.tickCount % 60 == 0; - boolean flag3 = Math.abs(i - this.lastSentYRot) >= 1 || Math.abs(j - this.lastSentXRot) >= 1; + + ++this.teleportDelay; + Vec3 vec3d = this.entity.trackingPosition(); +- boolean flag1 = this.positionCodec.delta(vec3d).lengthSqr() >= 7.62939453125E-6D; ++ // Paper start - reduce allocation of Vec3D here ++ Vec3 base = this.positionCodec.base; ++ double vec3d_dx = vec3d.x - base.x; ++ double vec3d_dy = vec3d.y - base.y; ++ double vec3d_dz = vec3d.z - base.z; ++ boolean flag1 = (vec3d_dx * vec3d_dx + vec3d_dy * vec3d_dy + vec3d_dz * vec3d_dz) >= 7.62939453125E-6D; ++ // Paper end - reduce allocation of Vec3D here + Packet packet1 = null; + boolean flag2 = flag1 || this.tickCount % 60 == 0; + boolean flag3 = false; diff --git a/patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch similarity index 92% rename from patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch rename to patches/server/Validate-ResourceLocation-in-NBT-reading.patch index cefddf1366..dc34efcc70 100644 --- a/patches/unapplied/server/Validate-ResourceLocation-in-NBT-reading.patch +++ b/patches/server/Validate-ResourceLocation-in-NBT-reading.patch @@ -110,8 +110,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.leashData = this.readLeashData(nbt); this.setLeftHanded(nbt.getBoolean("LeftHanded")); if (nbt.contains("DeathLootTable", 8)) { -- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable"))); -+ this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("DeathLootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation +- this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("DeathLootTable")))); ++ this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation this.lootTableSeed = nbt.getLong("DeathLootTableSeed"); } @@ -133,11 +133,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java @@ -0,0 +0,0 @@ public interface ContainerEntity extends Container, MenuProvider { - default void readChestVehicleSaveData(CompoundTag nbt, HolderLookup.Provider registriesLookup) { + default void readChestVehicleSaveData(CompoundTag nbt, HolderLookup.Provider registries) { this.clearItemStacks(); if (nbt.contains("LootTable", 8)) { -- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); -+ this.setLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation +- this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(nbt.getString("LootTable")))); ++ this.setContainerLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(nbt.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation // Paper start - LootTable API if (this.getLootTable() != null) { this.lootableData().loadNbt(nbt); @@ -149,13 +149,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 while (iterator.hasNext()) { String s = (String) iterator.next(); -- this.recipesUsed.put(ResourceLocation.parse(s), nbttagcompound1.getInt(s)); +- this.recipesUsed.put(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(s)), nbttagcompound1.getInt(s)); + // Paper start - Validate ResourceLocation + final ResourceLocation resourceLocation = ResourceLocation.tryParse(s); + if (resourceLocation != null) { -+ this.recipesUsed.put(resourceLocation, nbttagcompound1.getInt(s)); ++ this.recipesUsed.put(ResourceKey.create(Registries.RECIPE, resourceLocation), nbttagcompound1.getInt(s)); + } -+ // Paper end - Validate ResourceLocation } // Paper start - cook speed multiplier API