Small diff cleanups from patch updating

And remove a dumb log change in PacketEncoder
This commit is contained in:
Nassim Jahnke 2024-12-17 16:50:59 +01:00
parent 183782ad2e
commit 7caf863b52
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F
25 changed files with 27 additions and 110 deletions

View file

@ -31,10 +31,10 @@ this fix, as the data will remain in the oversized file. Once the server returns
to a jar with this fix, the data will be restored.
diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java
index 2b4fa89f15a42ddd627983fbd1377fb7c9864896..7491644233d52dc56d83de5ad3373f6a9a455378 100644
index d0854fa02be52f560fc91adeb8495a6bd22f6f74..783a2d80f6197dd0af0dc81909f0353a8ea2ecf4 100644
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -54,6 +54,7 @@ public class RegionFile implements AutoCloseable {
@@ -53,6 +53,7 @@ public class RegionFile implements AutoCloseable {
this.info = info;
this.path = path;
this.version = version;
@ -42,7 +42,7 @@ index 2b4fa89f15a42ddd627983fbd1377fb7c9864896..7491644233d52dc56d83de5ad3373f6a
if (!Files.isDirectory(externalFileDir)) {
throw new IllegalArgumentException("Expected directory, got " + externalFileDir.toAbsolutePath());
} else {
@@ -424,4 +425,75 @@ public class RegionFile implements AutoCloseable {
@@ -423,4 +424,75 @@ public class RegionFile implements AutoCloseable {
interface CommitOp {
void run() throws IOException;
}

View file

@ -7,7 +7,7 @@
+ private final int minDataFixPrecacheVersion; // Paper - Perf: Cache DataFixerUpper Rewrite Rules on demand
public DataFixerBuilder(final int dataVersion) {
+ minDataFixPrecacheVersion = Integer.getInteger("Paper.minPrecachedDatafixVersion", dataVersion+1) * 10; // Paper - Perf: default to precache nothing - mojang stores versions * 10 to allow for 'sub versions'
+ this.minDataFixPrecacheVersion = Integer.getInteger("Paper.minPrecachedDatafixVersion", dataVersion + 1) * 10; // Paper - Perf: default to precache nothing - Mojang stores versions * 10 to allow for 'sub versions'
this.dataVersion = dataVersion;
}

View file

@ -32,7 +32,7 @@
player.awardStat(Stats.USE_CAULDRON);
player.awardStat(Stats.ITEM_USED.get(item));
- level.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState());
+ // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit
+ // level.setBlockAndUpdate(pos, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit
level.playSound(null, pos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
level.gameEvent(null, GameEvent.FLUID_PLACE, pos);
}
@ -66,7 +66,7 @@
player.awardStat(Stats.USE_CAULDRON);
player.awardStat(Stats.ITEM_USED.get(item));
- LayeredCauldronBlock.lowerFillLevel(state, level, pos);
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
+ // LayeredCauldronBlock.lowerFillLevel(state, level, pos); // CraftBukkit
level.playSound(null, pos, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1.0F, 1.0F);
level.gameEvent(null, GameEvent.FLUID_PICKUP, pos);
}

View file

@ -24,9 +24,9 @@
+ shrink = false; // Paper - shrink below
+ // Chain to handler for new item
+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem());
+ DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior
+ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(blockSource, eventStack);
+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior
+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) {
+ dispenseBehavior.dispense(blockSource, eventStack);
+ return item;
+ }
+ }

View file

