From 557ea82bf6742cbbeb1e00805374c3f67bacb73f Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 16 Jun 2023 03:28:31 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#9342) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: fdff0cd4 PR-869: Add Enderman#teleport and Enderman#teleportTowards dfd86ee7 Improve sendSignChange and related documentation beced2b2 PR-867: Add Player#sendBlockUpdate to send tile entity updates CraftBukkit Changes: ad6d0cffb SPIGOT-7394: Fix another issue with sendSignChange 66c5ce4c7 SPIGOT-7391: Preserve vanilla sign json where not modified by event ae3824f94 PR-1204: Add Enderman#teleport and Enderman#teleportTowards 5863a2eae Fix sendSignChange not working 4a7eadc97 PR-1201: Add Player#sendBlockUpdate to send tile entity updates 789324e30 Work around issue placing decorated pots --- patches/api/Block-Ticking-API.patch | 6 ++-- patches/api/Missing-Entity-Behavior-API.patch | 4 +-- ...-get-a-BlockState-without-a-snapshot.patch | 4 +-- patches/server/Adventure.patch | 34 +++++++++--------- patches/server/Block-Ticking-API.patch | 4 +-- patches/server/Cache-block-data-strings.patch | 2 +- ...-sendSignChange0-s-usage-of-SignText.patch | 36 ------------------- ...und-playing-for-BlockItem-ItemStacks.patch | 2 +- .../Fix-upstreams-block-state-factories.patch | 6 ++-- patches/server/Optimise-getType-calls.patch | 2 +- .../Optimize-CraftBlockData-Creation.patch | 6 ++-- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 13 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 patches/server/Fix-sendSignChange0-s-usage-of-SignText.patch diff --git a/patches/api/Block-Ticking-API.patch b/patches/api/Block-Ticking-API.patch index 8f8e6b6612..233553df59 100644 --- a/patches/api/Block-Ticking-API.patch +++ b/patches/api/Block-Ticking-API.patch @@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/block/data/BlockData.java +++ b/src/main/java/org/bukkit/block/data/BlockData.java @@ -0,0 +0,0 @@ public interface BlockData extends Cloneable { - * @param mirror the mirror - */ - void mirror(@NotNull Mirror mirror); + @NotNull + @ApiStatus.Experimental + BlockState createBlockState(); + + // Paper start - Tick API + /** diff --git a/patches/api/Missing-Entity-Behavior-API.patch b/patches/api/Missing-Entity-Behavior-API.patch index 0b833ba2b0..925cd16d23 100644 --- a/patches/api/Missing-Entity-Behavior-API.patch +++ b/patches/api/Missing-Entity-Behavior-API.patch @@ -337,9 +337,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Enderman.java +++ b/src/main/java/org/bukkit/entity/Enderman.java @@ -0,0 +0,0 @@ public interface Enderman extends Monster { - * @param blockData data to set the carried block to, or null to remove */ - public void setCarriedBlock(@Nullable BlockData blockData); + @ApiStatus.Experimental + public boolean teleportTowards(@NotNull Entity entity); + + // Paper start + /** diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index e8c2206c07..f6211c960e 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -102,8 +102,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void refreshSnapshot() { @@ -0,0 +0,0 @@ public class CraftBlockEntityState extends CraftBlockStat - public PersistentDataContainer getPersistentDataContainer() { - return this.getSnapshot().persistentDataContainer; + T vanillaTileEntitiy = (T) BlockEntity.loadStatic(CraftLocation.toBlockPosition(location), getHandle(), this.getSnapshotNBT()); + return ClientboundBlockEntityDataPacket.create(vanillaTileEntitiy); } + + // Paper start diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index d8818edb91..04a65019fd 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2835,25 +2835,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - String[] lines = new String[4]; + List lines = new java.util.ArrayList<>(); // Paper - adventure - for (int j = 0; j < list.size(); ++j) { -- lines[j] = CraftChatMessage.fromComponent(signtext.getMessage(j, entityhuman.isTextFilteringEnabled())); -+ lines.add(io.papermc.paper.adventure.PaperAdventure.asAdventure(signtext.getMessage(j, entityhuman.isTextFilteringEnabled()))); // Paper - adventure + for (int i = 0; i < list.size(); ++i) { +- lines[i] = CraftChatMessage.fromComponent(signtext.getMessage(i, entityhuman.isTextFilteringEnabled())); ++ lines.add(io.papermc.paper.adventure.PaperAdventure.asAdventure(signtext.getMessage(i, entityhuman.isTextFilteringEnabled()))); // Paper - Adventure } - SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, lines, (front) ? Side.FRONT : Side.BACK); +- SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, lines.clone(), (front) ? Side.FRONT : Side.BACK); ++ SignChangeEvent event = new SignChangeEvent(CraftBlock.at(this.level, this.worldPosition), player, new java.util.ArrayList<>(lines), (front) ? Side.FRONT : Side.BACK); // Paper - Adventure entityhuman.level().getCraftServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { -- Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); -- for (int j = 0; j < components.length; j++) { -- signtext = signtext.setMessage(j, components[j]); -+ // Paper start - adventure -+ for (int j = 0; j < 4; j++) { -+ signtext = signtext.setMessage(j, io.papermc.paper.adventure.PaperAdventure.asVanilla(lines.get(j))); -+ // Paper end - adventure + if (event.isCancelled()) { + return originalText; + } + +- Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.getLines()); ++ Component[] components = org.bukkit.craftbukkit.block.CraftSign.sanitizeLines(event.lines()); // Paper - Adventure + for (int i = 0; i < components.length; i++) { +- if (!Objects.equals(lines[i], event.getLine(i))) { ++ if (!Objects.equals(lines.get(i), event.line(i))) { // Paper - Adventure + signtext = signtext.setMessage(i, components[i]); } - } else { - signtext = originalText; + } diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java @@ -3806,10 +3808,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private void sendSignChange0(Component[] components, Location loc, DyeColor dyeColor, boolean hasGlowingText) { SignBlockEntity sign = new SignBlockEntity(CraftLocation.toBlockPosition(loc), Blocks.OAK_SIGN.defaultBlockState()); SignText text = sign.getFrontText(); - text.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); + text = text.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - text.setMessage(i, components[i]); } + sign.setText(text, true); - this.getHandle().connection.send(sign.getUpdatePacket()); + getHandle().connection.send(sign.getUpdatePacket()); diff --git a/patches/server/Block-Ticking-API.patch b/patches/server/Block-Ticking-API.patch index 980f95a177..26779691a1 100644 --- a/patches/server/Block-Ticking-API.patch +++ b/patches/server/Block-Ticking-API.patch @@ -35,8 +35,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -0,0 +0,0 @@ public class CraftBlockData implements BlockData { - public void mirror(Mirror mirror) { - this.state = this.state.mirror(net.minecraft.world.level.block.Mirror.valueOf(mirror.name())); + public BlockState createBlockState() { + return CraftBlockStates.getBlockState(this.state, null); } + + // Paper start - Block tick API diff --git a/patches/server/Cache-block-data-strings.patch b/patches/server/Cache-block-data-strings.patch index cd5b7c2996..0604aa6c18 100644 --- a/patches/server/Cache-block-data-strings.patch +++ b/patches/server/Cache-block-data-strings.patch @@ -57,6 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static CraftBlockData createNewData(Material material, String data) { + // Paper end - cache block data strings - BlockState blockData; + net.minecraft.world.level.block.state.BlockState blockData; Block block = CraftMagicNumbers.getBlock(material); Map, Comparable> parsed = null; diff --git a/patches/server/Fix-sendSignChange0-s-usage-of-SignText.patch b/patches/server/Fix-sendSignChange0-s-usage-of-SignText.patch deleted file mode 100644 index 8b0f92f0a9..0000000000 --- a/patches/server/Fix-sendSignChange0-s-usage-of-SignText.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Bjarne Koll -Date: Sun, 11 Jun 2023 18:45:10 +0200 -Subject: [PATCH] Fix sendSignChange0's usage of SignText - -Minecraft 1.20 introduced the SignText class that holds onto the text of -a single side of a minecraft sign. -This type is immutable and any methods on it produce an updated, new -instance of the class rather than mutating the called upon instance. - -Spigot does not respect this change as it does not re-assign the -constructed sign text to the instance nor does it feed back said -instance to the virtual sign block entity. - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - private void sendSignChange0(Component[] components, Location loc, DyeColor dyeColor, boolean hasGlowingText) { - SignBlockEntity sign = new SignBlockEntity(CraftLocation.toBlockPosition(loc), Blocks.OAK_SIGN.defaultBlockState()); - SignText text = sign.getFrontText(); -- text.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); -- text.setHasGlowingText(hasGlowingText); -+ // Paper start - fix sign change using immutable SignText type -+ text = text.setColor(net.minecraft.world.item.DyeColor.byId(dyeColor.getWoolData())); -+ text = text.setHasGlowingText(hasGlowingText); - for (int i = 0; i < components.length; i++) { -- text.setMessage(i, components[i]); -+ text = text.setMessage(i, components[i]); - } -+ sign.setText(text, true); -+ // Paper end - fix sign change using immutable SignText type - - getHandle().connection.send(sign.getUpdatePacket()); - // Paper end diff --git a/patches/server/Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch b/patches/server/Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch index 13cf01eaac..77d52c26dc 100644 --- a/patches/server/Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch +++ b/patches/server/Fix-spigot-sound-playing-for-BlockItem-ItemStacks.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // SPIGOT-1288 - play sound stripped from ItemBlock if (this.item instanceof BlockItem) { -- SoundType soundeffecttype = ((BlockItem) this.item).getBlock().getSoundType(null); +- SoundType soundeffecttype = ((BlockItem) this.item).getBlock().defaultBlockState().getSoundType(); // TODO: not strictly correct, however currently only affects decorated pots + // Paper start + BlockPos position = new net.minecraft.world.item.context.BlockPlaceContext(itemactioncontext).getClickedPos(); + net.minecraft.world.level.block.state.BlockState blockData = world.getBlockState(position); diff --git a/patches/server/Fix-upstreams-block-state-factories.patch b/patches/server/Fix-upstreams-block-state-factories.patch index 34da830b97..3dc5505053 100644 --- a/patches/server/Fix-upstreams-block-state-factories.patch +++ b/patches/server/Fix-upstreams-block-state-factories.patch @@ -29,9 +29,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -@@ -0,0 +0,0 @@ import org.bukkit.World; - import org.bukkit.block.TileState; - import org.bukkit.persistence.PersistentDataContainer; +@@ -0,0 +0,0 @@ import org.bukkit.persistence.PersistentDataContainer; + import org.jetbrains.annotations.NotNull; + import org.jetbrains.annotations.Nullable; -public class CraftBlockEntityState extends CraftBlockState implements TileState { +public abstract class CraftBlockEntityState extends CraftBlockState implements TileState { // Paper - revert upstream's revert of the block state changes diff --git a/patches/server/Optimise-getType-calls.patch b/patches/server/Optimise-getType-calls.patch index 5e5746d8dd..d99d13ba42 100644 --- a/patches/server/Optimise-getType-calls.patch +++ b/patches/server/Optimise-getType-calls.patch @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.state.getBukkitMaterial(); // Paper - optimise getType calls } - public BlockState getState() { + public net.minecraft.world.level.block.state.BlockState getState() { diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CraftChunkData.java diff --git a/patches/server/Optimize-CraftBlockData-Creation.patch b/patches/server/Optimize-CraftBlockData-Creation.patch index 990e30b7c2..945fc3f725 100644 --- a/patches/server/Optimize-CraftBlockData-Creation.patch +++ b/patches/server/Optimize-CraftBlockData-Creation.patch @@ -36,13 +36,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - optimize creating BlockData to not need a map lookup + static { + // Initialize cached data for all IBlockData instances after registration -+ Block.BLOCK_STATE_REGISTRY.iterator().forEachRemaining(BlockState::createCraftBlockData); ++ Block.BLOCK_STATE_REGISTRY.iterator().forEachRemaining(net.minecraft.world.level.block.state.BlockState::createCraftBlockData); + } - public static CraftBlockData fromData(BlockState data) { + public static CraftBlockData fromData(net.minecraft.world.level.block.state.BlockState data) { + return data.createCraftBlockData(); + } + -+ public static CraftBlockData createData(BlockState data) { ++ public static CraftBlockData createData(net.minecraft.world.level.block.state.BlockState data) { + // Paper end return CraftBlockData.MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data); } diff --git a/work/Bukkit b/work/Bukkit index f1dd65ed73..fdff0cd477 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit f1dd65ed73b7cca00527ff81d02ce4d27c456a37 +Subproject commit fdff0cd477bff16874060e6ebb82671955c04e78 diff --git a/work/CraftBukkit b/work/CraftBukkit index 9c5d600d13..ad6d0cffbe 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 9c5d600d1395e9783a8369dc4227be2b05010107 +Subproject commit ad6d0cffbeeddfa1e16574b2df0e575b7e037c8e