mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
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
This commit is contained in:
parent
3477dbf4aa
commit
557ea82bf6
13 changed files with 38 additions and 72 deletions
|
@ -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
|
||||
+ /**
|
||||
|
|
|
@ -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
|
||||
+ /**
|
||||
|
|
|
@ -102,8 +102,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
public void refreshSnapshot() {
|
||||
@@ -0,0 +0,0 @@ public class CraftBlockEntityState<T extends BlockEntity> 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
|
||||
|
|
|
@ -2835,25 +2835,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
- String[] lines = new String[4];
|
||||
+ List<net.kyori.adventure.text.Component> 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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Property<?>, Comparable<?>> parsed = null;
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Bjarne Koll <git@lynxplay.dev>
|
||||
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
|
|
@ -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);
|
||||
|
|
|
@ -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<T extends BlockEntity> extends CraftBlockState implements TileState {
|
||||
+public abstract class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockState implements TileState { // Paper - revert upstream's revert of the block state changes
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit f1dd65ed73b7cca00527ff81d02ce4d27c456a37
|
||||
Subproject commit fdff0cd477bff16874060e6ebb82671955c04e78
|
|
@ -1 +1 @@
|
|||
Subproject commit 9c5d600d1395e9783a8369dc4227be2b05010107
|
||||
Subproject commit ad6d0cffbeeddfa1e16574b2df0e575b7e037c8e
|
Loading…
Reference in a new issue