Compare commits

...

9 commits

Author SHA1 Message Date
Spottedleaf
216b704363 Replace all RegionFile operations with SectorFile
Please see https://github.com/PaperMC/SectorTool
for details on the new format and how to use the tool to
convert the world or how to revert the conversion.

This patch includes conversion logic to convert RegionFiles to
SectorFile on demand. If a SectorFile does not exist, it will
attempt to copy chunk/entity/poi data from existing RegionFiles.

Included in this test patch is logic to dump SectorFile operation
tracing to file `sectorfile.tracer` in the root dir of a world. The
file is not compressed, and it is appended to only. As a result of
the lack of compression, when sending the file back for analysis
please compress it to reduce size usage.

This tracing will be useful for later tests to perform parameter
scanning on some of the parameters of SectorFile:
1. The section shift
2. The sector size
3. SectorFile cache size
2024-06-22 15:03:37 -07:00
willkroboth
e41d44fa87
Fix hasFiredAsync parameter when AsyncPlayerSendCommandsEvent is called (#10896) 2024-06-17 21:16:55 +02:00
Spottedleaf
122c9d3843
Fix NPE in V3808
The armor items may not exist, so we need to null check it.
2024-06-17 13:47:24 +02:00
Bjarne Koll
fe7043e19e
Configurable damage tick when blocking with shield (#10877)
A long standing bug in spigot and its derivatives was the fact that
players taking damage while blocking with a shield would not receive
invulnerability, while they do in vanilla.

This enabled the pvp technique of disabling a shield and immediately
attacking again to knock a player into the air.
While upstream fixed this and properly aligned itself with vanilla
damage logic (in this specific case) changing such long standing
behaviour has some downsides.

To allow players used to this specific bug to still use it, this patch
introduces a configuration option to re-introduce said bug.
As there is no easy way to *only* re-add this bug, the option is found
in the unsupported section as it may introduce other damage related
disparity from vanilla.
2024-06-15 23:09:34 +02:00
Aya
43484eb340
Add back RecipeIterator fixes patch (#10887) 2024-06-15 21:49:08 +02:00
Ghast
af7f0c49f3
Fix ItemMeta#removeEnchantments (#10886) 2024-06-15 17:26:55 +02:00
Jake Potrebic
3889ffb436
Fix Player#sendBlockUpdate (#10855) 2024-06-15 17:05:21 +02:00
Jake Potrebic
5914f600f4
Update AbstractArrow item method implementations for 1.20.6 (#10885) 2024-06-15 16:40:29 +02:00
Nassim Jahnke
9e7f6c3f7e
Fixup and deprecate player profiles in ping event (#10880) 2024-06-14 13:41:20 +02:00
15 changed files with 5538 additions and 56 deletions

View file

@ -8,20 +8,28 @@ and allows full control of the response sent to the client.
diff --git a/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d84302d697267
index 0000000000000000000000000000000000000000..acff2ff570f8419ffa4dfefe890795c63d75325d
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/event/server/PaperServerListPingEvent.java
@@ -0,0 +1,338 @@
@@ -0,0 +1,502 @@
+package com.destroystokyo.paper.event.server;
+
+import static java.util.Objects.requireNonNull;
+
+import com.destroystokyo.paper.network.StatusClient;
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import com.google.common.base.Preconditions;
+import io.papermc.paper.util.TransformingRandomAccessList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.server.ServerListPingEvent;
+import org.bukkit.profile.PlayerTextures;
+import org.bukkit.util.CachedServerIcon;
+
+import java.util.ArrayList;
@ -44,7 +52,12 @@ index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d8430
+
+ private int numPlayers;
+ private boolean hidePlayers;
+ @NotNull private final List<PlayerProfile> playerSample = new ArrayList<>();
+ @NotNull private final List<ListedPlayerInfo> listedPlayers = new ArrayList<>();
+ @NotNull private final TransformingRandomAccessList<ListedPlayerInfo, PlayerProfile> playerSample = new TransformingRandomAccessList<>(
+ listedPlayers,
+ info -> new UncheckedPlayerProfile(info.name(), info.id()),
+ profile -> new ListedPlayerInfo(profile.getName(), profile.getId())
+ );
+
+ @NotNull private String version;
+ private int protocolVersion;
@ -163,7 +176,7 @@ index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d8430
+ }
+
+ /**
+ * Returns a mutable list of {@link PlayerProfile} that will be displayed
+ * Returns a mutable list of {@link ListedPlayerInfo} that will be displayed
+ * as online players on the client.
+ * <p>
+ * The Vanilla Minecraft client will display them when hovering the
@ -172,6 +185,22 @@ index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d8430
+ * @return The mutable player sample list
+ */
+ @NotNull
+ public List<ListedPlayerInfo> getListedPlayers() {
+ return this.listedPlayers;
+ }
+
+ /**
+ * Returns a mutable list of {@link PlayerProfile} that will be displayed
+ * as online players on the client.
+ * <p>
+ * The Vanilla Minecraft client will display them when hovering the
+ * player count with the mouse.
+ *
+ * @return The mutable player sample list
+ * @deprecated Use {@link #getListedPlayers()}, as this does not contain real player profiles
+ */
+ @NotNull
+ @Deprecated(forRemoval = true, since = "1.20.6")
+ public List<PlayerProfile> getPlayerSample() {
+ return this.playerSample;
+ }
@ -276,9 +305,11 @@ index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d8430
+ * <li>Remove all entries from {@link #getPlayerSample()} that refer to
+ * the removed player (based on their {@link UUID}).</li>
+ * </ul>
+ * @deprecated the Iterable interface will be removed at some point
+ */
+ @NotNull
+ @Override
+ @Deprecated(forRemoval = true, since = "1.20.6")
+ public Iterator<Player> iterator() {
+ if (this.players == null) {
+ this.players = getOnlinePlayers();
@ -349,6 +380,139 @@ index 0000000000000000000000000000000000000000..0bb6fdbdd05ae6a8fb413e0f6b8d8430
+ }
+ }
+
+ /**
+ * Represents a player that will be displayed in the player sample of the server list.
+ *
+ * @param name name of the listed player
+ * @param id UUID of the listed player
+ */
+ public record ListedPlayerInfo(@NotNull String name, @NotNull UUID id) {
+ }
+
+ @ApiStatus.Internal
+ private static final class UncheckedPlayerProfile implements PlayerProfile {
+ private String name;
+ private UUID uuid;
+
+ public UncheckedPlayerProfile(final @NotNull String name, final @NotNull UUID uuid) {
+ Preconditions.checkNotNull(name, "name cannot be null");
+ Preconditions.checkNotNull(uuid, "uuid cannot be null");
+ this.name = name;
+ this.uuid = uuid;
+ }
+
+ @Override
+ public @Nullable UUID getUniqueId() {
+ return uuid;
+ }
+
+ @Override
+ public @Nullable String getName() {
+ return name;
+ }
+
+ @Override
+ public @NotNull String setName(@Nullable final String name) {
+ Preconditions.checkNotNull(name, "name cannot be null");
+ return this.name = name;
+ }
+
+ @Override
+ public @Nullable UUID getId() {
+ return uuid;
+ }
+
+ @Override
+ public @Nullable UUID setId(@Nullable final UUID uuid) {
+ Preconditions.checkNotNull(uuid, "uuid cannot be null");
+ return this.uuid = uuid;
+ }
+
+ @Override
+ public @NotNull PlayerTextures getTextures() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setTextures(@Nullable final PlayerTextures textures) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull Set<ProfileProperty> getProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean hasProperty(@Nullable final String property) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setProperty(@NotNull final ProfileProperty property) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setProperties(@NotNull final Collection<ProfileProperty> properties) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeProperty(@Nullable final String property) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clearProperties() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isComplete() {
+ return false;
+ }
+
+ @Override
+ public boolean completeFromCache() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean completeFromCache(final boolean onlineMode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean completeFromCache(final boolean lookupUUID, final boolean onlineMode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean complete(final boolean textures) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean complete(final boolean textures, final boolean onlineMode) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull CompletableFuture<PlayerProfile> update() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public org.bukkit.profile.@NotNull PlayerProfile clone() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NotNull Map<String, Object> serialize() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/StatusClient.java b/src/main/java/com/destroystokyo/paper/network/StatusClient.java
new file mode 100644
@ -369,6 +533,22 @@ index 0000000000000000000000000000000000000000..517d15238ed117f38bbd39f570874014
+public interface StatusClient extends NetworkClient {
+
+}
diff --git a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
index 72ebc29db42d08d1d0361dba462fc8a573fbf918..d351f62971f8f1317b3fc92f8b1d446e48149c3a 100644
--- a/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
+++ b/src/main/java/org/bukkit/event/server/ServerListPingEvent.java
@@ -248,9 +248,11 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
*
* @throws UnsupportedOperationException if the caller of this event does
* not support removing players
+ * @deprecated the Iterable interface will be removed at some point
*/
@NotNull
@Override
+ @Deprecated(forRemoval = true, since = "1.20.6")
public Iterator<Player> iterator() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
diff --git a/src/main/java/org/bukkit/util/CachedServerIcon.java b/src/main/java/org/bukkit/util/CachedServerIcon.java
index 9a7768d41270714d4a1c89b4dcb436cc66f57545..b74b21a1ac7798e847b6d34ff45026e1c9cfed14 100644
--- a/src/main/java/org/bukkit/util/CachedServerIcon.java

View file

@ -7,7 +7,7 @@ Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java
index 839e5b7df49f42b5fec7729997bef3370ba36d80..b36298679d6d52d09fe4bb8e52e19e18f6df742a 100644
index 839e5b7df49f42b5fec7729997bef3370ba36d80..07b7d3ddd6c8400c39578f8c09df13dc2411be1d 100644
--- a/src/main/java/org/bukkit/entity/AbstractArrow.java
+++ b/src/main/java/org/bukkit/entity/AbstractArrow.java
@@ -130,17 +130,21 @@ public interface AbstractArrow extends Projectile {
@ -25,26 +25,34 @@ index 839e5b7df49f42b5fec7729997bef3370ba36d80..b36298679d6d52d09fe4bb8e52e19e18
* Sets the ItemStack which will be picked up from this arrow.
*
* @param item ItemStack set to be picked up
+ * @deprecated until 1.20.5 when the behavior is more defined
+ * @deprecated use {@link #getItemStack()}
*/
@ApiStatus.Experimental
+ @Deprecated // Paper - remove in 1.20.5
+ @Deprecated(forRemoval = true, since = "1.20.4") // Paper
public void setItem(@NotNull ItemStack item);
/**
@@ -194,4 +198,44 @@ public interface AbstractArrow extends Projectile {
@@ -194,4 +198,52 @@ public interface AbstractArrow extends Projectile {
CREATIVE_ONLY;
}
// Paper end
+
+ // Paper start - more projectile API
+ /**
+ * Gets the ItemStack for this arrow.
+ * Gets the {@link ItemStack} for this arrow. This stack is used
+ * for both visuals on the arrow and the stack that could be picked up.
+ *
+ * @return The ItemStack, as if a player picked up the arrow
+ */
+ @NotNull
+ org.bukkit.inventory.ItemStack getItemStack();
+ @NotNull ItemStack getItemStack();
+
+ /**
+ * Sets the {@link ItemStack} for this arrow. This stack is used for both
+ * visuals on the arrow and the stack that could be picked up.
+ *
+ * @param stack the arrow stack
+ */
+ void setItemStack(@NotNull ItemStack stack);
+
+ /**
+ * Sets the amount of ticks this arrow has been alive in the world

View file

@ -487,10 +487,10 @@ index 0000000000000000000000000000000000000000..7684e71f802f3d19e5340713b45cc848
+}
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..892351c3b6397b3cde6a31a6594c0e16bbe1252b
index 0000000000000000000000000000000000000000..7045040681e639f36fefcf2735f67367d5e3cbc4
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -0,0 +1,311 @@
@@ -0,0 +1,313 @@
+package io.papermc.paper.configuration;
+
+import co.aikar.timings.MinecraftTimings;
@ -651,6 +651,8 @@ index 0000000000000000000000000000000000000000..892351c3b6397b3cde6a31a6594c0e16
+ public boolean performUsernameValidation = true;
+ @Comment("This setting controls if players should be able to create headless pistons.")
+ public boolean allowHeadlessPistons = false;
+ @Comment("This setting controls if the vanilla damage tick should be skipped if damage was blocked via a shield.")
+ public boolean skipVanillaDamageTickWhenShieldBlocked = false;
+ @Comment("This setting controls what compression format is used for region files.")
+ public CompressionFormat compressionFormat = CompressionFormat.ZLIB;
+

View file

@ -60,23 +60,18 @@ index 0000000000000000000000000000000000000000..d926ad804355ee2fdc5910b2505e8671
+}
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..6b0bdc266109cdfb874f08bf74323603921d2260
index 0000000000000000000000000000000000000000..aa2aff62c873ba85b0cbced5382398c858420e59
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
@@ -0,0 +1,116 @@
@@ -0,0 +1,97 @@
+package com.destroystokyo.paper.network;
+
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Strings;
+import com.mojang.authlib.GameProfile;
+import io.papermc.paper.adventure.AdventureComponent;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import javax.annotation.Nonnull;
+import net.minecraft.network.Connection;
+import net.minecraft.network.chat.Component;
@ -87,9 +82,6 @@ index 0000000000000000000000000000000000000000..6b0bdc266109cdfb874f08bf74323603
+
+public final class StandardPaperServerListPingEventImpl extends PaperServerListPingEventImpl {
+
+ // private static final GameProfile[] EMPTY_PROFILES = new GameProfile[0];
+ private static final UUID FAKE_UUID = new UUID(0, 0);
+
+ private List<GameProfile> originalSample;
+
+ private StandardPaperServerListPingEventImpl(MinecraftServer server, Connection networkManager, ServerStatus ping) {
@ -99,12 +91,12 @@ index 0000000000000000000000000000000000000000..6b0bdc266109cdfb874f08bf74323603
+
+ @Nonnull
+ @Override
+ public List<PlayerProfile> getPlayerSample() {
+ List<PlayerProfile> sample = super.getPlayerSample();
+ public List<ListedPlayerInfo> getListedPlayers() {
+ List<ListedPlayerInfo> sample = super.getListedPlayers();
+
+ if (this.originalSample != null) {
+ for (GameProfile profile : this.originalSample) {
+ sample.add(CraftPlayerProfile.asBukkitCopy(profile));
+ sample.add(new ListedPlayerInfo(profile.getName(), profile.getId()));
+ }
+ this.originalSample = null;
+ }
@ -117,25 +109,14 @@ index 0000000000000000000000000000000000000000..6b0bdc266109cdfb874f08bf74323603
+ return this.originalSample;
+ }
+
+ List<PlayerProfile> entries = super.getPlayerSample();
+ List<ListedPlayerInfo> entries = super.getListedPlayers();
+ if (entries.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ final List<GameProfile> profiles = new ArrayList<>();
+ for (PlayerProfile profile : entries) {
+ /*
+ * Avoid null UUIDs/names since that will make the response invalid
+ * on the client.
+ * Instead, fall back to a fake/empty UUID and an empty string as name.
+ * This can be used to create custom lines in the player list that do not
+ * refer to a specific player.
+ */
+ if (profile.getId() != null && profile.getName() != null) {
+ profiles.add(CraftPlayerProfile.asAuthlib(profile));
+ } else {
+ profiles.add(new GameProfile(MoreObjects.firstNonNull(profile.getId(), FAKE_UUID), Strings.nullToEmpty(profile.getName())));
+ }
+ for (ListedPlayerInfo playerInfo : entries) {
+ profiles.add(new GameProfile(playerInfo.id(), playerInfo.name()));
+ }
+ return profiles;
+ }
@ -181,7 +162,7 @@ index 0000000000000000000000000000000000000000..6b0bdc266109cdfb874f08bf74323603
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 260e364c91d8c3d774681f9f0ecba63df5dd3f5c..2ae6eb3a05bd0574143699e1286f63f5fd699f30 100644
index 1fdd088f0bb6606f2a9a482d276aa3e9261be012..b6c5656665e492a7fdec0ae15545ecbabf585336 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -3,6 +3,9 @@ package net.minecraft.server;

View file

@ -87,7 +87,7 @@ index d9fc3c25bef251df6a53ee47ec224b07240a931c..2a22827f44dd0d524c22264447959a69
public boolean hasPermission(int level) {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index b754c0b3e2cd878fca5f702daca64f837ec83451..f15c388434a0a501f86868de35cc138756975027 100644
index b754c0b3e2cd878fca5f702daca64f837ec83451..b7c297fa41bb7d3c6a8e82520ec1a84e10f93014 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -488,6 +488,7 @@ public class Commands {
@ -102,7 +102,7 @@ index b754c0b3e2cd878fca5f702daca64f837ec83451..f15c388434a0a501f86868de35cc1387
private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
// Paper end - Perf: Async command map building
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API
+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, true).callEvent(); // Paper - Brigadier API
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
event.getPlayer().getServer().getPluginManager().callEvent(event);

View file

@ -12,6 +12,7 @@ public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ
public net.minecraft.world.entity.projectile.ShulkerBullet currentMoveDirection
public net.minecraft.world.entity.projectile.ShulkerBullet flightSteps
public net.minecraft.world.entity.projectile.AbstractArrow soundEvent
public net/minecraft/world/entity/projectile/AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V
public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage
public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR
public net.minecraft.world.entity.projectile.Projectile hasBeenShot
@ -175,7 +176,7 @@ index 91c2d0b40d3fca86938cd454e1415a4eea3df7c7..de4fb2654c7895cfd83ad694455ee56c
+ // Paper end - More projectile API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..0cc1cdf91deb07ebb437ef5e61d149b2c109877f 100644
index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..656e1fc4321a804aa79a08bca8974637d4ffdb1b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractArrow.java
@@ -60,20 +60,7 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
@ -200,15 +201,21 @@ index 98f46fadd60ea688fefa8d83dbd6fe9b61b6a96f..0cc1cdf91deb07ebb437ef5e61d149b2
@Override
public boolean isInBlock() {
@@ -140,4 +127,31 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
@@ -140,4 +127,37 @@ public class CraftAbstractArrow extends AbstractProjectile implements AbstractAr
public String toString() {
return "CraftArrow";
}
+
+ // Paper start
+ @Override
+ public org.bukkit.craftbukkit.inventory.CraftItemStack getItemStack() {
+ return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.getHandle().getPickupItem());
+ public CraftItemStack getItemStack() {
+ return CraftItemStack.asCraftMirror(this.getHandle().getPickupItem());
+ }
+
+ @Override
+ public void setItemStack(final ItemStack stack) {
+ Preconditions.checkArgument(stack != null, "ItemStack cannot be null");
+ this.getHandle().setPickupItemStack(CraftItemStack.asNMSCopy(stack));
+ }
+
+ @Override

View file

@ -22,10 +22,10 @@ is actually processed, this is honestly really just exposed for the misnomers or
who just wanna ensure that this won't grow over a specific size if chat gets stupidly active
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 892351c3b6397b3cde6a31a6594c0e16bbe1252b..ab5089781b8866cd6ad1b9570634ba84d936cfe7 100644
index 7045040681e639f36fefcf2735f67367d5e3cbc4..cc847dce0116b8260790b890b1d5452c280e186c 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -285,7 +285,18 @@ public class GlobalConfiguration extends ConfigurationPart {
@@ -287,7 +287,18 @@ public class GlobalConfiguration extends ConfigurationPart {
@PostProcess
private void postProcess() {

View file

@ -22083,7 +22083,7 @@ index 0000000000000000000000000000000000000000..a76916cdb7cf91b8ba5461524472b3e4
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3808.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3808.java
new file mode 100644
index 0000000000000000000000000000000000000000..22b7bf301c8ab7cde285fa257f240986a697b83f
index 0000000000000000000000000000000000000000..78a10f89218eb0edf121f88978b4fe13e1b1bf44
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3808.java
@@ -0,0 +1,82 @@
@ -22133,12 +22133,12 @@ index 0000000000000000000000000000000000000000..22b7bf301c8ab7cde285fa257f240986
+
+ if (this.clearArmor) {
+ final ListType armor = data.getList("ArmorItems", ObjectType.MAP);
+ if (armor.size() > 2) {
+ if (armor != null && armor.size() > 2) {
+ armor.setMap(2, data.getTypeUtil().createEmptyMap());
+ }
+
+ final ListType chances = data.getList("ArmorDropChances", ObjectType.FLOAT);
+ if (chances.size() > 2) {
+ if (chances != null && chances.size() > 2) {
+ chances.setFloat(2, 0.085F);
+ }
+ }

View file

@ -14551,7 +14551,7 @@ index 0000000000000000000000000000000000000000..61fa1ab0f6550fec2b9d035ea45c7262
+
+}
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
index 4de88f74182bb596c6b5ad0351cc0dacefd0ce96..2874bc3001c4e7d9191e47ba512c5a68369c21f1 100644
index 2a5453707bc172d8d0efe3f11959cb0b5f830984..0467ad99b144aa81a04baa45d4c8bbb2b70185a2 100644
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
@@ -29,6 +29,45 @@ public class GlobalConfiguration extends ConfigurationPart {
@ -14622,7 +14622,7 @@ index 4de88f74182bb596c6b5ad0351cc0dacefd0ce96..2874bc3001c4e7d9191e47ba512c5a68
public UnsupportedSettings unsupportedSettings;
public class UnsupportedSettings extends ConfigurationPart {
@@ -201,7 +225,7 @@ public class GlobalConfiguration extends ConfigurationPart {
@@ -203,7 +227,7 @@ public class GlobalConfiguration extends ConfigurationPart {
@PostProcess
private void postProcess() {

View file

@ -9,6 +9,8 @@ public net/minecraft/world/food/FoodProperties DEFAULT_EAT_SECONDS
public org/bukkit/craftbukkit/block/CraftBlockStates getBlockState(Lorg/bukkit/World;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/entity/BlockEntity;)Lorg/bukkit/craftbukkit/block/CraftBlockState;
public net/minecraft/world/level/block/entity/BlockEntity saveId(Lnet/minecraft/nbt/CompoundTag;)V
Co-authored-by: GhastCraftHD <julius.gruenberg@leghast.de>
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 066feef97f92b3f788dd6d25d188f2cc36fc4c80..7c7b9b1e0b604b0164b431873e6753b60421f970 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
@ -830,7 +832,7 @@ index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..77489c3ffaa3a72d4cf105499a77150f
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 705d7365a7bab9fe29b90a175040e6a1623e21a7..8ccb8d71ee489891e8d9128a5520675dd3a62786 100644
index 5d86861a0df7308ae9b8440e5d9136fa7c8f1835..7d15711ffc908dff8a01f2425d729b449c5ed617 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -175,9 +175,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -906,6 +908,15 @@ index 705d7365a7bab9fe29b90a175040e6a1623e21a7..8ccb8d71ee489891e8d9128a5520675d
this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null;
}
// Paper end
@@ -1094,7 +1099,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public void removeEnchantments() {
if (this.hasEnchants()) {
- this.enchantments.clear();
+ this.enchantments = null; // Paper - Correctly clear enchantments
}
}
@@ -1160,6 +1165,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper end
@Override

View file

@ -32,7 +32,7 @@ index 9d74577af071954e1e37201a96368c1360076209..eafa54c870c3e2aef30c3f9f96f51660
throw new IllegalArgumentException("Not implemented. This is a bug");
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 8ccb8d71ee489891e8d9128a5520675dd3a62786..ad51c62b80bfd8f09c57e9ed1e73aad12341293a 100644
index 7d15711ffc908dff8a01f2425d729b449c5ed617..b6686a42fe1eb29e00907105291e9e4a0baa08e0 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1367,7 +1367,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {

View file

@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 4 Jun 2024 19:48:03 -0700
Subject: [PATCH] Fix Player#setBlockUpdate
BlockEntity needs its Level set
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
index 2c61e8d5bbab59c691f4cb003041e7e50e406b85..cee3fe00cc662f095e7d726b5f1a913cd8199210 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
@@ -190,6 +190,7 @@ public abstract class CraftBlockEntityState<T extends BlockEntity> extends Craft
@Nullable
public Packet<ClientGamePacketListener> getUpdatePacket(@NotNull Location location) {
T vanillaTileEntitiy = (T) BlockEntity.loadStatic(CraftLocation.toBlockPosition(location), this.getHandle(), this.getSnapshotNBT(), this.getRegistryAccess());
+ vanillaTileEntitiy.setLevel(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle()); // Paper - set level. Required for accessing RegistryAccess
return ClientboundBlockEntityDataPacket.create(vanillaTileEntitiy);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 40155cc70ba959eea8011626a30e26f44298c99d..32c3c2c6b2eaa90b149d9b425341e75b85bd9764 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1125,6 +1125,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void sendBlockUpdate(@NotNull Location location, @NotNull TileState tileState) throws IllegalArgumentException {
Preconditions.checkArgument(location != null, "Location can not be null");
Preconditions.checkArgument(tileState != null, "TileState can not be null");
+ Preconditions.checkArgument(location.getWorld() != null, "Location must have a world"); // Paper
if (this.getHandle().connection == null) return;

View file

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake <jake.m.potrebic@gmail.com>
Date: Sat, 15 Jun 2024 18:50:18 +0100
Subject: [PATCH] Fix removing recipes from RecipeIterator
== AT ==
public net.minecraft.world.item.crafting.RecipeManager byName
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java
index 78a2afa981407de793ac940d6eb7315c5cd53b8f..33cd12d55786356dc89ab9d3872b2f7d266c3de2 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java
@@ -9,6 +9,7 @@ import org.bukkit.inventory.Recipe;
public class RecipeIterator implements Iterator<Recipe> {
private final Iterator<Map.Entry<RecipeType<?>, RecipeHolder<?>>> recipes;
+ private Recipe currentRecipe; // Paper - fix removing recipes from RecipeIterator
public RecipeIterator() {
this.recipes = MinecraftServer.getServer().getRecipeManager().byType.entries().iterator();
@@ -21,11 +22,19 @@ public class RecipeIterator implements Iterator<Recipe> {
@Override
public Recipe next() {
- return this.recipes.next().getValue().toBukkitRecipe();
+ // Paper start - fix removing recipes from RecipeIterator
+ this.currentRecipe = this.recipes.next().getValue().toBukkitRecipe();
+ return this.currentRecipe;
+ // Paper end - fix removing recipes from RecipeIterator
}
@Override
public void remove() {
+ // Paper start - fix removing recipes from RecipeIterator
+ if (this.currentRecipe instanceof org.bukkit.Keyed keyed) {
+ MinecraftServer.getServer().getRecipeManager().byName.remove(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(keyed.getKey()));
+ }
+ // Paper end - fix removing recipes from RecipeIterator
this.recipes.remove();
}
}

View file

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bjarne Koll <lynxplay101@gmail.com>
Date: Thu, 13 Jun 2024 17:16:01 +0200
Subject: [PATCH] Configurable damage tick when blocking with shield
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 21e61bb75ac7ce468bc757633ce678b21bcb9deb..015134a614a44b610aac1a4c6a1eb6b7b5bb96b5 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2380,7 +2380,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer) damagesource.getEntity(), this, damagesource, originalDamage, f, true); // Paper - fix taken/dealt param order
}
- return true;
+ return !io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.skipVanillaDamageTickWhenShieldBlocked; // Paper - this should always return true, however expose an unsupported setting to flip this to false to enable "shield stunning".
} else {
return true; // Paper - return false ONLY if event was cancelled
}

File diff suppressed because it is too large Load diff