@ -1,13 +1,11 @@
--- a/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java
+++ b/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java
@@ -8,25 +_,48 @@
import net.minecraft.world.level.block.DispenserBlock;
@@ -10,23 +_,46 @@
public class DefaultDispenseItemBehavior implements DispenseItemBehavior {
+ private Direction direction; // Paper - cache facing direction
private static final int DEFAULT_ACCURACY = 6;
+ // CraftBukkit start
+ private Direction direction; // Paper - cache facing direction
+ private boolean dropper;
+
+ public DefaultDispenseItemBehavior(boolean dropper) {
@ -29,7 +27,7 @@
protected ItemStack execute(BlockSource blockSource, ItemStack item) {
- Direction direction = blockSource.state().getValue(DispenserBlock.FACING);
+ // Paper - cached enum direction
+ // Paper - cache facing direction
Position dispensePosition = DispenserBlock.getDispensePosition(blockSource);
ItemStack itemStack = item.split(1);
- spawnItem(blockSource.level(), itemStack, 6, direction, dispensePosition);

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/nbt/ByteArrayTag.java
+++ b/net/minecraft/nbt/ByteArrayTag.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.nbt;
import java.io.DataInput;
@@ -23,6 +_,7 @@
private static byte[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(24L);

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/nbt/IntArrayTag.java
+++ b/net/minecraft/nbt/IntArrayTag.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.nbt;
import java.io.DataInput;
@@ -23,6 +_,7 @@
private static int[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(24L);

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/nbt/NbtIo.java
+++ b/net/minecraft/nbt/NbtIo.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.nbt;
import java.io.BufferedOutputStream;
@@ -118,6 +_,12 @@
}

View file

@ -14,15 +14,7 @@
this.protocolInfo.codec().encode(byteBuf, packet);
int i = byteBuf.readableBytes();
if (LOGGER.isDebugEnabled()) {
@@ -32,14 +_,40 @@
JvmProfiler.INSTANCE.onPacketSent(this.protocolInfo.id(), packetType, channelHandlerContext.channel().remoteAddress(), i);
} catch (Throwable var9) {
- LOGGER.error("Error sending packet {}", packetType, var9);
+ LOGGER.error("Error sending packet {} (skippable? {})", packetType, packet.isSkippable(), var9);
if (packet.isSkippable()) {
throw new SkipPacketException(var9);
}
@@ -39,7 +_,33 @@
throw var9;
} finally {

View file

@ -7,10 +7,10 @@
- ChatDecorator PLAIN = (player, message) -> message;
-
- Component decorate(@Nullable ServerPlayer player, Component message);
+ ChatDecorator PLAIN = (sender, message) -> java.util.concurrent.CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events
+ ChatDecorator PLAIN = (player, message) -> java.util.concurrent.CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events
+
+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack)
+ java.util.concurrent.CompletableFuture<Component> decorate(@Nullable ServerPlayer sender, Component message); // Paper - adventure; support async chat decoration events
+ java.util.concurrent.CompletableFuture<Component> decorate(@Nullable ServerPlayer player, Component message); // Paper - adventure; support async chat decoration events
+
+ // Paper start - adventure; support async chat decoration events
+ default java.util.concurrent.CompletableFuture<Component> decorate(@Nullable ServerPlayer sender, @Nullable net.minecraft.commands.CommandSourceStack commandSourceStack, Component message) {

View file

@ -9,7 +9,7 @@
+
+ // CraftBukkit start
+ default java.util.stream.Stream<Component> stream() {
+ return com.google.common.collect.Streams.concat(new java.util.stream.Stream[]{java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)});
+ return com.google.common.collect.Streams.concat(java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream));
+ }
+
+ @Override

View file

@ -71,12 +71,12 @@
(entryBuilder, buffer) -> entryBuilder.chatSession = buffer.readNullable(RemoteChatSession.Data::read),
- (buffer, entry) -> buffer.writeNullable(entry.chatSession, RemoteChatSession.Data::write)
+ // Paper start - Prevent causing expired keys from impacting new joins
+ (buf, entry) -> {
+ (buffer, entry) -> {
+ RemoteChatSession.Data chatSession = entry.chatSession;
+ if (chatSession != null && chatSession.profilePublicKey().hasExpired()) {
+ chatSession = null;
+ }
+ buf.writeNullable(chatSession, RemoteChatSession.Data::write);
+ buffer.writeNullable(chatSession, RemoteChatSession.Data::write);
+ }
+ // Paper end - Prevent causing expired keys from impacting new joins
),

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.RegistryFriendlyByteBuf;
@@ -16,6 +_,16 @@
ClientboundSystemChatPacket::overlay,
ClientboundSystemChatPacket::new

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.FriendlyByteBuf;
@@ -14,6 +_,7 @@
private final BlockHitResult blockHit;
private final InteractionHand hand;

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
+++ b/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import net.minecraft.network.FriendlyByteBuf;
@@ -14,6 +_,7 @@
private final int sequence;
private final float yRot;

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java
+++ b/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.network.protocol.handshake;
import net.minecraft.network.FriendlyByteBuf;
@@ -20,7 +_,7 @@
}

View file

@ -1,16 +1,15 @@
--- a/net/minecraft/server/commands/DifficultyCommand.java
+++ b/net/minecraft/server/commands/DifficultyCommand.java
@@ -31,10 +_,11 @@
@@ -31,10 +_,10 @@
public static int setDifficulty(CommandSourceStack source, Difficulty difficulty) throws CommandSyntaxException {
MinecraftServer server = source.getServer();
- if (server.getWorldData().getDifficulty() == difficulty) {
+ net.minecraft.server.level.ServerLevel serverLevel = source.getLevel(); // CraftBukkit
+ if (serverLevel.getDifficulty() == difficulty) { // CraftBukkit
+ if (source.getLevel().getDifficulty() == difficulty) { // CraftBukkit
throw ERROR_ALREADY_DIFFICULT.create(difficulty.getKey());
} else {
- server.setDifficulty(difficulty, true);
+ server.setDifficulty(serverLevel, difficulty, true); // Paper - per level difficulty; don't skip other difficulty-changing logic (fix upstream's fix)
+ server.setDifficulty(source.getLevel(), difficulty, true); // Paper - per level difficulty; don't skip other difficulty-changing logic (fix upstream's fix)
source.sendSuccess(() -> Component.translatable("commands.difficulty.success", difficulty.getDisplayName()), true);
return 0;
}

View file

@ -15,12 +15,12 @@
}
+
+ // CraftBukkit start
+ public static void reload(MinecraftServer minecraftserver) {
+ PackRepository resourcepackrepository = minecraftserver.getPackRepository();
+ WorldData savedata = minecraftserver.getWorldData();
+ Collection<String> collection = resourcepackrepository.getSelectedIds();
+ Collection<String> collection1 = ReloadCommand.discoverNewPacks(resourcepackrepository, savedata, collection);
+ minecraftserver.reloadResources(collection1, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper - Add ServerResourcesReloadedEvent
+ public static void reload(MinecraftServer server) {
+ PackRepository packRepository = server.getPackRepository();
+ WorldData worldData = server.getWorldData();
+ Collection<String> selectedIds = packRepository.getSelectedIds();
+ Collection<String> collection = discoverNewPacks(packRepository, worldData, selectedIds);
+ server.reloadResources(collection, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper - Add ServerResourcesReloadedEvent
+ }
+ // CraftBukkit end

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/server/players/UserBanListEntry.java
+++ b/net/minecraft/server/players/UserBanListEntry.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.server.players;
import com.google.gson.JsonObject;
@@ -37,19 +_,29 @@
@Nullable

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.stats;
import com.google.common.collect.Maps;
@@ -51,9 +_,22 @@
LOGGER.error("Couldn't parse statistics file {}", file, var5);
}

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/world/entity/ai/attributes/Attributes.java
+++ b/net/minecraft/world/entity/ai/attributes/Attributes.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.entity.ai.attributes;
import net.minecraft.core.Holder;
@@ -10,7 +_,7 @@
public static final Holder<Attribute> ARMOR_TOUGHNESS = register(
"armor_toughness", new RangedAttribute("attribute.name.armor_toughness", 0.0, 0.0, 20.0).setSyncable(true)

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/world/item/DebugStickItem.java
+++ b/net/minecraft/world/item/DebugStickItem.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.item;
import java.util.Collection;
@@ -51,7 +_,7 @@
public boolean handleInteraction(
Player player, BlockState stateClicked, LevelAccessor accessor, BlockPos pos, boolean shouldCycleState, ItemStack debugStack

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.level.chunk;
import com.google.common.base.Stopwatch;
@@ -41,22 +_,109 @@
private final Map<ConcentricRingsStructurePlacement, CompletableFuture<List<ChunkPos>>> ringPositions = new Object2ObjectArrayMap<>();
private boolean hasGeneratedPositions;

View file

@ -1,7 +0,0 @@
--- a/net/minecraft/world/level/chunk/DataLayer.java
+++ b/net/minecraft/world/level/chunk/DataLayer.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.level.chunk;
import java.util.Arrays;

View file

@ -1,10 +1,5 @@
--- a/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -1,3 +_,4 @@
+// mc-dev import
package net.minecraft.world.level.chunk.storage;
import com.google.common.annotations.VisibleForTesting;
@@ -46,7 +_,7 @@
protected final RegionBitmap usedSectors = new RegionBitmap();