From 88ca48c121d97b4c694735d2a338086b3d66ac69 Mon Sep 17 00:00:00 2001 From: Noah van der Aa Date: Wed, 8 Jun 2022 15:38:56 +0200 Subject: [PATCH] Moar 1.19 fixes (#7884) --- ...g-command-sender-which-forwards-feedb.patch | 7 +++---- patches/server/Add-GameEvent-tags.patch | 2 +- ...d-configurable-height-for-slime-spawn.patch | 2 +- .../Handle-Item-Meta-Inconsistencies.patch | 11 +---------- ...-item-frames-performance-and-bug-fixe.patch | 18 +----------------- ...ockPhysicsEvent-if-a-plugin-has-a-lis.patch | 10 +--------- ...Update-itemstack-legacy-name-and-lore.patch | 2 +- .../Use-a-Shared-Random-for-Entities.patch | 10 +--------- 8 files changed, 10 insertions(+), 52 deletions(-) diff --git a/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch b/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch index 7fb3bb2beb..e7013cf7c5 100644 --- a/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch +++ b/patches/server/API-for-creating-command-sender-which-forwards-feedb.patch @@ -21,7 +21,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import net.minecraft.commands.CommandSource; +import net.minecraft.commands.CommandSourceStack; -+import net.minecraft.network.chat.TextComponent; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.phys.Vec2; +import net.minecraft.world.phys.Vec3; @@ -89,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + overworld, + 4, + this.getName(), -+ new TextComponent(this.getName()), ++ net.minecraft.network.chat.Component.literal(this.getName()), + this.server.getServer(), + null + ); @@ -97,8 +96,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private record Source(FeedbackForwardingSender sender) implements CommandSource { + @Override -+ public void sendMessage(final net.minecraft.network.chat.Component message, final UUID sender) { -+ this.sender.sendMessage(Identity.identity(sender), PaperAdventure.asAdventure(message)); ++ public void sendSystemMessage(final net.minecraft.network.chat.Component message) { ++ this.sender.sendMessage(Identity.nil(), PaperAdventure.asAdventure(message)); + } + + @Override diff --git a/patches/server/Add-GameEvent-tags.patch b/patches/server/Add-GameEvent-tags.patch index bb121045d7..979763f4f6 100644 --- a/patches/server/Add-GameEvent-tags.patch +++ b/patches/server/Add-GameEvent-tags.patch @@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + case org.bukkit.Tag.REGISTRY_GAME_EVENTS -> { + Preconditions.checkArgument(clazz == org.bukkit.GameEvent.class, "Game Event namespace must have GameEvent type"); -+ TagKey gameEventTagKey = TagKey.create(Registry.GAME_EVENT_REGISTRY, key); ++ TagKey gameEventTagKey = TagKey.create(Registry.GAME_EVENT_REGISTRY, key); + if (Registry.GAME_EVENT.isKnownTagName(gameEventTagKey)) { + return (org.bukkit.Tag) new io.papermc.paper.CraftGameEventTag(Registry.GAME_EVENT, gameEventTagKey); + } diff --git a/patches/server/Add-configurable-height-for-slime-spawn.patch b/patches/server/Add-configurable-height-for-slime-spawn.patch index 2b7e396d81..5ada055593 100644 --- a/patches/server/Add-configurable-height-for-slime-spawn.patch +++ b/patches/server/Add-configurable-height-for-slime-spawn.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - Replace rules for Height in Swamp Biome + final double maxHeightSwamp = world.getMinecraftWorld().paperConfig.slimeMaxSpawnHeightInSwamp; + final double minHeightSwamp = world.getMinecraftWorld().paperConfig.slimeMinSpawnHeightInSwamp; -+ if (world.getBiome(pos).is(Biomes.SWAMP) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp && random.nextFloat() < 0.5F && random.nextFloat() < world.getMoonBrightness() && world.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { ++ if (world.getBiome(pos).is(net.minecraft.world.level.biome.Biomes.SWAMP) && pos.getY() > minHeightSwamp && pos.getY() < maxHeightSwamp && random.nextFloat() < 0.5F && random.nextFloat() < world.getMoonBrightness() && world.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { + // Paper end return checkMobSpawnRules(type, world, spawnReason, pos, random); } diff --git a/patches/server/Handle-Item-Meta-Inconsistencies.patch b/patches/server/Handle-Item-Meta-Inconsistencies.patch index 347ddc3ece..df92925b95 100644 --- a/patches/server/Handle-Item-Meta-Inconsistencies.patch +++ b/patches/server/Handle-Item-Meta-Inconsistencies.patch @@ -21,15 +21,6 @@ diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ import java.text.DecimalFormatSymbols; - import java.util.Collection; - import java.util.Iterator; - import java.util.List; -+import java.util.Collections; -+import java.util.Comparator; - import java.util.Locale; - import java.util.Map.Entry; - import java.util.Optional; @@ -0,0 +0,0 @@ public final class ItemStack { return this.getItem().getTooltipImage(this); } @@ -46,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + try { + //noinspection unchecked -+ list.sort((Comparator) enchantSorter); // Paper ++ list.sort((java.util.Comparator) enchantSorter); // Paper + } catch (Exception ignored) {} + } + // Paper end diff --git a/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch index a7dab2a5d9..4fb6c69d8d 100644 --- a/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch +++ b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch @@ -28,29 +28,13 @@ diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/m 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 @@ import net.minecraft.world.item.ElytraItem; - import net.minecraft.world.item.ItemCooldowns; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.item.Items; -+import net.minecraft.world.item.MapItem; // Paper - import net.minecraft.world.item.ProjectileWeaponItem; - import net.minecraft.world.item.SwordItem; - import net.minecraft.world.item.crafting.Recipe; -@@ -0,0 +0,0 @@ import net.minecraft.world.level.block.entity.SignBlockEntity; - import net.minecraft.world.level.block.entity.StructureBlockEntity; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.block.state.pattern.BlockInWorld; -+import net.minecraft.world.level.saveddata.maps.MapItemSavedData; // Paper - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.scores.PlayerTeam; @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { return null; } // CraftBukkit end + // Paper start - remove player from map on drop + if (itemstack.getItem() == Items.FILLED_MAP) { -+ MapItemSavedData worldmap = MapItem.getSavedData(itemstack, this.level); ++ net.minecraft.world.level.saveddata.maps.MapItemSavedData worldmap = net.minecraft.world.item.MapItem.getSavedData(itemstack, this.level); + if (worldmap != null) { + worldmap.tickCarriedBy(this, itemstack); + } diff --git a/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch b/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch index b387ae98d4..f59532da4a 100644 --- a/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch +++ b/patches/server/Only-process-BlockPhysicsEvent-if-a-plugin-has-a-lis.patch @@ -59,20 +59,12 @@ diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -0,0 +0,0 @@ import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.util.Mth; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; @@ -0,0 +0,0 @@ public class DoublePlantBlock extends BushBlock { protected static void preventCreativeDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) { // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { -+ if (((ServerLevel)world).hasPhysicsEvent && org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper ++ if (((net.minecraft.server.level.ServerLevel)world).hasPhysicsEvent && org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper return; } // CraftBukkit end diff --git a/patches/server/Update-itemstack-legacy-name-and-lore.patch b/patches/server/Update-itemstack-legacy-name-and-lore.patch index 0a37cafe99..fac1e68999 100644 --- a/patches/server/Update-itemstack-legacy-name-and-lore.patch +++ b/patches/server/Update-itemstack-legacy-name-and-lore.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -0,0 +0,0 @@ public final class ItemStack { - list.sort((Comparator) enchantSorter); // Paper + list.sort((java.util.Comparator) enchantSorter); // Paper } catch (Exception ignored) {} } + diff --git a/patches/server/Use-a-Shared-Random-for-Entities.patch b/patches/server/Use-a-Shared-Random-for-Entities.patch index 922f4e02b5..1ecfbbddb9 100644 --- a/patches/server/Use-a-Shared-Random-for-Entities.patch +++ b/patches/server/Use-a-Shared-Random-for-Entities.patch @@ -9,14 +9,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.entity.EntityInLevelCallback; - import net.minecraft.world.level.gameevent.DynamicGameEventListener; - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.level.levelgen.Heightmap; -+import net.minecraft.world.level.levelgen.PositionalRandomFactory; - import net.minecraft.world.level.material.Fluid; - import net.minecraft.world.level.material.FluidState; - import net.minecraft.world.level.material.PushReaction; @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; } @@ -42,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + @Override -+ public PositionalRandomFactory forkPositional() { ++ public net.minecraft.world.level.levelgen.PositionalRandomFactory forkPositional() { + return new net.minecraft.world.level.levelgen.LegacyRandomSource.LegacyPositionalRandomFactory(this.nextLong()); + } +