More more more more work
This commit is contained in:
parent
aab40382a5
commit
c7304035b6
123 changed files with 257 additions and 265 deletions
|
@ -14,7 +14,7 @@ big slowdown in execution but throwing an exception at same time to raise awaren
|
|||
that it is happening so that plugin authors can fix their code to stop executing commands async.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index fda4d570ef04e91c4e6c29c52221c04937dc4fbc..e9999a52a0f54c47e973bc22fa91465e8e993b1c 100644
|
||||
index fda4d570ef04e91c4e6c29c52221c04937dc4fbc..350128dc1c4c2c1597ad19d8b24193bc94c90d81 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2041,6 +2041,29 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
@ -29,7 +29,7 @@ index fda4d570ef04e91c4e6c29c52221c04937dc4fbc..e9999a52a0f54c47e973bc22fa91465e
|
|||
+ Waitable wait = new Waitable() {
|
||||
+ @Override
|
||||
+ protected Object evaluate() {
|
||||
+ chat(fCommandLine, false);
|
||||
+ chat(fCommandLine, original, false);
|
||||
+ return null;
|
||||
+ }
|
||||
+ };
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Fix exploit that allowed colored signs to be created
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 7fb4e1cf4eb21dd19a581b082caf9825cdaa4ad9..78662c29e9771ddead43dc243fb5f7d802d6d40d 100644
|
||||
index 795bd69354dc59ea3fc59daa7239e5e8fa110e8c..4471a220b66cdb055b5e4c32b5d7859685ea4666 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -3218,9 +3218,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
@ -13,7 +13,7 @@ index 7fb4e1cf4eb21dd19a581b082caf9825cdaa4ad9..78662c29e9771ddead43dc243fb5f7d8
|
|||
|
||||
if (this.player.isTextFilteringEnabled()) {
|
||||
- lines.add(net.kyori.adventure.text.Component.text(filteredtext.filteredOrEmpty())); // Paper - adventure
|
||||
+ lines.add(SharedConstants.filterText(net.kyori.adventure.text.Component.text(filteredtext.filteredOrEmpty()))); // Paper - adventure
|
||||
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(filteredtext.filteredOrEmpty()))); // Paper - adventure
|
||||
} else {
|
||||
- lines.add(net.kyori.adventure.text.Component.text(filteredtext.raw())); // Paper - adventure
|
||||
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(filteredtext.raw()))); // Paper - adventure
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
||||
Date: Wed, 8 Jun 2022 10:52:18 +0200
|
||||
Subject: [PATCH] Move range check for block placing up
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index acb7c80fa01689098962d170df91aa79c2472dd1..cc1225f7c1e4d47f509c55609066fba084331a4d 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1829,6 +1829,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
ItemStack itemstack = this.player.getItemInHand(enumhand);
|
||||
BlockHitResult movingobjectpositionblock = packet.getHitResult();
|
||||
Vec3 vec3d = movingobjectpositionblock.getLocation();
|
||||
+ // Paper start - improve distance check
|
||||
+ if (!Double.isFinite(vec3d.x) || !Double.isFinite(vec3d.y) || !Double.isFinite(vec3d.z)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
|
||||
Vec3 vec3d1 = Vec3.atCenterOf(blockposition);
|
||||
|
389
patches/server/0648-Fix-and-optimise-world-force-upgrading.patch
Normal file
389
patches/server/0648-Fix-and-optimise-world-force-upgrading.patch
Normal file
|
@ -0,0 +1,389 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 20 May 2021 07:02:22 -0700
|
||||
Subject: [PATCH] Fix and optimise world force upgrading
|
||||
|
||||
The WorldUpgrader class was incorrectly modified by
|
||||
CB. It will store an IChunkLoader instance for all
|
||||
dimension types in the world, but obviously with how
|
||||
CB shifts around worlds only one dimension type exists
|
||||
per world. But this would be OK if CB did this
|
||||
change correctly. All IChunkLoader instances
|
||||
will point to the same regionfiles. And all
|
||||
IChunkLoader instances are going to be read from.
|
||||
|
||||
This problem hasn't really been reported because
|
||||
it relies on the persistent legacy data to be converted
|
||||
as well to cause corruption. Why? Because the legacy
|
||||
data is also shared, it will result in different
|
||||
outputs from conversion (as once conversion for legacy
|
||||
persistent data takes place, it is REMOVED - so the next
|
||||
convert will _not_ have the data). Which means different
|
||||
sizes on disk. Which means different regionfile sector
|
||||
allocations. Which means there are 3 different possible
|
||||
regionfile sector allocations in memory, and none of them
|
||||
are going to be correct.
|
||||
|
||||
I've fixed this by writing a world upgrader suited to
|
||||
CB's changes to world folder format. It was brain dead
|
||||
easy to add threading, so I did.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..95cac7edae8ac64811fc6a2f6b97dd4a0fceb0b0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/world/ThreadedWorldUpgrader.java
|
||||
@@ -0,0 +1,209 @@
|
||||
+package io.papermc.paper.world;
|
||||
+
|
||||
+import com.mojang.datafixers.DataFixer;
|
||||
+import com.mojang.serialization.Codec;
|
||||
+import net.minecraft.SharedConstants;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.util.worldupdate.WorldUpgrader;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
+import net.minecraft.world.level.chunk.storage.ChunkStorage;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileStorage;
|
||||
+import net.minecraft.world.level.dimension.DimensionType;
|
||||
+import net.minecraft.world.level.dimension.LevelStem;
|
||||
+import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
+import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
+import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.text.DecimalFormat;
|
||||
+import java.util.Optional;
|
||||
+import java.util.concurrent.ExecutorService;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.ThreadFactory;
|
||||
+import java.util.concurrent.atomic.AtomicInteger;
|
||||
+import java.util.concurrent.atomic.AtomicLong;
|
||||
+import java.util.function.Supplier;
|
||||
+
|
||||
+public class ThreadedWorldUpgrader {
|
||||
+
|
||||
+ private static final Logger LOGGER = LogManager.getLogger();
|
||||
+
|
||||
+ private final ResourceKey<LevelStem> dimensionType;
|
||||
+ private final String worldName;
|
||||
+ private final File worldDir;
|
||||
+ private final ExecutorService threadPool;
|
||||
+ private final DataFixer dataFixer;
|
||||
+ private final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey;
|
||||
+ private final boolean removeCaches;
|
||||
+
|
||||
+ public ThreadedWorldUpgrader(final ResourceKey<LevelStem> dimensionType, final String worldName, final File worldDir, final int threads,
|
||||
+ final DataFixer dataFixer, final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey, final boolean removeCaches) {
|
||||
+ this.dimensionType = dimensionType;
|
||||
+ this.worldName = worldName;
|
||||
+ this.worldDir = worldDir;
|
||||
+ this.threadPool = Executors.newFixedThreadPool(Math.max(1, threads), new ThreadFactory() {
|
||||
+ private final AtomicInteger threadCounter = new AtomicInteger();
|
||||
+
|
||||
+ @Override
|
||||
+ public Thread newThread(final Runnable run) {
|
||||
+ final Thread ret = new Thread(run);
|
||||
+
|
||||
+ ret.setName("World upgrader thread for world " + ThreadedWorldUpgrader.this.worldName + " #" + this.threadCounter.getAndIncrement());
|
||||
+ ret.setUncaughtExceptionHandler((thread, throwable) -> {
|
||||
+ LOGGER.fatal("Error upgrading world", throwable);
|
||||
+ });
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+ });
|
||||
+ this.dataFixer = dataFixer;
|
||||
+ this.generatorKey = generatorKey;
|
||||
+ this.removeCaches = removeCaches;
|
||||
+ }
|
||||
+
|
||||
+ public void convert() {
|
||||
+ final File worldFolder = LevelStorageSource.getStorageFolder(this.worldDir.toPath(), this.dimensionType).toFile();
|
||||
+ final DimensionDataStorage worldPersistentData = new DimensionDataStorage(new File(worldFolder, "data"), this.dataFixer);
|
||||
+
|
||||
+ final File regionFolder = new File(worldFolder, "region");
|
||||
+
|
||||
+ LOGGER.info("Force upgrading " + this.worldName);
|
||||
+ LOGGER.info("Counting regionfiles for " + this.worldName);
|
||||
+ final File[] regionFiles = regionFolder.listFiles((final File dir, final String name) -> {
|
||||
+ return WorldUpgrader.REGEX.matcher(name).matches();
|
||||
+ });
|
||||
+ if (regionFiles == null) {
|
||||
+ LOGGER.info("Found no regionfiles to convert for world " + this.worldName);
|
||||
+ return;
|
||||
+ }
|
||||
+ LOGGER.info("Found " + regionFiles.length + " regionfiles to convert");
|
||||
+ LOGGER.info("Starting conversion now for world " + this.worldName);
|
||||
+
|
||||
+ final WorldInfo info = new WorldInfo(() -> worldPersistentData,
|
||||
+ new ChunkStorage(regionFolder.toPath(), this.dataFixer, false), this.removeCaches, this.dimensionType, this.generatorKey);
|
||||
+
|
||||
+ long expectedChunks = (long)regionFiles.length * (32L * 32L);
|
||||
+
|
||||
+ for (final File regionFile : regionFiles) {
|
||||
+ final ChunkPos regionPos = RegionFileStorage.getRegionFileCoordinates(regionFile.toPath());
|
||||
+ if (regionPos == null) {
|
||||
+ expectedChunks -= (32L * 32L);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.threadPool.execute(new ConvertTask(info, regionPos.x >> 5, regionPos.z >> 5));
|
||||
+ }
|
||||
+ this.threadPool.shutdown();
|
||||
+
|
||||
+ final DecimalFormat format = new DecimalFormat("#0.00");
|
||||
+
|
||||
+ final long start = System.nanoTime();
|
||||
+
|
||||
+ while (!this.threadPool.isTerminated()) {
|
||||
+ final long current = info.convertedChunks.get();
|
||||
+
|
||||
+ LOGGER.info("{}% completed ({} / {} chunks)...", format.format((double)current / (double)expectedChunks * 100.0), current, expectedChunks);
|
||||
+
|
||||
+ try {
|
||||
+ Thread.sleep(1000L);
|
||||
+ } catch (final InterruptedException ignore) {}
|
||||
+ }
|
||||
+
|
||||
+ final long end = System.nanoTime();
|
||||
+
|
||||
+ try {
|
||||
+ info.loader.close();
|
||||
+ } catch (final IOException ex) {
|
||||
+ LOGGER.fatal("Failed to close chunk loader", ex);
|
||||
+ }
|
||||
+ LOGGER.info("Completed conversion. Took {}s, {} out of {} chunks needed to be converted/modified ({}%)",
|
||||
+ (int)Math.ceil((end - start) * 1.0e-9), info.modifiedChunks.get(), expectedChunks, format.format((double)info.modifiedChunks.get() / (double)expectedChunks * 100.0));
|
||||
+ }
|
||||
+
|
||||
+ private static final class WorldInfo {
|
||||
+
|
||||
+ public final Supplier<DimensionDataStorage> persistentDataSupplier;
|
||||
+ public final ChunkStorage loader;
|
||||
+ public final boolean removeCaches;
|
||||
+ public final ResourceKey<LevelStem> worldKey;
|
||||
+ public final Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey;
|
||||
+ public final AtomicLong convertedChunks = new AtomicLong();
|
||||
+ public final AtomicLong modifiedChunks = new AtomicLong();
|
||||
+
|
||||
+ private WorldInfo(final Supplier<DimensionDataStorage> persistentDataSupplier, final ChunkStorage loader, final boolean removeCaches,
|
||||
+ final ResourceKey<LevelStem> worldKey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> generatorKey) {
|
||||
+ this.persistentDataSupplier = persistentDataSupplier;
|
||||
+ this.loader = loader;
|
||||
+ this.removeCaches = removeCaches;
|
||||
+ this.worldKey = worldKey;
|
||||
+ this.generatorKey = generatorKey;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static final class ConvertTask implements Runnable {
|
||||
+
|
||||
+ private final WorldInfo worldInfo;
|
||||
+ private final int regionX;
|
||||
+ private final int regionZ;
|
||||
+
|
||||
+ public ConvertTask(final WorldInfo worldInfo, final int regionX, final int regionZ) {
|
||||
+ this.worldInfo = worldInfo;
|
||||
+ this.regionX = regionX;
|
||||
+ this.regionZ = regionZ;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ final int regionCX = this.regionX << 5;
|
||||
+ final int regionCZ = this.regionZ << 5;
|
||||
+
|
||||
+ final Supplier<DimensionDataStorage> persistentDataSupplier = this.worldInfo.persistentDataSupplier;
|
||||
+ final ChunkStorage loader = this.worldInfo.loader;
|
||||
+ final boolean removeCaches = this.worldInfo.removeCaches;
|
||||
+ final ResourceKey<LevelStem> worldKey = this.worldInfo.worldKey;
|
||||
+
|
||||
+ for (int cz = regionCZ; cz < (regionCZ + 32); ++cz) {
|
||||
+ for (int cx = regionCX; cx < (regionCX + 32); ++cx) {
|
||||
+ final ChunkPos chunkPos = new ChunkPos(cx, cz);
|
||||
+ try {
|
||||
+ // no need to check the coordinate of the chunk, the regionfilecache does that for us
|
||||
+
|
||||
+ CompoundTag chunkNBT = (loader.read(chunkPos).join()).orElse(null);
|
||||
+
|
||||
+ if (chunkNBT == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final int versionBefore = ChunkStorage.getVersion(chunkNBT);
|
||||
+
|
||||
+ chunkNBT = loader.upgradeChunkTag(worldKey, persistentDataSupplier, chunkNBT, this.worldInfo.generatorKey, chunkPos, null);
|
||||
+
|
||||
+ boolean modified = versionBefore < SharedConstants.getCurrentVersion().getWorldVersion();
|
||||
+
|
||||
+ if (removeCaches) {
|
||||
+ final CompoundTag level = chunkNBT.getCompound("Level");
|
||||
+ modified |= level.contains("Heightmaps");
|
||||
+ level.remove("Heightmaps");
|
||||
+ modified |= level.contains("isLightOn");
|
||||
+ level.remove("isLightOn");
|
||||
+ }
|
||||
+
|
||||
+ if (modified) {
|
||||
+ this.worldInfo.modifiedChunks.getAndIncrement();
|
||||
+ loader.write(chunkPos, chunkNBT);
|
||||
+ }
|
||||
+ } catch (final Exception ex) {
|
||||
+ LOGGER.error("Error upgrading chunk {}", chunkPos, ex);
|
||||
+ } finally {
|
||||
+ this.worldInfo.convertedChunks.getAndIncrement();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index ce4aed84d751a48dcd2a8409190db4a22d78f77b..0a843e0afbcb1af8e2641515eb244b791b819b8c 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -16,6 +16,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BooleanSupplier;
|
||||
+import io.papermc.paper.world.ThreadedWorldUpgrader;
|
||||
import joptsimple.NonOptionArgumentSpec;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
@@ -297,6 +298,15 @@ public class Main {
|
||||
|
||||
}
|
||||
|
||||
+ // Paper start - fix and optimise world upgrading
|
||||
+ public static void convertWorldButItWorks(net.minecraft.resources.ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimensionType, net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess worldSession,
|
||||
+ DataFixer dataFixer, Optional<net.minecraft.resources.ResourceKey<com.mojang.serialization.Codec<? extends net.minecraft.world.level.chunk.ChunkGenerator>>> generatorKey, boolean removeCaches) {
|
||||
+ int threads = Runtime.getRuntime().availableProcessors() * 3 / 8;
|
||||
+ final ThreadedWorldUpgrader worldUpgrader = new ThreadedWorldUpgrader(dimensionType, worldSession.getLevelId(), worldSession.levelDirectory.path().toFile(), threads, dataFixer, generatorKey, removeCaches);
|
||||
+ worldUpgrader.convert();
|
||||
+ }
|
||||
+ // Paper end - fix and optimise world upgrading
|
||||
+
|
||||
public static void forceUpgrade(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, boolean eraseCache, BooleanSupplier continueCheck, WorldGenSettings generatorOptions) {
|
||||
Main.LOGGER.info("Forcing world upgrade! {}", session.getLevelId()); // CraftBukkit
|
||||
WorldUpgrader worldupgrader = new WorldUpgrader(session, dataFixer, generatorOptions, eraseCache);
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index cefa833408ff95890dc5c831276f259022bd95a3..fdf08831a9d1b27c8050432e958f7133f3d10e1e 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -545,11 +545,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
worlddata = new PrimaryLevelData(worldsettings, generatorsettings, Lifecycle.stable());
|
||||
}
|
||||
worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
|
||||
- if (this.options.has("forceUpgrade")) {
|
||||
- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> {
|
||||
- return true;
|
||||
- }, worlddata.worldGenSettings());
|
||||
- }
|
||||
+ // Paper - move down
|
||||
|
||||
PrimaryLevelData iworlddataserver = worlddata;
|
||||
WorldGenSettings generatorsettings = worlddata.worldGenSettings();
|
||||
@@ -564,6 +560,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
|
||||
}
|
||||
|
||||
+ // Paper start - fix and optimise world upgrading
|
||||
+ if (options.has("forceUpgrade")) {
|
||||
+ net.minecraft.server.Main.convertWorldButItWorks(
|
||||
+ dimensionKey, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), options.has("eraseCache")
|
||||
+ );
|
||||
+ }
|
||||
+ // Paper end - fix and optimise world upgrading
|
||||
ResourceKey<Level> worldKey = ResourceKey.create(Registry.DIMENSION_REGISTRY, dimensionKey.location());
|
||||
|
||||
if (dimensionKey == LevelStem.OVERWORLD) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index d9a88b29cfefcdbce7bfc477b6c1af0e51079102..c21274a72dca31c9160ecbcfa7eb42de64e91454 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -182,6 +182,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
||||
|
||||
+ // Paper start - fix and optimise world upgrading
|
||||
+ // copied from below
|
||||
+ public static ResourceKey<DimensionType> getDimensionKey(DimensionType manager) {
|
||||
+ return ((org.bukkit.craftbukkit.CraftServer)org.bukkit.Bukkit.getServer()).getHandle().getServer().registryHolder.ownedRegistryOrThrow(net.minecraft.core.Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(manager).orElseThrow(() -> {
|
||||
+ return new IllegalStateException("Unregistered dimension type: " + manager);
|
||||
+ });
|
||||
+ }
|
||||
+ // Paper end - fix and optimise world upgrading
|
||||
+
|
||||
public CraftWorld getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index a96a6af2bcec3134b7caa32299bd07af50e83b89..0d96d1c0b66c57c680759f3567ef1b0c326d8cfa 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -32,6 +32,28 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
|
||||
// Paper start
|
||||
+ public static @Nullable ChunkPos getRegionFileCoordinates(Path file) {
|
||||
+ String fileName = file.getFileName().toString();
|
||||
+ if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ String[] split = fileName.split("\\.");
|
||||
+
|
||||
+ if (split.length != 4) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ int x = Integer.parseInt(split[1]);
|
||||
+ int z = Integer.parseInt(split[2]);
|
||||
+
|
||||
+ return new ChunkPos(x << 5, z << 5);
|
||||
+ } catch (NumberFormatException ex) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) {
|
||||
return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 5196eef152a64269f460b3631aba455b0b434246..e8f327693e8b488790bf58d4927497402211bf1d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1202,12 +1202,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
worlddata.checkName(name);
|
||||
worlddata.setModdedInfo(this.console.getServerModName(), this.console.getModdedStatus().shouldReportAsModified());
|
||||
-
|
||||
- if (console.options.has("forceUpgrade")) {
|
||||
- net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), console.options.has("eraseCache"), () -> {
|
||||
- return true;
|
||||
- }, worlddata.worldGenSettings());
|
||||
- }
|
||||
+ // Paper - move down
|
||||
|
||||
long j = BiomeManager.obfuscateSeed(creator.seed());
|
||||
List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(worlddata));
|
||||
@@ -1219,6 +1214,13 @@ public final class CraftServer implements Server {
|
||||
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
|
||||
}
|
||||
|
||||
+ // Paper start - fix and optimise world upgrading
|
||||
+ if (console.options.has("forceUpgrade")) {
|
||||
+ net.minecraft.server.Main.convertWorldButItWorks(
|
||||
+ actualDimension, worldSession, DataFixers.getDataFixer(), worlddimension.generator().getTypeNameForDataFixer(), console.options.has("eraseCache")
|
||||
+ );
|
||||
+ }
|
||||
+ // Paper end - fix and optimise world upgrading
|
||||
ResourceKey<net.minecraft.world.level.Level> worldKey;
|
||||
String levelName = this.getServer().getProperties().levelName;
|
||||
if (name.equals(levelName + "_nether")) {
|
64
patches/server/0649-Add-Mob-lookAt-API.patch
Normal file
64
patches/server/0649-Add-Mob-lookAt-API.patch
Normal file
|
@ -0,0 +1,64 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 14 May 2021 13:42:17 -0500
|
||||
Subject: [PATCH] Add Mob#lookAt API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
index 881bb11507eafe87522ad4131ea7859f42918b3e..d9008049188c1933f2b6b39b9219983ff947b4bf 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
@@ -82,5 +82,53 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||
public boolean isInDaylight() {
|
||||
return getHandle().isSunBurnTick();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
|
||||
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
|
||||
+ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.Location location, float headRotationSpeed, float maxHeadPitch) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(location, "location cannot be null");
|
||||
+ com.google.common.base.Preconditions.checkArgument(location.getWorld().equals(getWorld()), "location in a different world");
|
||||
+ getHandle().getLookControl().setLookAt(location.getX(), location.getY(), location.getZ(), headRotationSpeed, maxHeadPitch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
|
||||
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
|
||||
+ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(@org.jetbrains.annotations.NotNull org.bukkit.entity.Entity entity, float headRotationSpeed, float maxHeadPitch) {
|
||||
+ com.google.common.base.Preconditions.checkNotNull(entity, "entity cannot be null");
|
||||
+ com.google.common.base.Preconditions.checkArgument(entity.getWorld().equals(getWorld()), "entity in a different world");
|
||||
+ getHandle().getLookControl().setLookAt(((CraftEntity) entity).getHandle(), headRotationSpeed, maxHeadPitch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(double x, double y, double z) {
|
||||
+ getHandle().getLookControl().setLookAt(x, y, z);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lookAt(double x, double y, double z, float headRotationSpeed, float maxHeadPitch) {
|
||||
+ getHandle().getLookControl().setLookAt(x, y, z, headRotationSpeed, maxHeadPitch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getHeadRotationSpeed() {
|
||||
+ return getHandle().getHeadRotSpeed();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxHeadPitch() {
|
||||
+ return getHandle().getMaxHeadXRot();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
141
patches/server/0650-Add-Unix-domain-socket-support.patch
Normal file
141
patches/server/0650-Add-Unix-domain-socket-support.patch
Normal file
|
@ -0,0 +1,141 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Tue, 11 May 2021 17:39:22 -0400
|
||||
Subject: [PATCH] Add Unix domain socket support
|
||||
|
||||
For Windows and ARM support, JEP-380 is required:
|
||||
https://inside.java/2021/02/03/jep380-unix-domain-sockets-channels/
|
||||
This will be possible as of the Minecraft 1.17 Java version bump.
|
||||
|
||||
Tested-by: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Reviewed-by: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index 023c564248adb2c5c4b679be9075ca88cb2d5b62..ca6b12b61874913f6d4abac97a3df67d0053cd8f 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -641,6 +641,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
// Spigot Start
|
||||
public SocketAddress getRawAddress()
|
||||
{
|
||||
+ // Paper start - this can be nullable in the case of a Unix domain socket, so if it is, fake something
|
||||
+ if (this.channel.remoteAddress() == null) {
|
||||
+ return new java.net.InetSocketAddress(java.net.InetAddress.getLoopbackAddress(), 0);
|
||||
+ }
|
||||
+ // Paper end
|
||||
return this.channel.remoteAddress();
|
||||
}
|
||||
// Spigot End
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 2c215e2080f00d6c875fbde92fd2c1c051d0cf98..2d01a1d4b2f7fdd38a6b1022f2476ba68b663171 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -224,6 +224,20 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
|
||||
// this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
+ // Paper start - Unix domain socket support
|
||||
+ java.net.SocketAddress bindAddress;
|
||||
+ if (this.getLocalIp().startsWith("unix:")) {
|
||||
+ if (!io.netty.channel.epoll.Epoll.isAvailable()) {
|
||||
+ DedicatedServer.LOGGER.error("**** INVALID CONFIGURATION!");
|
||||
+ DedicatedServer.LOGGER.error("You are trying to use a Unix domain socket but you're not on a supported OS.");
|
||||
+ return false;
|
||||
+ } else if (!io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled && !org.spigotmc.SpigotConfig.bungee) {
|
||||
+ DedicatedServer.LOGGER.error("**** INVALID CONFIGURATION!");
|
||||
+ DedicatedServer.LOGGER.error("Unix domain sockets require IPs to be forwarded from a proxy.");
|
||||
+ return false;
|
||||
+ }
|
||||
+ bindAddress = new io.netty.channel.unix.DomainSocketAddress(this.getLocalIp().substring("unix:".length()));
|
||||
+ } else {
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
if (!this.getLocalIp().isEmpty()) {
|
||||
@@ -233,12 +247,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
if (this.getPort() < 0) {
|
||||
this.setPort(dedicatedserverproperties.serverPort);
|
||||
}
|
||||
+ bindAddress = new java.net.InetSocketAddress(inetaddress, this.getPort());
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
this.initializeKeyPair();
|
||||
DedicatedServer.LOGGER.info("Starting Minecraft server on {}:{}", this.getLocalIp().isEmpty() ? "*" : this.getLocalIp(), this.getPort());
|
||||
|
||||
try {
|
||||
- this.getConnection().startTcpServerListener(inetaddress, this.getPort());
|
||||
+ this.getConnection().bind(bindAddress); // Paper - Unix domain socket support
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.warn("**** FAILED TO BIND TO PORT!");
|
||||
DedicatedServer.LOGGER.warn("The exception was: {}", ioexception.toString());
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
index 83af90fb0dcb4b1a5a68f655cf66d101b472e8e7..b80aedd2002959b4026c27ce76b3ed17f0acfb5b 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
|
||||
@@ -80,7 +80,12 @@ public class ServerConnectionListener {
|
||||
this.running = true;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
public void startTcpServerListener(@Nullable InetAddress address, int port) throws IOException {
|
||||
+ bind(new java.net.InetSocketAddress(address, port));
|
||||
+ }
|
||||
+ public void bind(java.net.SocketAddress address) throws IOException {
|
||||
+ // Paper end
|
||||
List list = this.channels;
|
||||
|
||||
synchronized (this.channels) {
|
||||
@@ -88,7 +93,11 @@ public class ServerConnectionListener {
|
||||
LazyLoadedValue lazyinitvar;
|
||||
|
||||
if (Epoll.isAvailable() && this.server.isEpollEnabled()) {
|
||||
+ if (address instanceof io.netty.channel.unix.DomainSocketAddress) {
|
||||
+ oclass = io.netty.channel.epoll.EpollServerDomainSocketChannel.class;
|
||||
+ } else {
|
||||
oclass = EpollServerSocketChannel.class;
|
||||
+ }
|
||||
lazyinitvar = ServerConnectionListener.SERVER_EPOLL_EVENT_GROUP;
|
||||
ServerConnectionListener.LOGGER.info("Using epoll channel type");
|
||||
} else {
|
||||
@@ -116,7 +125,7 @@ public class ServerConnectionListener {
|
||||
((Connection) object).setListener(new ServerHandshakePacketListenerImpl(ServerConnectionListener.this.server, (Connection) object));
|
||||
io.papermc.paper.network.ChannelInitializeListenerHolder.callListeners(channel); // Paper
|
||||
}
|
||||
- }).group((EventLoopGroup) lazyinitvar.get()).localAddress(address, port)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
+ }).group((EventLoopGroup) lazyinitvar.get()).localAddress(address)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit // Paper
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index 53833fdd748098b662d4420a254401c0d3982e56..b02cbf6bcc57167a1373925f652950e0212dfa4f 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -43,6 +43,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
this.connection.setProtocol(ConnectionProtocol.LOGIN);
|
||||
// CraftBukkit start - Connection throttle
|
||||
try {
|
||||
+ if (!(this.connection.channel.localAddress() instanceof io.netty.channel.unix.DomainSocketAddress)) { // Paper - the connection throttle is useless when you have a Unix domain socket
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long connectionThrottle = this.server.server.getConnectionThrottle();
|
||||
InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
|
||||
@@ -71,6 +72,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
}
|
||||
}
|
||||
}
|
||||
+ } // Paper - add closing bracket for if check above
|
||||
} catch (Throwable t) {
|
||||
org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
|
||||
}
|
||||
@@ -119,8 +121,11 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
// Paper end
|
||||
// if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
|
||||
if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.BYPASS_HOSTCHECK || ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) { // Paper
|
||||
+ // Paper start - Unix domain socket support
|
||||
+ java.net.SocketAddress socketAddress = connection.getRemoteAddress();
|
||||
packet.hostName = split[0];
|
||||
- connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort());
|
||||
+ connection.address = new java.net.InetSocketAddress(split[1], socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0);
|
||||
+ // Paper end
|
||||
connection.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );
|
||||
} else
|
||||
{
|
258
patches/server/0651-Add-EntityInsideBlockEvent.patch
Normal file
258
patches/server/0651-Add-EntityInsideBlockEvent.patch
Normal file
|
@ -0,0 +1,258 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 8 May 2021 18:02:36 -0700
|
||||
Subject: [PATCH] Add EntityInsideBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
index 922b5b22a4ccfeead9d6d2b9a2a2b3cc8a1e6c55..a76c452dc5c2069a3071aec31bfb3e977867161e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BaseFireBlock.java
|
||||
@@ -121,6 +121,7 @@ public abstract class BaseFireBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!entity.fireImmune()) {
|
||||
entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1);
|
||||
if (entity.getRemainingFireTicks() == 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
||||
index af808ddea455b2df9e551ce32dcd5bb472623dd9..f9aaec28be3e7a191981d30b361e369d7fea2c9e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
||||
@@ -67,6 +67,7 @@ public abstract class BasePressurePlateBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide) {
|
||||
int i = this.getSignalForState(state);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
|
||||
index ce32a0582c6d86e754710daa1413ff46da05dc56..63aa6b82ba21ec8e8f362b390063e4e275a979a5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BigDripleafBlock.java
|
||||
@@ -170,6 +170,7 @@ public class BigDripleafBlock extends HorizontalDirectionalBlock implements Bone
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide) {
|
||||
if (state.getValue(BigDripleafBlock.TILT) == Tilt.NONE && BigDripleafBlock.canEntityTilt(pos, entity) && !world.hasNeighborSignal(pos)) {
|
||||
// CraftBukkit start - tilt dripleaf
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
|
||||
index 3da8d49f7e36d8f1c0873bec32123971e53d2a31..461288cb56793f11e8dac80720b36cb9b42da518 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
|
||||
@@ -38,6 +38,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
BlockState blockState = world.getBlockState(pos.above());
|
||||
if (blockState.isAir()) {
|
||||
entity.onAboveBubbleCol(state.getValue(DRAG_DOWN));
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
|
||||
index c187e9df237ee71562343bbb4b577b2dcd9b4f1c..a0194e78913017693df7d92516dfbacb1153a1c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ButtonBlock.java
|
||||
@@ -186,6 +186,7 @@ public abstract class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide && this.sensitive && !(Boolean) state.getValue(ButtonBlock.POWERED)) {
|
||||
this.checkPressed(state, world, pos);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
index cb3d26af146859b87fc471174f8f63dfe7caa5fd..0fbabb84ef13e68b12212d9bfeb885c78893c116 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
@@ -116,6 +116,7 @@ public class CactusBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit
|
||||
entity.hurt(DamageSource.CACTUS, 1.0F);
|
||||
CraftEventFactory.blockDamage = null; // CraftBukkit
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
|
||||
index 930421c72326fabfa3f2e3ab37c4dd6f416d6d44..a4c44cb59dee29cf227dbb51bfc1576d89dfb2e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java
|
||||
@@ -93,6 +93,7 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if ((Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) {
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit
|
||||
entity.hurt(DamageSource.IN_FIRE, (float) this.fireDamage);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
||||
index 76fc886013b6c53f7888292f8fda50abe72e43bf..275e5334b1206a2dcafc3772c7e2ad0ebe3693f9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
|
||||
@@ -163,6 +163,7 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (entity instanceof Ravager && !CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit
|
||||
world.destroyBlock(pos, true, entity);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
index 932a2c279f46c951182d2604b525b473b6945895..05dfb1790a292f9f85b641377c2ca3675726c127 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/DetectorRailBlock.java
|
||||
@@ -44,6 +44,7 @@ public class DetectorRailBlock extends BaseRailBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide) {
|
||||
if (!(Boolean) state.getValue(DetectorRailBlock.POWERED)) {
|
||||
this.checkPressed(world, pos, state);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index 3b54eb4962a0cd39e6ff7a934f814de864a16a3d..150c16da7caa655cfc2c371d3336a8d7345438c6 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -44,6 +44,7 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (world instanceof ServerLevel && !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(entity.getBoundingBox().move((double) (-pos.getX()), (double) (-pos.getY()), (double) (-pos.getZ()))), state.getShape(world, pos), BooleanOp.AND)) {
|
||||
ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
||||
ServerLevel worldserver = ((ServerLevel) world).getServer().getLevel(resourcekey);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
|
||||
index 0549256cbd7028c82bf82ccc4ff64219df7e0906..683f24251baf8ef3bef8f32ba83dc7f0e8ed7d70 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/HoneyBlock.java
|
||||
@@ -55,6 +55,7 @@ public class HoneyBlock extends HalfTransparentBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (this.isSlidingDown(pos, entity)) {
|
||||
this.maybeDoSlideAchievement(entity, pos);
|
||||
this.doSlideMovement(entity);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/HopperBlock.java b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
|
||||
index c89bce01302348115791732fb31ce48aec7239d4..45224b264c7500a9d4342864cf67e7d1550c8103 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/HopperBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/HopperBlock.java
|
||||
@@ -200,6 +200,7 @@ public class HopperBlock extends BaseEntityBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity instanceof HopperBlockEntity) {
|
||||
HopperBlockEntity.entityInside(world, pos, state, entity, (HopperBlockEntity)blockEntity);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
|
||||
index f0a3ef0529951e7732602d358ddea1782001db7e..6588b207d93d96934e72176874ba60c81e9a098c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/LavaCauldronBlock.java
|
||||
@@ -24,6 +24,7 @@ public class LavaCauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (this.isEntityInsideContent(state, pos, entity)) {
|
||||
entity.lavaHurt();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||
index 2d0191eeb746d496a481d66cdfa77078313a13ec..24d2da792bc498adf4251555a538df4cafe2e827 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/LayeredCauldronBlock.java
|
||||
@@ -60,6 +60,7 @@ public class LayeredCauldronBlock extends AbstractCauldronBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide && entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) {
|
||||
// CraftBukkit start
|
||||
if (entity.mayInteract(world, pos)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
index 8c97cae63b4b373f1d67e797b9fe1064b5205da5..08a84e8fdb242f467fb20eec73764ef71691ad42 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
@@ -85,6 +85,7 @@ public class NetherPortalBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions()) {
|
||||
// CraftBukkit start - Entity in portal
|
||||
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
|
||||
index 47f54002654d198a56a85884de34e305e545eb4b..518d3832c36c9ecf1ed9267ffc1f926dc84b7989 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/PowderSnowBlock.java
|
||||
@@ -55,6 +55,7 @@ public class PowderSnowBlock extends Block implements BucketPickup {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!(entity instanceof LivingEntity) || entity.getFeetBlockState().is((Block) this)) {
|
||||
entity.makeStuckInBlock(state, new Vec3(0.8999999761581421D, 1.5D, 0.8999999761581421D));
|
||||
if (world.isClientSide) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java
|
||||
index 272ec85b1bde4b7a9439ab8fbb2711f3adb65b55..1d28810f697565e34d59ffc8dbf55173c2a671ea 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SweetBerryBushBlock.java
|
||||
@@ -77,6 +77,7 @@ public class SweetBerryBushBlock extends BushBlock implements BonemealableBlock
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) {
|
||||
entity.makeStuckInBlock(state, new Vec3(0.800000011920929D, 0.75D, 0.800000011920929D));
|
||||
if (!world.isClientSide && (Integer) state.getValue(SweetBerryBushBlock.AGE) > 0 && (entity.xOld != entity.getX() || entity.zOld != entity.getZ())) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||
index 5e1133bf2cba55a6ec5559d8db41e1a3db582d06..4e2fb4ee8e46b3c363992ff23e26f5a648c5f003 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/TripWireBlock.java
|
||||
@@ -121,6 +121,7 @@ public class TripWireBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide) {
|
||||
if (!(Boolean) state.getValue(TripWireBlock.POWERED)) {
|
||||
this.checkPressed(world, pos);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
|
||||
index 2b2a28d0383ccc8c0e7debd90331570b02b5e65f..bd4295f8d24ca9fd8c3af31abcd13da24db1c5d5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
|
||||
@@ -25,6 +25,7 @@ public class WaterlilyBlock extends BushBlock {
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
super.entityInside(state, world, pos, entity);
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (world instanceof ServerLevel && entity instanceof Boat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit
|
||||
world.destroyBlock(new BlockPos(pos), true, entity);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/WebBlock.java b/src/main/java/net/minecraft/world/level/block/WebBlock.java
|
||||
index 6964308822ebf8a7027ce426062ba43a70c20c15..763fa221c562e96c2abd09c7055e91a86ac03d43 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/WebBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/WebBlock.java
|
||||
@@ -14,6 +14,7 @@ public class WebBlock extends Block {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
entity.makeStuckInBlock(state, new Vec3(0.25D, (double)0.05F, 0.25D));
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java b/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java
|
||||
index 7acac8e59d6d46d03f6a15f0657b6028a63f752a..7d5f7983bbbcb004a1334f22dbe47b477ea5b750 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/WitherRoseBlock.java
|
||||
@@ -46,6 +46,7 @@ public class WitherRoseBlock extends FlowerBlock {
|
||||
|
||||
@Override
|
||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper
|
||||
if (!world.isClientSide && world.getDifficulty() != Difficulty.PEACEFUL) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity entityliving = (LivingEntity) entity;
|
30
patches/server/0652-Attributes-API-for-item-defaults.patch
Normal file
30
patches/server/0652-Attributes-API-for-item-defaults.patch
Normal file
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 8 May 2021 15:01:54 -0700
|
||||
Subject: [PATCH] Attributes API for item defaults
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 44b922c9e6f022c1a9282c0cb686bbd8a8d1c675..c98c5e070349e5c9356a3dec2344a135ad8f0b56 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -545,6 +545,19 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return CraftMagicNumbers.getItem(itemToBeRepaired.getType()).isValidRepairItem(CraftItemStack.asNMSCopy(itemToBeRepaired), CraftItemStack.asNMSCopy(repairMaterial));
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public Multimap<Attribute, AttributeModifier> getItemAttributes(Material material, EquipmentSlot equipmentSlot) {
|
||||
+ Item item = CraftMagicNumbers.getItem(material);
|
||||
+ if (item == null) {
|
||||
+ throw new IllegalArgumentException(material + " is not an item and therefore does not have attributes");
|
||||
+ }
|
||||
+ ImmutableMultimap.Builder<Attribute, AttributeModifier> attributeMapBuilder = ImmutableMultimap.builder();
|
||||
+ item.getDefaultAttributeModifiers(CraftEquipmentSlot.getNMS(equipmentSlot)).forEach((attributeBase, attributeModifier) -> {
|
||||
+ attributeMapBuilder.put(CraftAttributeMap.fromMinecraft(net.minecraft.core.Registry.ATTRIBUTE.getKey(attributeBase).toString()), CraftAttributeInstance.convert(attributeModifier, equipmentSlot));
|
||||
+ });
|
||||
+ return attributeMapBuilder.build();
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public int getProtocolVersion() {
|
||||
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|
|
@ -0,0 +1,118 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 18:23:26 -0800
|
||||
Subject: [PATCH] Add cause to Weather/ThunderChangeEvents
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 3bb1fe9e6f5e8f7dc6dc07f83c5b0793760882e8..428272c1cace3a87fbcade90b5f9ee9236532418 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -494,8 +494,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.serverLevelData.setClearWeatherTime(clearDuration);
|
||||
this.serverLevelData.setRainTime(rainDuration);
|
||||
this.serverLevelData.setThunderTime(rainDuration);
|
||||
- this.serverLevelData.setRaining(raining);
|
||||
- this.serverLevelData.setThundering(thundering);
|
||||
+ this.serverLevelData.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper
|
||||
+ this.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -887,8 +887,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.serverLevelData.setThunderTime(j);
|
||||
this.serverLevelData.setRainTime(k);
|
||||
this.serverLevelData.setClearWeatherTime(i);
|
||||
- this.serverLevelData.setThundering(flag1);
|
||||
- this.serverLevelData.setRaining(flag2);
|
||||
+ this.serverLevelData.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper
|
||||
+ this.serverLevelData.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper
|
||||
}
|
||||
|
||||
this.oThunderLevel = this.thunderLevel;
|
||||
@@ -954,14 +954,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
private void resetWeatherCycle() {
|
||||
// CraftBukkit start
|
||||
- this.serverLevelData.setRaining(false);
|
||||
+ this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
|
||||
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
// Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
if (!this.serverLevelData.isRaining()) {
|
||||
this.serverLevelData.setRainTime(0);
|
||||
}
|
||||
// CraftBukkit end
|
||||
- this.serverLevelData.setThundering(false);
|
||||
+ this.serverLevelData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night
|
||||
// CraftBukkit start
|
||||
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
// Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java b/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
||||
index 401787a5b55384b9ab7755e822b3b881dc45ac45..e537a8df45c31efa80cb898cbef9c3a09fac3bf9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
||||
@@ -351,6 +351,11 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
||||
|
||||
@Override
|
||||
public void setThundering(boolean thundering) {
|
||||
+ // Paper start
|
||||
+ this.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+ public void setThundering(boolean thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
if (this.thundering == thundering) {
|
||||
return;
|
||||
@@ -358,7 +363,7 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
||||
|
||||
org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
|
||||
if (world != null) {
|
||||
- ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering);
|
||||
+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering, cause); // Paper
|
||||
Bukkit.getServer().getPluginManager().callEvent(thunder);
|
||||
if (thunder.isCancelled()) {
|
||||
return;
|
||||
@@ -385,6 +390,12 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
||||
|
||||
@Override
|
||||
public void setRaining(boolean raining) {
|
||||
+ // Paper start
|
||||
+ this.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void setRaining(boolean raining, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) {
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
if (this.raining == raining) {
|
||||
return;
|
||||
@@ -392,7 +403,7 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
||||
|
||||
org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
|
||||
if (world != null) {
|
||||
- WeatherChangeEvent weather = new WeatherChangeEvent(world, raining);
|
||||
+ WeatherChangeEvent weather = new WeatherChangeEvent(world, raining, cause); // Paper
|
||||
Bukkit.getServer().getPluginManager().callEvent(weather);
|
||||
if (weather.isCancelled()) {
|
||||
return;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 4e552504b207a91b9fbd7f2a7f6e96e1fe81cfe2..85972e19324027beaf215bed1b45947f976f5db4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1195,7 +1195,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public void setStorm(boolean hasStorm) {
|
||||
- world.levelData.setRaining(hasStorm);
|
||||
+ world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper
|
||||
this.setWeatherDuration(0); // Reset weather duration (legacy behaviour)
|
||||
this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
||||
}
|
||||
@@ -1217,7 +1217,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public void setThundering(boolean thundering) {
|
||||
- world.serverLevelData.setThundering(thundering);
|
||||
+ world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper
|
||||
this.setThunderDuration(0); // Reset weather duration (legacy behaviour)
|
||||
this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
||||
}
|
75
patches/server/0654-More-Lidded-Block-API.patch
Normal file
75
patches/server/0654-More-Lidded-Block-API.patch
Normal file
|
@ -0,0 +1,75 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: LemonCaramel <admin@caramel.moe>
|
||||
Date: Sun, 23 May 2021 17:49:51 +0900
|
||||
Subject: [PATCH] More Lidded Block API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
||||
index 9d0c272b1d89a96b0b63603fa8e4649f11fb6c51..d5fdf4504a0ca76fb0483f4ae5861c93fb622b2d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBarrel.java
|
||||
@@ -58,4 +58,11 @@ public class CraftBarrel extends CraftLootable<BarrelBlockEntity> implements Bar
|
||||
}
|
||||
getTileEntity().openersCounter.opened = false;
|
||||
}
|
||||
+
|
||||
+ // Paper start - More Lidded Block API
|
||||
+ @Override
|
||||
+ public boolean isOpen() {
|
||||
+ return getTileEntity().openersCounter.opened;
|
||||
+ }
|
||||
+ // Paper end - More Lidded Block API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
index 82b3f3b3aced73ce136b6b94fe212972ac6090ef..b4bc5cbb71007b4d1a27bb841ff787a95e9ecbdc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
@@ -78,4 +78,11 @@ public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest
|
||||
}
|
||||
getTileEntity().openersCounter.opened = false;
|
||||
}
|
||||
+
|
||||
+ // Paper start - More Lidded Block API
|
||||
+ @Override
|
||||
+ public boolean isOpen() {
|
||||
+ return getTileEntity().openersCounter.opened;
|
||||
+ }
|
||||
+ // Paper end - More Lidded Block API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
|
||||
index 6513acb46591b2903d1baf18c23ed1fc8c2a731f..b8ab67fd1820613520203f708f2f267587ace67b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java
|
||||
@@ -36,4 +36,11 @@ public class CraftEnderChest extends CraftBlockEntityState<EnderChestBlockEntity
|
||||
}
|
||||
getTileEntity().openersCounter.opened = false;
|
||||
}
|
||||
+
|
||||
+ // Paper start - More Lidded Block API
|
||||
+ @Override
|
||||
+ public boolean isOpen() {
|
||||
+ return getTileEntity().openersCounter.opened;
|
||||
+ }
|
||||
+ // Paper end - More Lidded Block API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
|
||||
index 2d5205a9adfa66545f40a13bf0e37dc62ac0fdb9..72074b4c0feea8136e80589345538552ce28a2ea 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftShulkerBox.java
|
||||
@@ -55,8 +55,15 @@ public class CraftShulkerBox extends CraftLootable<ShulkerBoxBlockEntity> implem
|
||||
if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.Level) {
|
||||
net.minecraft.world.level.Level world = getTileEntity().getLevel();
|
||||
world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0);
|
||||
- world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound)
|
||||
}
|
||||
getTileEntity().opened = false;
|
||||
}
|
||||
+
|
||||
+ // Paper start - More Lidded Block API
|
||||
+ @Override
|
||||
+ public boolean isOpen() {
|
||||
+ return getTileEntity().opened;
|
||||
+ }
|
||||
+ // Paper end - More Lidded Block API
|
||||
}
|
23
patches/server/0655-Limit-item-frame-cursors-on-maps.patch
Normal file
23
patches/server/0655-Limit-item-frame-cursors-on-maps.patch
Normal file
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Yive <admin@yive.me>
|
||||
Date: Wed, 26 May 2021 15:09:33 -0700
|
||||
Subject: [PATCH] Limit item frame cursors on maps
|
||||
|
||||
|
||||
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 4acbcafc158cf11af51d9518ba5b83aaa75f52a1..67b88da702b780f79c0496cb17f1e6f1f8dd6c2b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
@@ -295,8 +295,12 @@ public class MapItemSavedData extends SavedData {
|
||||
|
||||
MapFrame worldmapframe1 = new MapFrame(blockposition, entityitemframe.getDirection().get2DDataValue() * 90, entityitemframe.getId());
|
||||
|
||||
+ // Paper start
|
||||
+ if (this.decorations.size() < player.level.paperConfig().maps.itemFrameCursorLimit) {
|
||||
this.addDecoration(MapDecoration.Type.FRAME, player.level, "frame-" + entityitemframe.getId(), (double) blockposition.getX(), (double) blockposition.getZ(), (double) (entityitemframe.getDirection().get2DDataValue() * 90), (Component) null);
|
||||
this.frameMarkers.put(worldmapframe1.getId(), worldmapframe1);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
CompoundTag nbttagcompound = stack.getTag();
|
377
patches/server/0656-Add-PlayerKickEvent-causes.patch
Normal file
377
patches/server/0656-Add-PlayerKickEvent-causes.patch
Normal file
|
@ -0,0 +1,377 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 15 May 2021 20:30:45 -0700
|
||||
Subject: [PATCH] Add PlayerKickEvent causes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index fdf08831a9d1b27c8050432e958f7133f3d10e1e..d605c4355674644e47ea5ea9e979f7806aed1607 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2101,7 +2101,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
if (!whitelist.isWhiteListed(entityplayer.getGameProfile()) && !this.getPlayerList().isOp(entityplayer.getGameProfile())) { // Paper - Fix kicking ops when whitelist is reloaded (MC-171420)
|
||||
- entityplayer.connection.disconnect(org.spigotmc.SpigotConfig.whitelistMessage); // Paper - use configurable message
|
||||
+ entityplayer.connection.disconnect(org.spigotmc.SpigotConfig.whitelistMessage, org.bukkit.event.player.PlayerKickEvent.Cause.WHITELIST); // Paper - use configurable message
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/BanIpCommands.java b/src/main/java/net/minecraft/server/commands/BanIpCommands.java
|
||||
index 37c6be64f618857abcbdbfe2a1fd58ed4f997a29..19023c0796f0b6d7b4acd4ff8984355ec5b3faa7 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/BanIpCommands.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/BanIpCommands.java
|
||||
@@ -61,7 +61,7 @@ public class BanIpCommands {
|
||||
}
|
||||
|
||||
for(ServerPlayer serverPlayer : list) {
|
||||
- serverPlayer.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"));
|
||||
+ serverPlayer.connection.disconnect(Component.translatable("multiplayer.disconnect.ip_banned"), org.bukkit.event.player.PlayerKickEvent.Cause.IP_BANNED); // Paper - kick event cause
|
||||
}
|
||||
|
||||
return list.size();
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java b/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java
|
||||
index 991d9a2bfd8d577c9c25e559833af9ddf690f1dc..458b9a730a1f629bd605c26a4ec4440e8ee84b1d 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/BanPlayerCommands.java
|
||||
@@ -42,7 +42,7 @@ public class BanPlayerCommands {
|
||||
source.sendSuccess(Component.translatable("commands.ban.success", ComponentUtils.getDisplayName(gameProfile), userBanListEntry.getReason()), true);
|
||||
ServerPlayer serverPlayer = source.getServer().getPlayerList().getPlayer(gameProfile.getId());
|
||||
if (serverPlayer != null) {
|
||||
- serverPlayer.connection.disconnect(Component.translatable("multiplayer.disconnect.banned"));
|
||||
+ serverPlayer.connection.disconnect(Component.translatable("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/KickCommand.java b/src/main/java/net/minecraft/server/commands/KickCommand.java
|
||||
index 65637a33ba171a4b598f70cd943d24b0ee44a69f..57a9146bf2dee7a60aab16716e25348fad7ba127 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/KickCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/KickCommand.java
|
||||
@@ -22,7 +22,7 @@ public class KickCommand {
|
||||
|
||||
private static int kickPlayers(CommandSourceStack source, Collection<ServerPlayer> targets, Component reason) {
|
||||
for(ServerPlayer serverPlayer : targets) {
|
||||
- serverPlayer.connection.disconnect(reason);
|
||||
+ serverPlayer.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause
|
||||
source.sendSuccess(Component.translatable("commands.kick.success", serverPlayer.getDisplayName(), reason), true);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index cc1225f7c1e4d47f509c55609066fba084331a4d..a768e09c5ce6718435b50f1502c5ace773fff470 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -372,7 +372,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger()) {
|
||||
if (++this.aboveGroundTickCount > 80) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
|
||||
- this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer); // Paper - use configurable kick message
|
||||
+ this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_PLAYER); // Paper - use configurable kick message & kick event cause
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -391,7 +391,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (this.clientVehicleIsFloating && this.player.getRootVehicle().getControllingPassenger() == this.player) {
|
||||
if (++this.aboveGroundVehicleTickCount > 80) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
|
||||
- this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle); // Paper - use configurable kick message
|
||||
+ this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_VEHICLE); // Paper - use configurable kick message & kick event cause
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -413,7 +413,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (this.keepAlivePending) {
|
||||
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
|
||||
- this.disconnect(Component.translatable("disconnect.timeout", new Object[0]));
|
||||
+ this.disconnect(Component.translatable("disconnect.timeout", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
|
||||
}
|
||||
} else {
|
||||
if (elapsedTime >= 15000L) { // 15 seconds
|
||||
@@ -443,7 +443,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
|
||||
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.idling"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
||||
|
||||
this.chatPreviewThrottler.tick();
|
||||
@@ -469,14 +469,22 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
public void disconnect(String s) {
|
||||
// Paper start
|
||||
- this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s));
|
||||
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void disconnect(String s, PlayerKickEvent.Cause cause) {
|
||||
+ this.disconnect(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(s), cause);
|
||||
}
|
||||
|
||||
public void disconnect(final Component reason) {
|
||||
- this.disconnect(PaperAdventure.asAdventure(reason));
|
||||
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
- public void disconnect(net.kyori.adventure.text.Component reason) {
|
||||
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
|
||||
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
|
||||
+ }
|
||||
+
|
||||
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
|
||||
// Paper end
|
||||
// CraftBukkit start - fire PlayerKickEvent
|
||||
if (this.processedDisconnect) {
|
||||
@@ -505,7 +513,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
net.kyori.adventure.text.Component leaveMessage = net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? this.player.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(this.player.getScoreboardName())); // Paper - Adventure
|
||||
|
||||
- PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage); // Paper - Adventure
|
||||
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), reason, leaveMessage, cause); // Paper - Adventure & kick event reason
|
||||
|
||||
if (this.cserver.getServer().isRunning()) {
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
@@ -575,7 +583,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(), packet.getY(), packet.getZ(), packet.getYRot(), packet.getXRot())) {
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.invalid_vehicle_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_VEHICLE_MOVEMENT); // Paper - kick event cause
|
||||
} else {
|
||||
Entity entity = this.player.getRootVehicle();
|
||||
|
||||
@@ -826,13 +834,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async
|
||||
// CraftBukkit start
|
||||
if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable
|
||||
- server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper
|
||||
+ server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
// Paper start
|
||||
String str = packet.getCommand(); int index = -1;
|
||||
if (str.length() > 64 && ((index = str.indexOf(' ')) == -1 || index >= 64)) {
|
||||
- server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper
|
||||
+ server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
// Paper end
|
||||
@@ -985,7 +993,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Paper start - validate pick item position
|
||||
if (!(packet.getSlot() >= 0 && packet.getSlot() < this.player.getInventory().items.size())) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
- this.disconnect("Invalid hotbar selection (Hacking?)");
|
||||
+ this.disconnect("Invalid hotbar selection (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
|
||||
@@ -1172,7 +1180,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
||||
if (byteLength > 256 * 4) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!");
|
||||
- server.scheduleOnMain(() -> this.disconnect("Book too large!"));
|
||||
+ server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
byteTotal += byteLength;
|
||||
@@ -1195,14 +1203,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
if (byteTotal > byteAllowed) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size());
|
||||
- server.scheduleOnMain(() -> this.disconnect("Book too large!"));
|
||||
+ server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
// CraftBukkit start
|
||||
if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
|
||||
- this.disconnect("Book edited too quickly!");
|
||||
+ this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
this.lastBookTick = MinecraftServer.currentTick;
|
||||
@@ -1326,7 +1334,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (ServerGamePacketListenerImpl.containsInvalidValues(packet.getX(0.0D), packet.getY(0.0D), packet.getZ(0.0D), packet.getYRot(0.0F), packet.getXRot(0.0F))) {
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"));
|
||||
+ this.disconnect(Component.translatable(("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT)); // Paper - kick event cause
|
||||
} else {
|
||||
ServerLevel worldserver = this.player.getLevel();
|
||||
|
||||
@@ -1753,7 +1761,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.dropCount++;
|
||||
if (this.dropCount >= 20) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
- this.disconnect("You dropped your items too quickly (Hacking?)");
|
||||
+ this.disconnect("You dropped your items too quickly (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1961,7 +1969,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (packet.getAction() == ServerboundResourcePackPacket.Action.DECLINED && this.server.isResourcePackRequired()) {
|
||||
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
||||
- this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"), org.bukkit.event.player.PlayerKickEvent.Cause.RESOURCE_PACK_REJECTION); // Paper - add cause
|
||||
}
|
||||
// Paper start
|
||||
PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
|
||||
@@ -2074,7 +2082,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
- this.disconnect("Invalid hotbar selection (Hacking?)"); // CraftBukkit
|
||||
+ this.disconnect("Invalid hotbar selection (Hacking?)", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // CraftBukkit // Paper - kick event cause
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2087,7 +2095,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.message())) {
|
||||
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
||||
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
|
||||
} else {
|
||||
if (this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages())) {
|
||||
// this.server.submit(() -> { // CraftBukkit - async chat
|
||||
@@ -2478,7 +2486,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// this.chatSpamTickCount += 20;
|
||||
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
// CraftBukkit end
|
||||
- this.disconnect(Component.translatable("disconnect.spam"));
|
||||
+ this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - kick event cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2740,7 +2748,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Spigot Start
|
||||
if ( entity == this.player && !this.player.isSpectator() )
|
||||
{
|
||||
- this.disconnect( "Cannot interact with self!" );
|
||||
+ this.disconnect( "Cannot interact with self!", org.bukkit.event.player.PlayerKickEvent.Cause.SELF_INTERACTION ); // Paper - add cause
|
||||
return;
|
||||
}
|
||||
// Spigot End
|
||||
@@ -2833,7 +2841,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
// CraftBukkit end
|
||||
} else {
|
||||
- ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
||||
+ ServerGamePacketListenerImpl.this.disconnect(Component.translatable("multiplayer.disconnect.invalid_entity_attacked"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_ENTITY_ATTACKED); // Paper - add cause
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getName().getString());
|
||||
}
|
||||
}
|
||||
@@ -3241,7 +3249,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Paper start
|
||||
if (!org.bukkit.Bukkit.isPrimaryThread()) {
|
||||
if (recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) {
|
||||
- server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]))); // Paper
|
||||
+ server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3444,7 +3452,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
} else if (!this.isSingleplayerOwner()) {
|
||||
// Paper start - This needs to be handled on the main thread for plugins
|
||||
server.submit(() -> {
|
||||
- this.disconnect(Component.translatable("disconnect.timeout"));
|
||||
+ this.disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
|
||||
});
|
||||
// Paper end
|
||||
}
|
||||
@@ -3490,7 +3498,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
|
||||
- this.disconnect("Invalid payload REGISTER!");
|
||||
+ this.disconnect("Invalid payload REGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause
|
||||
}
|
||||
} else if (packet.identifier.equals(CUSTOM_UNREGISTER)) {
|
||||
try {
|
||||
@@ -3500,7 +3508,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t unregister custom payload", ex);
|
||||
- this.disconnect("Invalid payload UNREGISTER!");
|
||||
+ this.disconnect("Invalid payload UNREGISTER!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -3518,7 +3526,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
- this.disconnect("Invalid custom payload!");
|
||||
+ this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD); // Paper - kick event cause
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 3e8934a141bc8c650549afaef7b4f8b02371f9ab..9dece3470d617be02248f41847ebf77ed083653a 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -723,7 +723,7 @@ public abstract class PlayerList {
|
||||
while (iterator.hasNext()) {
|
||||
entityplayer = (ServerPlayer) iterator.next();
|
||||
this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
|
||||
- entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"));
|
||||
+ entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login", new Object[0]), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause
|
||||
}
|
||||
|
||||
// Instead of kicking then returning, we need to store the kick reason
|
||||
@@ -1354,8 +1354,8 @@ public abstract class PlayerList {
|
||||
// Paper end
|
||||
// CraftBukkit start - disconnect safely
|
||||
for (ServerPlayer player : this.players) {
|
||||
- if (isRestarting) player.connection.disconnect(org.spigotmc.SpigotConfig.restartMessage); else // Paper
|
||||
- player.connection.disconnect(this.server.server.shutdownMessage()); // CraftBukkit - add custom shutdown message // Paper - Adventure
|
||||
+ if (isRestarting) player.connection.disconnect(org.spigotmc.SpigotConfig.restartMessage, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); else // Paper - kick event cause (cause is never used here)
|
||||
+ player.connection.disconnect(this.server.server.shutdownMessage(), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); // CraftBukkit - add custom shutdown message // Paper - Adventure & KickEventCause (cause is never used here)
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index cacadcbffdc9629e693dfea6185009ebca2740f6..8ffef2843d8d4fa6ddfc0fb1403c6eacdafa63a9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -516,7 +516,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
org.spigotmc.AsyncCatcher.catchOp("player kick"); // Spigot
|
||||
if (this.getHandle().connection == null) return;
|
||||
|
||||
- this.getHandle().connection.disconnect(message == null ? "" : message);
|
||||
+ this.getHandle().connection.disconnect(message == null ? "" : message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); // Paper - kick event cause
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@@ -528,10 +528,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void kick(final net.kyori.adventure.text.Component message) {
|
||||
+ kick(message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void kick(net.kyori.adventure.text.Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("player kick");
|
||||
final ServerGamePacketListenerImpl connection = this.getHandle().connection;
|
||||
if (connection != null) {
|
||||
- connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message);
|
||||
+ connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
index 92d97a5810a379b427a99b4c63fb9844d823a84f..160115bf8a153ff981ba308599d22c4c08026fb6 100644
|
||||
--- a/src/main/java/org/spigotmc/RestartCommand.java
|
||||
+++ b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
@@ -74,7 +74,7 @@ public class RestartCommand extends Command
|
||||
// Kick all players
|
||||
for ( ServerPlayer p : com.google.common.collect.ImmutableList.copyOf( MinecraftServer.getServer().getPlayerList().players ) )
|
||||
{
|
||||
- p.connection.disconnect(SpigotConfig.restartMessage);
|
||||
+ p.connection.disconnect(SpigotConfig.restartMessage, org.bukkit.event.player.PlayerKickEvent.Cause.RESTART_COMMAND); // Paper - kick event reason (cause is never used))
|
||||
}
|
||||
// Give the socket a chance to send the packets
|
||||
try
|
50
patches/server/0657-Add-PufferFishStateChangeEvent.patch
Normal file
50
patches/server/0657-Add-PufferFishStateChangeEvent.patch
Normal file
|
@ -0,0 +1,50 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
|
||||
Date: Mon, 10 May 2021 16:59:05 +0100
|
||||
Subject: [PATCH] Add PufferFishStateChangeEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Pufferfish.java b/src/main/java/net/minecraft/world/entity/animal/Pufferfish.java
|
||||
index 9169e0c76b1801aad760691a6090199fdb7f6585..ce02552c1b3c62cf9f48425838a129a3ec40a049 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Pufferfish.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Pufferfish.java
|
||||
@@ -95,25 +95,39 @@ public class Pufferfish extends AbstractFish {
|
||||
public void tick() {
|
||||
if (!this.level.isClientSide && this.isAlive() && this.isEffectiveAi()) {
|
||||
if (this.inflateCounter > 0) {
|
||||
+ boolean increase = true; // Paper - Add PufferFishStateChangeEvent
|
||||
if (this.getPuffState() == 0) {
|
||||
+ if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 1).callEvent()) { // Paper - Add PufferFishStateChangeEvent
|
||||
this.playSound(SoundEvents.PUFFER_FISH_BLOW_UP, this.getSoundVolume(), this.getVoicePitch());
|
||||
this.setPuffState(1);
|
||||
+ } else { increase = false; } // Paper - Add PufferFishStateChangeEvent
|
||||
} else if (this.inflateCounter > 40 && this.getPuffState() == 1) {
|
||||
+ if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 2).callEvent()) { // Paper - Add PufferFishStateChangeEvent
|
||||
this.playSound(SoundEvents.PUFFER_FISH_BLOW_UP, this.getSoundVolume(), this.getVoicePitch());
|
||||
this.setPuffState(2);
|
||||
+ } else { increase = false; } // Paper - Add PufferFishStateChangeEvent
|
||||
}
|
||||
|
||||
+ if (increase) { // Paper - Add PufferFishStateChangeEvent
|
||||
++this.inflateCounter;
|
||||
+ } // Paper - Add PufferFishStateChangeEvent
|
||||
} else if (this.getPuffState() != 0) {
|
||||
+ boolean increase = true; // Paper - Add PufferFishStateChangeEvent
|
||||
if (this.deflateTimer > 60 && this.getPuffState() == 2) {
|
||||
+ if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 1).callEvent()) { // Paper - Add PufferFishStateChangeEvent
|
||||
this.playSound(SoundEvents.PUFFER_FISH_BLOW_OUT, this.getSoundVolume(), this.getVoicePitch());
|
||||
this.setPuffState(1);
|
||||
+ } else { increase = false; } // Paper - Add PufferFishStateChangeEvent
|
||||
} else if (this.deflateTimer > 100 && this.getPuffState() == 1) {
|
||||
+ if (new io.papermc.paper.event.entity.PufferFishStateChangeEvent((org.bukkit.entity.PufferFish) getBukkitEntity(), 0).callEvent()) { // Paper - Add PufferFishStateChangeEvent
|
||||
this.playSound(SoundEvents.PUFFER_FISH_BLOW_OUT, this.getSoundVolume(), this.getVoicePitch());
|
||||
this.setPuffState(0);
|
||||
+ } else { increase = false; } // Paper - Add PufferFishStateChangeEvent
|
||||
}
|
||||
|
||||
+ if (increase) { // Paper - Add PufferFishStateChangeEvent
|
||||
++this.deflateTimer;
|
||||
+ } // Paper - Add PufferFishStateChangeEvent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 20 May 2021 22:16:37 -0700
|
||||
Subject: [PATCH] Fix PlayerBucketEmptyEvent result itemstack
|
||||
|
||||
Fixes SPIGOT-2560: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-2560
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
|
||||
index 7c6c928da4e0f3ac54fa9b9ddce7b0e0bf3cce4b..73f1211470d9626c82c8345037da19aed9db3f23 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
|
||||
@@ -40,6 +40,8 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
|
||||
public class BucketItem extends Item implements DispensibleContainerItem {
|
||||
|
||||
+ private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper
|
||||
+
|
||||
public final Fluid content;
|
||||
|
||||
public BucketItem(Fluid fluid, Item.Properties settings) {
|
||||
@@ -121,6 +123,13 @@ public class BucketItem extends Item implements DispensibleContainerItem {
|
||||
}
|
||||
|
||||
public static ItemStack getEmptySuccessItem(ItemStack stack, Player player) {
|
||||
+ // Paper start
|
||||
+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) {
|
||||
+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent;
|
||||
+ itemLeftInHandAfterPlayerBucketEmptyEvent = null;
|
||||
+ return itemInHand;
|
||||
+ }
|
||||
+ // Paper end
|
||||
return !player.getAbilities().instabuild ? new ItemStack(Items.BUCKET) : stack;
|
||||
}
|
||||
|
||||
@@ -153,6 +162,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
|
||||
((ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
||||
return false;
|
||||
}
|
||||
+ itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack() != null ? event.getItemStack().equals(CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; // Paper - fix empty event result itemstack
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (!flag1) {
|
|
@ -0,0 +1,91 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 29 May 2020 20:29:02 -0400
|
||||
Subject: [PATCH] Synchronize PalettedContainer instead of
|
||||
ThreadingDetector/Semaphore
|
||||
|
||||
Mojang has flaws in their logic about chunks being concurrently
|
||||
wrote to. So we constantly see crashes around multiple threads writing.
|
||||
|
||||
Additionally, java has optimized synchronization so well that its
|
||||
in many times faster than trying to manage read write locks for low
|
||||
contention situations.
|
||||
|
||||
And this is extremely a low contention situation.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 723608946947fa2792c7284fa5faa85ab9507897..e77b516995666402cc8814ac78a6c11077108b2e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -32,14 +32,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values
|
||||
private volatile PalettedContainer.Data<T> data;
|
||||
private final PalettedContainer.Strategy strategy;
|
||||
- private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer");
|
||||
+ // private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused
|
||||
|
||||
public void acquire() {
|
||||
- this.threadingDetector.checkAndLock();
|
||||
+ // this.threadingDetector.checkAndLock(); // Paper - disable this - use proper synchronization
|
||||
}
|
||||
|
||||
public void release() {
|
||||
- this.threadingDetector.checkAndUnlock();
|
||||
+ // this.threadingDetector.checkAndUnlock(); // Paper - disable this
|
||||
}
|
||||
|
||||
// Paper start - Anti-Xray - Add preset values
|
||||
@@ -129,7 +129,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int onResize(int newBits, T object) {
|
||||
+ public synchronized int onResize(int newBits, T object) { // Paper - synchronize
|
||||
PalettedContainer.Data<T> data = this.data;
|
||||
|
||||
// Paper start - Anti-Xray - Add preset values
|
||||
@@ -176,7 +176,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
return this.getAndSet(this.strategy.getIndex(x, y, z), value);
|
||||
}
|
||||
|
||||
- private T getAndSet(int index, T value) {
|
||||
+ private synchronized T getAndSet(int index, T value) { // Paper - synchronize
|
||||
int i = this.data.palette.idFor(value);
|
||||
int j = this.data.storage.getAndSet(index, i);
|
||||
return this.data.palette.valueFor(j);
|
||||
@@ -193,7 +193,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
|
||||
}
|
||||
|
||||
- private void set(int index, T value) {
|
||||
+ private synchronized void set(int index, T value) { // Paper - synchronize
|
||||
int i = this.data.palette.idFor(value);
|
||||
this.data.storage.set(index, i);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
});
|
||||
}
|
||||
|
||||
- public void read(FriendlyByteBuf buf) {
|
||||
+ public synchronized void read(FriendlyByteBuf buf) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
try {
|
||||
@@ -238,7 +238,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
@Override
|
||||
@Deprecated @io.papermc.paper.annotation.DoNotUse public void write(FriendlyByteBuf buf) { this.write(buf, null, 0); }
|
||||
@Override
|
||||
- public void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) {
|
||||
+ public synchronized void write(FriendlyByteBuf buf, @Nullable com.destroystokyo.paper.antixray.ChunkPacketInfo<T> chunkPacketInfo, int bottomBlockY) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
try {
|
||||
@@ -296,7 +296,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
- public PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) {
|
||||
+ public synchronized PalettedContainerRO.PackedData<T> pack(IdMap<T> idList, PalettedContainer.Strategy paletteProvider) { // Paper - synchronize
|
||||
this.acquire();
|
||||
|
||||
PalettedContainerRO.PackedData var12;
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: GioSDA <gsdambrosio@gmail.com>
|
||||
Date: Wed, 10 Mar 2021 10:06:45 -0800
|
||||
Subject: [PATCH] Add option to fix items merging through walls
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 7e293167e73238f42fc213ee29d89aa775cf9e60..30c417c3169c1df43662fd77ac6816db64a42802 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -245,6 +245,14 @@ public class ItemEntity extends Entity {
|
||||
ItemEntity entityitem = (ItemEntity) iterator.next();
|
||||
|
||||
if (entityitem.isMergable()) {
|
||||
+ // Paper Start - Fix items merging through walls
|
||||
+ if (this.level.paperConfig().fixes.fixItemsMergingThroughWalls) {
|
||||
+ net.minecraft.world.level.ClipContext rayTrace = new net.minecraft.world.level.ClipContext(this.position(), entityitem.position(),
|
||||
+ net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, this);
|
||||
+ net.minecraft.world.phys.BlockHitResult rayTraceResult = level.clip(rayTrace);
|
||||
+ if (rayTraceResult.getType() == net.minecraft.world.phys.HitResult.Type.BLOCK) continue;
|
||||
+ }
|
||||
+ // Paper End
|
||||
this.tryToMerge(entityitem);
|
||||
if (this.isRemoved()) {
|
||||
break;
|
32
patches/server/0661-Add-BellRevealRaiderEvent.patch
Normal file
32
patches/server/0661-Add-BellRevealRaiderEvent.patch
Normal file
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Wed, 26 May 2021 17:09:07 -0400
|
||||
Subject: [PATCH] Add BellRevealRaiderEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
index feaad48e9bbc1e658324ef9e1e7e73aca0b3bf48..b9d2c38e80924f52dcf76ec1042d2d746e77ffc6 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BellBlockEntity.java
|
||||
@@ -138,7 +138,7 @@ public class BellBlockEntity extends BlockEntity {
|
||||
private static void makeRaidersGlow(Level world, BlockPos pos, List<LivingEntity> hearingEntities) {
|
||||
hearingEntities.stream().filter((entity) -> {
|
||||
return isRaiderWithinRange(pos, entity);
|
||||
- }).forEach(BellBlockEntity::glow);
|
||||
+ }).forEach(entity -> glow(entity, pos)); // Paper - pass BlockPos
|
||||
}
|
||||
|
||||
private static void showBellParticles(Level world, BlockPos pos, List<LivingEntity> hearingEntities) {
|
||||
@@ -170,7 +170,11 @@ public class BellBlockEntity extends BlockEntity {
|
||||
return entity.isAlive() && !entity.isRemoved() && pos.closerToCenterThan(entity.position(), 48.0D) && entity.getType().is(EntityTypeTags.RAIDERS);
|
||||
}
|
||||
|
||||
- private static void glow(LivingEntity entity) {
|
||||
+ // Paper start
|
||||
+ private static void glow(LivingEntity entity) { glow(entity, null); }
|
||||
+ private static void glow(LivingEntity entity, @javax.annotation.Nullable BlockPos pos) {
|
||||
+ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level.getWorld().getBlockAt(net.minecraft.server.MCUtil.toLocation(entity.level, pos)), entity.getBukkitEntity()).callEvent()) return;
|
||||
+ // Paper end
|
||||
entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60));
|
||||
}
|
||||
|
65
patches/server/0662-Fix-invulnerable-end-crystals.patch
Normal file
65
patches/server/0662-Fix-invulnerable-end-crystals.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Max Lee <max@themoep.de>
|
||||
Date: Thu, 27 May 2021 14:52:30 -0700
|
||||
Subject: [PATCH] Fix invulnerable end crystals
|
||||
|
||||
MC-108513
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
|
||||
index 78b0456a3f9e3f66d467386c3e5f68d07adf1977..6a08ab40e60b80f8f5c4d3f02da121be9da05111 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
|
||||
@@ -30,6 +30,7 @@ public class EndCrystal extends Entity {
|
||||
private static final EntityDataAccessor<Optional<BlockPos>> DATA_BEAM_TARGET = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.OPTIONAL_BLOCK_POS);
|
||||
private static final EntityDataAccessor<Boolean> DATA_SHOW_BOTTOM = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.BOOLEAN);
|
||||
public int time;
|
||||
+ public boolean generatedByDragonFight = false; // Paper - Fix invulnerable end crystals
|
||||
|
||||
public EndCrystal(EntityType<? extends EndCrystal> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -66,6 +67,17 @@ public class EndCrystal extends Entity {
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ // Paper start - Fix invulnerable end crystals
|
||||
+ if (this.level.paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) {
|
||||
+ if (!java.util.Objects.equals(((ServerLevel) this.level).uuid, this.getOriginWorld())
|
||||
+ || ((ServerLevel) this.level).dragonFight() == null
|
||||
+ || ((ServerLevel) this.level).dragonFight().respawnStage == null
|
||||
+ || ((ServerLevel) this.level).dragonFight().respawnStage.ordinal() > net.minecraft.world.level.dimension.end.DragonRespawnAnimation.SUMMONING_DRAGON.ordinal()) {
|
||||
+ this.setInvulnerable(false);
|
||||
+ this.setBeamTarget(null);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +89,7 @@ public class EndCrystal extends Entity {
|
||||
}
|
||||
|
||||
nbt.putBoolean("ShowBottom", this.showsBottom());
|
||||
+ if (this.generatedByDragonFight) nbt.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +101,7 @@ public class EndCrystal extends Entity {
|
||||
if (nbt.contains("ShowBottom", 1)) {
|
||||
this.setShowBottom(nbt.getBoolean("ShowBottom"));
|
||||
}
|
||||
+ if (nbt.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = nbt.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
||||
index 8e51c2bc6dc6483b2c670348daf793ca4d59e5b9..94209f8c02656c113b537093cbbfaba1b9871045 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
||||
@@ -99,6 +99,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
|
||||
endCrystal.setBeamTarget(config.getCrystalBeamTarget());
|
||||
endCrystal.setInvulnerable(config.isCrystalInvulnerable());
|
||||
endCrystal.moveTo((double)spike.getCenterX() + 0.5D, (double)(spike.getHeight() + 1), (double)spike.getCenterZ() + 0.5D, random.nextFloat() * 360.0F, 0.0F);
|
||||
+ endCrystal.generatedByDragonFight = true; // Paper
|
||||
world.addFreshEntity(endCrystal);
|
||||
this.setBlock(world, new BlockPos(spike.getCenterX(), spike.getHeight(), spike.getCenterZ()), Blocks.BEDROCK.defaultBlockState());
|
||||
}
|
48
patches/server/0663-Add-ElderGuardianAppearanceEvent.patch
Normal file
48
patches/server/0663-Add-ElderGuardianAppearanceEvent.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Fri, 19 Mar 2021 23:39:09 -0400
|
||||
Subject: [PATCH] Add ElderGuardianAppearanceEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffectUtil.java b/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
index f6c22fbad828afa29b9374b13d7bc8ac8cac7891..aefc65a81c91dac715df6d9a4eaaacd94f918cb5 100644
|
||||
--- a/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
@@ -53,10 +53,23 @@ public final class MobEffectUtil {
|
||||
}
|
||||
|
||||
public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
||||
+ // Paper start
|
||||
+ return addEffectToPlayersAround(worldserver, entity, vec3d, d0, mobeffect, i, cause, null);
|
||||
+ }
|
||||
+
|
||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
MobEffect mobeffectlist = mobeffect.getEffect();
|
||||
List<ServerPlayer> list = worldserver.getPlayers((entityplayer) -> {
|
||||
- return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).getDuration() < i);
|
||||
+ // Paper start
|
||||
+ boolean condition = entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).getDuration() < i);
|
||||
+ if (condition) {
|
||||
+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper ned
|
||||
});
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java b/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
index 0b6c6740e1411a558d224589b3786f3ba8e0a1bc..d02286d553c600fe7e75f48e278e380d21c5b868 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
@@ -67,7 +67,7 @@ public class ElderGuardian extends Guardian {
|
||||
super.customServerAiStep();
|
||||
if ((this.tickCount + this.getId()) % 1200 == 0) {
|
||||
MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2);
|
||||
- List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
+ List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
|
86
patches/server/0664-Fix-dangerous-end-portal-logic.patch
Normal file
86
patches/server/0664-Fix-dangerous-end-portal-logic.patch
Normal file
|
@ -0,0 +1,86 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@users.noreply.github.com>
|
||||
Date: Fri, 4 Jun 2021 17:06:52 -0400
|
||||
Subject: [PATCH] Fix dangerous end portal logic
|
||||
|
||||
End portals could teleport entities during move calls. Stupid
|
||||
logic given the caller will never expect that kind of thing,
|
||||
and will result in all kinds of dupes.
|
||||
|
||||
Move the tick logic into the post tick, where portaling was
|
||||
designed to happen in the first place.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index bfac12f0e89c4c7d48321ea608363518742304af..4888873a5efa026a1082c9f216eecc950b6f2471 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -459,6 +459,36 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this));
|
||||
}
|
||||
// Paper end - optimise entity tracking
|
||||
+ // Paper start - make end portalling safe
|
||||
+ public BlockPos portalBlock;
|
||||
+ public ServerLevel portalWorld;
|
||||
+ public void tickEndPortal() {
|
||||
+ BlockPos pos = this.portalBlock;
|
||||
+ ServerLevel world = this.portalWorld;
|
||||
+ this.portalBlock = null;
|
||||
+ this.portalWorld = null;
|
||||
+
|
||||
+ if (pos == null || world == null || world != this.level) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (this.isPassenger() || this.isVehicle() || !this.canChangeDimensions() || this.isRemoved() || !this.valid || !this.isAlive()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
||||
+ ServerLevel worldserver = world.getServer().getLevel(resourcekey);
|
||||
+
|
||||
+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(this.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+ event.callEvent();
|
||||
+
|
||||
+ if (this instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer)this).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
||||
+ return;
|
||||
+ }
|
||||
+ this.teleportTo(worldserver, null);
|
||||
+ }
|
||||
+ // Paper end - make end portalling safe
|
||||
|
||||
public Entity(EntityType<?> type, Level world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
@@ -2621,6 +2651,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
this.processPortalCooldown();
|
||||
+ this.tickEndPortal(); // Paper - make end portalling safe
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index 150c16da7caa655cfc2c371d3336a8d7345438c6..15c5cccfe02c924c02f605eb47dd0b420b189891 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -53,16 +53,10 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
- // CraftBukkit start - Entity in portal
|
||||
- EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
- world.getCraftServer().getPluginManager().callEvent(event);
|
||||
-
|
||||
- if (entity instanceof ServerPlayer) {
|
||||
- ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
||||
- return;
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
- entity.changeDimension(worldserver);
|
||||
+ // Paper start - move all of this logic into portal tick
|
||||
+ entity.portalWorld = ((ServerLevel)world);
|
||||
+ entity.portalBlock = pos.immutable();
|
||||
+ // Paper end - move all of this logic into portal tick
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 12 Sep 2018 21:47:01 -0400
|
||||
Subject: [PATCH] Optimize Biome Mob Lookups for Mob Spawning
|
||||
|
||||
Uses an EnumMap as well as a Set paired List for O(1) contains calls.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
index 08e3a3c250056227c518a15d5df38b346abae45a..7c92decbf0f4a10cc31f821a249749009d8b1485 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
@@ -59,11 +59,43 @@ public class MobSpawnSettings {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
- private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values()).collect(ImmutableMap.toImmutableMap((mobCategory) -> {
|
||||
+ // Paper start - keep track of data in a pair set to give O(1) contains calls - we have to hook removals incase plugins mess with it
|
||||
+ public static class MobList extends java.util.ArrayList<MobSpawnSettings.SpawnerData> {
|
||||
+ java.util.Set<MobSpawnSettings.SpawnerData> biomes = new java.util.HashSet<>();
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean contains(Object o) {
|
||||
+ return biomes.contains(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean add(MobSpawnSettings.SpawnerData BiomeSettingsMobs) {
|
||||
+ biomes.add(BiomeSettingsMobs);
|
||||
+ return super.add(BiomeSettingsMobs);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public MobSpawnSettings.SpawnerData remove(int index) {
|
||||
+ MobSpawnSettings.SpawnerData removed = super.remove(index);
|
||||
+ if (removed != null) {
|
||||
+ biomes.remove(removed);
|
||||
+ }
|
||||
+ return removed;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ biomes.clear();
|
||||
+ super.clear();
|
||||
+ }
|
||||
+ }
|
||||
+ // use toImmutableEnumMap collector
|
||||
+ private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = (Map) Stream.of(MobCategory.values()).collect(Maps.toImmutableEnumMap((mobCategory) -> {
|
||||
return mobCategory;
|
||||
}, (mobCategory) -> {
|
||||
- return Lists.newArrayList();
|
||||
+ return new MobList(); // Use MobList instead of ArrayList
|
||||
}));
|
||||
+ // Paper end
|
||||
private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap();
|
||||
private float creatureGenerationProbability = 0.1F;
|
||||
|
55
patches/server/0666-Make-item-validations-configurable.patch
Normal file
55
patches/server/0666-Make-item-validations-configurable.patch
Normal file
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 4 Jun 2021 12:12:35 -0700
|
||||
Subject: [PATCH] Make item validations configurable
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
index fefa4d83c5699be0b55794cd28d13d27b66ef108..d662cb0567884ec91c900f5c90ecb36912b127dd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
@@ -92,11 +92,11 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
super(tag);
|
||||
|
||||
if (tag.contains(BOOK_TITLE.NBT)) {
|
||||
- this.title = limit( tag.getString(BOOK_TITLE.NBT), 8192 ); // Spigot
|
||||
+ this.title = limit( tag.getString(BOOK_TITLE.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.title); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (tag.contains(BOOK_AUTHOR.NBT)) {
|
||||
- this.author = limit( tag.getString(BOOK_AUTHOR.NBT), 8192 ); // Spigot
|
||||
+ this.author = limit( tag.getString(BOOK_AUTHOR.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.author ); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (tag.contains(RESOLVED.NBT)) {
|
||||
@@ -124,7 +124,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
} else {
|
||||
page = this.validatePage(page);
|
||||
}
|
||||
- this.pages.add( limit( page, 16384 ) ); // Spigot
|
||||
+ this.pages.add( limit( page, io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.page ) ); // Spigot // Paper - make configurable
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index c475ddea1c995df1dfcaf4f491f341761a5f8802..a8294bf057e03c5d866f6da31e6cdfa9edd3f146 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -357,7 +357,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
CompoundTag display = tag.getCompound(DISPLAY.NBT);
|
||||
|
||||
if (display.contains(NAME.NBT)) {
|
||||
- this.displayName = limit( display.getString(NAME.NBT), 8192 ); // Spigot
|
||||
+ this.displayName = limit( display.getString(NAME.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.displayName ); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (display.contains(LOCNAME.NBT)) {
|
||||
@@ -368,7 +368,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
ListTag list = display.getList(LORE.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
this.lore = new ArrayList<String>(list.size());
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
- String line = limit( list.getString(index), 8192 ); // Spigot
|
||||
+ String line = limit( list.getString(index), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.loreLine ); // Spigot // Paper - make configurable
|
||||
this.lore.add(line);
|
||||
}
|
||||
}
|
74
patches/server/0667-Line-Of-Sight-Changes.patch
Normal file
74
patches/server/0667-Line-Of-Sight-Changes.patch
Normal file
|
@ -0,0 +1,74 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com>
|
||||
Date: Sat, 29 May 2021 14:33:25 -0500
|
||||
Subject: [PATCH] Line Of Sight Changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 644d71c024103c39d7532559c810038d687106e5..2694f7af35deff5c94929350589b2564f7bbdeff 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3484,7 +3484,8 @@ public abstract class LivingEntity extends Entity {
|
||||
Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
||||
|
||||
- return vec3d1.distanceTo(vec3d) > 128.0D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS;
|
||||
+ // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
||||
+ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
index 84d84ceda1855bd1d11b2917c16fdb845a7600fe..d1fca0e3227b5f37c11367548be362f5a49b6a71 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
@@ -944,5 +944,16 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
public org.bukkit.NamespacedKey getKey() {
|
||||
return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location());
|
||||
}
|
||||
+
|
||||
+ public boolean lineOfSightExists(Location from, Location to) {
|
||||
+ Preconditions.checkArgument(from != null, "from parameter in lineOfSightExists cannot be null");
|
||||
+ Preconditions.checkArgument(to != null, "to parameter in lineOfSightExists cannot be null");
|
||||
+ if (from.getWorld() != to.getWorld()) return false;
|
||||
+ net.minecraft.world.phys.Vec3 vec3d = new net.minecraft.world.phys.Vec3(from.getX(), from.getY(), from.getZ());
|
||||
+ net.minecraft.world.phys.Vec3 vec3d1 = new net.minecraft.world.phys.Vec3(to.getX(), to.getY(), to.getZ());
|
||||
+ if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks
|
||||
+
|
||||
+ return this.getHandle().clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, null)).getType() == net.minecraft.world.phys.HitResult.Type.MISS;
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 8fe1f5deddfee329c020d93c990dc686fe2b458e..ca176b9331345e343c19a02b6ba2ea886d20962d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -29,6 +29,9 @@ import net.minecraft.world.entity.projectile.ThrownEgg;
|
||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
+import net.minecraft.world.level.ClipContext;
|
||||
+import net.minecraft.world.phys.HitResult;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -557,6 +560,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return this.getHandle().hasLineOfSight(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasLineOfSight(Location loc) {
|
||||
+ if (this.getHandle().level != ((CraftWorld) loc.getWorld()).getHandle()) return false;
|
||||
+ Vec3 vec3d = new Vec3(this.getHandle().getX(), this.getHandle().getEyeY(), this.getHandle().getZ());
|
||||
+ Vec3 vec3d1 = new Vec3(loc.getX(), loc.getY(), loc.getZ());
|
||||
+ if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks
|
||||
+
|
||||
+ return this.getHandle().level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.getHandle())).getType() == HitResult.Type.MISS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return this.getHandle() instanceof Mob && !((Mob) this.getHandle()).isPersistenceRequired();
|
25
patches/server/0668-add-per-world-spawn-limits.patch
Normal file
25
patches/server/0668-add-per-world-spawn-limits.patch
Normal file
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: chase <chasewhip20@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 22:43:39 -0800
|
||||
Subject: [PATCH] add per world spawn limits
|
||||
|
||||
Taken from #2982. Credit to Chasewhip8
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 85972e19324027beaf215bed1b45947f976f5db4..59bf99a51d386851501b0acf2f07679f497d3132 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -211,6 +211,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
this.biomeProvider = biomeProvider;
|
||||
|
||||
this.environment = env;
|
||||
+ // Paper start - per world spawn limits
|
||||
+ for (SpawnCategory spawnCategory : SpawnCategory.values()) {
|
||||
+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
|
||||
+ setSpawnLimit(spawnCategory, this.world.paperConfig().entities.spawning.spawnLimits.getInt(CraftSpawnCategory.toNMS(spawnCategory)));
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,76 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 20 May 2021 20:40:53 -0700
|
||||
Subject: [PATCH] Fix PotionSplashEvent for water splash potions
|
||||
|
||||
Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6221
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
index ebe9b713905d33a4107fe32874a783e154bd0524..fee09e6ff72cf1da389d5811dd005642cd50a5b4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
@@ -121,30 +121,47 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
}
|
||||
}
|
||||
|
||||
+ private static final Predicate<net.minecraft.world.entity.LivingEntity> APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE.or(Axolotl.class::isInstance); // Paper
|
||||
private void applyWater() {
|
||||
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
||||
- List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE);
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE); // Paper
|
||||
+ Map<LivingEntity, Double> affected = new HashMap<>(); // Paper
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator.next();
|
||||
+ // Paper start - Change into single getEntities for axolotls & water sensitive
|
||||
+ if (entityliving instanceof Axolotl axolotl) {
|
||||
+ affected.put(axolotl.getBukkitLivingEntity(), 1.0);
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Paper end
|
||||
double d0 = this.distanceToSqr((Entity) entityliving);
|
||||
|
||||
if (d0 < 16.0D && entityliving.isSensitiveToWater()) {
|
||||
- entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ // Paper start
|
||||
+ double intensity = 1.0D - Math.sqrt(d0) / 4.0D;
|
||||
+ affected.put(entityliving.getBukkitLivingEntity(), intensity);
|
||||
+ // entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F); // Paper - moved down
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- List<Axolotl> list1 = this.level.getEntitiesOfClass(Axolotl.class, axisalignedbb);
|
||||
- Iterator iterator1 = list1.iterator();
|
||||
-
|
||||
- while (iterator1.hasNext()) {
|
||||
- Axolotl axolotl = (Axolotl) iterator1.next();
|
||||
-
|
||||
- axolotl.rehydrate();
|
||||
+ // Paper start
|
||||
+ org.bukkit.event.entity.PotionSplashEvent event = CraftEventFactory.callPotionSplashEvent(this, affected);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity affectedEntity : event.getAffectedEntities()) {
|
||||
+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) affectedEntity).getHandle();
|
||||
+ if (entityliving instanceof Axolotl axolotl && event.getIntensity(affectedEntity) > 0) {
|
||||
+ axolotl.rehydrate();
|
||||
+ } else {
|
||||
+ entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -165,6 +182,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
double d0 = this.distanceToSqr((Entity) entityliving);
|
||||
|
||||
if (d0 < 16.0D) {
|
||||
+ // Paper - diff on change, used when calling the splash event for water splash potions
|
||||
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
|
||||
|
||||
if (entityliving == entity) {
|
56
patches/server/0670-Add-more-LimitedRegion-API.patch
Normal file
56
patches/server/0670-Add-more-LimitedRegion-API.patch
Normal file
|
@ -0,0 +1,56 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dfsek <dfsek@protonmail.com>
|
||||
Date: Sat, 19 Jun 2021 20:15:59 -0700
|
||||
Subject: [PATCH] Add more LimitedRegion API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
index 992fc24a040c147596e6fe9f27936b4820ebc4b3..392701b0022e05d0fd03ee5836fd18f00502f028 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
@@ -226,4 +226,45 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
|
||||
public void addEntityToWorld(net.minecraft.world.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
this.entities.add(entity);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setBlockState(int x, int y, int z, BlockState state) {
|
||||
+ BlockPos pos = new BlockPos(x, y, z);
|
||||
+ if (!state.getBlockData().matches(getHandle().getBlockState(pos).createCraftBlockData())) {
|
||||
+ throw new IllegalArgumentException("BlockData does not match! Expected " + state.getBlockData().getAsString(false) + ", got " + getHandle().getBlockState(pos).createCraftBlockData().getAsString(false));
|
||||
+ }
|
||||
+ getHandle().getBlockEntity(pos).load(((org.bukkit.craftbukkit.block.CraftBlockEntityState<?>) state).getSnapshotNBT());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void scheduleBlockUpdate(int x, int y, int z) {
|
||||
+ BlockPos position = new BlockPos(x, y, z);
|
||||
+ getHandle().scheduleTick(position, getHandle().getBlockState(position).getBlock(), 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void scheduleFluidUpdate(int x, int y, int z) {
|
||||
+ BlockPos position = new BlockPos(x, y, z);
|
||||
+ getHandle().scheduleTick(position, getHandle().getFluidState(position).getType(), 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public World getWorld() {
|
||||
+ // reading/writing the returned Minecraft world causes a deadlock.
|
||||
+ // By implementing this, and covering it in warnings, we're assuming people won't be stupid, and
|
||||
+ // if they are stupid, they'll figure it out pretty fast.
|
||||
+ return getHandle().getMinecraftWorld().getWorld();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getCenterChunkX() {
|
||||
+ return centerChunkX;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getCenterChunkZ() {
|
||||
+ return centerChunkZ;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 20 Jun 2021 21:55:59 -0700
|
||||
Subject: [PATCH] Fix PlayerDropItemEvent using wrong item
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 607a44d2db927e579d8be7c52021d7bb205a379c..6e53214042ab515d9c66fb24f6aa1c07d6c3539d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2196,7 +2196,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
if (retainOwnership) {
|
||||
if (!itemstack1.isEmpty()) {
|
||||
- this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), stack.getCount());
|
||||
+ this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), itemstack1.getCount()); // Paper
|
||||
}
|
||||
|
||||
this.awardStat(Stats.DROP);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index a6bd94ed379ef1ab0ffe71183aef3cf3061fd092..92a5aadef076cb905962dab86f32d4ff253fef93 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -723,6 +723,11 @@ public abstract class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
double d0 = this.getEyeY() - 0.30000001192092896D;
|
||||
+ // Paper start
|
||||
+ ItemStack tmp = itemstack.copy();
|
||||
+ itemstack.setCount(0);
|
||||
+ itemstack = tmp;
|
||||
+ // Paper end
|
||||
ItemEntity entityitem = new ItemEntity(this.level, this.getX(), d0, this.getZ(), itemstack);
|
||||
|
||||
entityitem.setPickUpDelay(40);
|
594
patches/server/0672-Missing-Entity-Behavior-API.patch
Normal file
594
patches/server/0672-Missing-Entity-Behavior-API.patch
Normal file
|
@ -0,0 +1,594 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Mon, 21 Jun 2021 23:56:07 -0400
|
||||
Subject: [PATCH] Missing Entity Behavior API
|
||||
|
||||
Co-authored-by: Nassim Jahnke <jahnke.nassim@gmail.com>
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index d13f3460644f635ded96bf92ddf9ecf8984c8e47..bd048cc30046f19f9eee89c6ba45d0816a160e67 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -540,11 +540,13 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
this.setFlag(4, hasStung);
|
||||
}
|
||||
|
||||
+ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override
|
||||
public boolean isRolling() {
|
||||
return this.getFlag(2);
|
||||
}
|
||||
|
||||
public void setRolling(boolean nearTarget) {
|
||||
+ nearTarget = rollingOverride.toBooleanOrElse(nearTarget); // Paper - Rolling override
|
||||
this.setFlag(2, nearTarget);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
index 04a119e6641898454253e2478bc1b4dff181b5ee..a8da601b8342aa6e4902b452eb588c76c98a7adf 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -663,6 +663,14 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
|
||||
}
|
||||
|
||||
+ // Paper Start - Horse API
|
||||
+ public void setMouthOpen(boolean open) {
|
||||
+ this.setFlag(FLAG_OPEN_MOUTH, open);
|
||||
+ }
|
||||
+ public boolean isMouthOpen() {
|
||||
+ return this.getFlag(FLAG_OPEN_MOUTH);
|
||||
+ }
|
||||
+ // Paper End - Horse API
|
||||
private void openMouth() {
|
||||
if (!this.level.isClientSide) {
|
||||
this.mouthCounter = 1;
|
||||
@@ -675,6 +683,11 @@ public abstract class AbstractHorse extends Animal implements ContainerListener,
|
||||
this.setFlag(16, eatingGrass);
|
||||
}
|
||||
|
||||
+ // Paper Start - Horse API
|
||||
+ public void setForceStanding(boolean standing) {
|
||||
+ this.setFlag(FLAG_STANDING, standing);
|
||||
+ }
|
||||
+ // Paper End - Horse API
|
||||
public void setStanding(boolean angry) {
|
||||
if (angry) {
|
||||
this.setEating(false);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 32b302aad0319ce3ee412912425c1c8db9979f8a..92734f767fde60351a179a88350a97b861be0e88 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -84,6 +84,11 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
return entityliving.getMobType() != MobType.UNDEAD && entityliving.attackable();
|
||||
};
|
||||
private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0D).selector(WitherBoss.LIVING_ENTITY_SELECTOR);
|
||||
+ // Paper start
|
||||
+ private boolean canPortal = false;
|
||||
+
|
||||
+ public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; }
|
||||
+ // Paper end
|
||||
|
||||
public WitherBoss(EntityType<? extends WitherBoss> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -602,7 +607,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
|
||||
@Override
|
||||
public boolean canChangeDimensions() {
|
||||
- return false;
|
||||
+ return super.canChangeDimensions() && canPortal; // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
index e0e32528ed9f2f494b5ee2079c3167021f2e84c4..f22e615dba31619c97bf58930da060476a52facf 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
@@ -433,6 +433,16 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
this.entityData.set(EnderMan.DATA_STARED_AT, true);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void setCreepy(boolean creepy) {
|
||||
+ this.entityData.set(EnderMan.DATA_CREEPY, creepy);
|
||||
+ }
|
||||
+
|
||||
+ public void setHasBeenStaredAt(boolean hasBeenStaredAt) {
|
||||
+ this.entityData.set(EnderMan.DATA_STARED_AT, hasBeenStaredAt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean requiresCustomPersistence() {
|
||||
return super.requiresCustomPersistence() || this.getCarriedBlock() != null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Ghast.java b/src/main/java/net/minecraft/world/entity/monster/Ghast.java
|
||||
index 1f3506d38894fea224f3b2f125b45c3b68d705c7..bb2cb17e4e5ce142eeec18951c8948e3d6b3209c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Ghast.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Ghast.java
|
||||
@@ -66,6 +66,12 @@ public class Ghast extends FlyingMob implements Enemy {
|
||||
return this.explosionPower;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void setExplosionPower(int explosionPower) {
|
||||
+ this.explosionPower = explosionPower;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
protected boolean shouldDespawnInPeaceful() {
|
||||
return true;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
index e93a2634cd80cd4f1caf6bd60e569783bc6b577c..fb0a77b4cf1ba47c73c00993bd9b7454240fe5d6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
|
||||
@@ -197,6 +197,12 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
||||
}
|
||||
|
||||
public void startConverting(@Nullable UUID uuid, int delay) {
|
||||
+ // Paper start - missing entity behaviour api - converting without entity event
|
||||
+ this.startConverting(uuid, delay, true);
|
||||
+ }
|
||||
+
|
||||
+ public void startConverting(@Nullable UUID uuid, int delay, boolean broadcastEntityEvent) {
|
||||
+ // Paper end - missing entity behaviour api - converting without entity event
|
||||
this.conversionStarter = uuid;
|
||||
this.villagerConversionTime = delay;
|
||||
this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true);
|
||||
@@ -204,7 +210,7 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
|
||||
this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level.getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
// CraftBukkit end
|
||||
- this.level.broadcastEntityEvent(this, (byte) 16);
|
||||
+ if (broadcastEntityEvent) this.level.broadcastEntityEvent(this, (byte) 16); // Paper - missing entity behaviour api - converting without entity event
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
|
||||
index a367f50b0e3fe9e7a1b87892a8c98e88bd678f6f..1b31b32d42eeb54680b902cd7e82d10ba7daa5d0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownTrident.java
|
||||
@@ -105,6 +105,20 @@ public class ThrownTrident extends AbstractArrow {
|
||||
return (Boolean) this.entityData.get(ThrownTrident.ID_FOIL);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void setFoil(boolean foil) {
|
||||
+ this.entityData.set(ThrownTrident.ID_FOIL, foil);
|
||||
+ }
|
||||
+
|
||||
+ public int getLoyalty() {
|
||||
+ return this.entityData.get(ThrownTrident.ID_LOYALTY);
|
||||
+ }
|
||||
+
|
||||
+ public void setLoyalty(byte loyalty) {
|
||||
+ this.entityData.set(ThrownTrident.ID_LOYALTY, loyalty);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Nullable
|
||||
@Override
|
||||
protected EntityHitResult findHitEntity(Vec3 currentPosition, Vec3 nextPosition) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
index 254d4f2e45d7c8f572a4368eccd84560d4d0d836..299ab868252c8f326e3a56e878c9ee230c9635dc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
@@ -115,4 +115,36 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
|
||||
public AbstractHorseInventory getInventory() {
|
||||
return new CraftSaddledInventory(getHandle().inventory);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Horse API
|
||||
+ @Override
|
||||
+ public boolean isEatingGrass() {
|
||||
+ return this.getHandle().isEating();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEatingGrass(boolean eating) {
|
||||
+ this.getHandle().setEating(eating);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isRearing() {
|
||||
+ return this.getHandle().isStanding();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setRearing(boolean rearing) {
|
||||
+ this.getHandle().setForceStanding(rearing);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEating() {
|
||||
+ return this.getHandle().isMouthOpen();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEating(boolean eating) {
|
||||
+ this.getHandle().setMouthOpen(eating);
|
||||
+ }
|
||||
+ // Paper end - Horse API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java
|
||||
index 8ada3dfbe89c8b55d85c31c71e365af0cbf66d19..b5d3a00a48d3b7618f974bb0f6909aa7c304b012 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java
|
||||
@@ -91,4 +91,22 @@ public class CraftBee extends CraftAnimals implements Bee {
|
||||
public void setCannotEnterHiveTicks(int ticks) {
|
||||
this.getHandle().setStayOutOfHiveCountdown(ticks);
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setRollingOverride(net.kyori.adventure.util.TriState rolling) {
|
||||
+ this.getHandle().rollingOverride = rolling;
|
||||
+
|
||||
+ this.getHandle().setRolling(this.getHandle().isRolling()); // Refresh rolling state
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isRolling() {
|
||||
+ return this.getRollingOverride().toBooleanOrElse(this.getHandle().isRolling());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.util.TriState getRollingOverride() {
|
||||
+ return this.getHandle().rollingOverride;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java
|
||||
index 37352ca3ff267d02a26ed182ce3df3ef775fa9bc..6a504f61c55d3983871f8d1c5c002c7a7b9c50ff 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java
|
||||
@@ -51,4 +51,25 @@ public class CraftCat extends CraftTameableAnimal implements Cat {
|
||||
public void setCollarColor(DyeColor color) {
|
||||
this.getHandle().setCollarColor(net.minecraft.world.item.DyeColor.byId(color.getWoolData()));
|
||||
}
|
||||
+ // Paper Start - More cat api
|
||||
+ @Override
|
||||
+ public void setLyingDown(boolean lyingDown) {
|
||||
+ this.getHandle().setLying(lyingDown);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isLyingDown() {
|
||||
+ return this.getHandle().isLying();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setHeadUp(boolean headUp) {
|
||||
+ this.getHandle().setRelaxStateOne(headUp);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isHeadUp() {
|
||||
+ return this.getHandle().isRelaxStateOne();
|
||||
+ }
|
||||
+ // Paper End - More cat api
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
|
||||
index ae669a970aa1f17ed786640de8a481364543c58e..acdc4e578d70f8121c8c6be7682ba1ecef7687cf 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java
|
||||
@@ -39,6 +39,28 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
||||
this.getHandle().setCarriedBlock(blockData == null ? null : ((CraftBlockData) blockData).getState());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isScreaming() {
|
||||
+ return this.getHandle().isCreepy();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setScreaming(boolean screaming) {
|
||||
+ this.getHandle().setCreepy(screaming);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasBeenStaredAt() {
|
||||
+ return this.getHandle().hasBeenStaredAt();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setHasBeenStaredAt(boolean hasBeenStaredAt) {
|
||||
+ this.getHandle().setHasBeenStaredAt(hasBeenStaredAt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public EnderMan getHandle() {
|
||||
return (EnderMan) entity;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
|
||||
index f6369a1b0ea3fc64e9e7902d9da25924a0745855..fce96b67300b8808984904ee19d4e987f5235bfd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java
|
||||
@@ -119,4 +119,41 @@ public class CraftFox extends CraftAnimals implements Fox {
|
||||
public boolean isFaceplanted() {
|
||||
return this.getHandle().isFaceplanted();
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add more fox behavior API
|
||||
+ @Override
|
||||
+ public void setInterested(boolean interested) {
|
||||
+ this.getHandle().setIsInterested(interested);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isInterested() {
|
||||
+ return this.getHandle().isInterested();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLeaping(boolean leaping) {
|
||||
+ this.getHandle().setIsPouncing(leaping);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isLeaping() {
|
||||
+ return this.getHandle().isPouncing();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setDefending(boolean defending) {
|
||||
+ this.getHandle().setDefending(defending);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDefending() {
|
||||
+ return this.getHandle().isDefending();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setFaceplanted(boolean faceplanted) {
|
||||
+ this.getHandle().setFaceplanted(faceplanted);
|
||||
+ }
|
||||
+ // Paper end - Add more fox behavior API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java
|
||||
index 7adda5c93e7c172ea0ba4a3f15828b5e54a283e7..fffaf4108b632ceabac4186d93b34ad0eb069a04 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java
|
||||
@@ -34,4 +34,17 @@ public class CraftGhast extends CraftFlying implements Ghast {
|
||||
public void setCharging(boolean flag) {
|
||||
this.getHandle().setCharging(flag);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public int getExplosionPower() {
|
||||
+ return this.getHandle().getExplosionPower();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setExplosionPower(int explosionPower) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(explosionPower >= 0 && explosionPower <= 127, "The explosion power has to be between 0 and 127");
|
||||
+ this.getHandle().setExplosionPower(explosionPower);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java
|
||||
index ff9f711b83a8ea1bf4135751a9ba865224bce787..1f6dcad764240e15083731d017f9bb1c5c84622f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java
|
||||
@@ -46,6 +46,32 @@ public class CraftPanda extends CraftAnimals implements Panda {
|
||||
public void setHiddenGene(Gene gene) {
|
||||
this.getHandle().setHiddenGene(CraftPanda.toNms(gene));
|
||||
}
|
||||
+ // Paper start - Panda API
|
||||
+ @Override
|
||||
+ public void setSneezeTicks(int ticks) {
|
||||
+ this.getHandle().setSneezeCounter(ticks);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getSneezeTicks() {
|
||||
+ return this.getHandle().getSneezeCounter();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEatingTicks(int ticks) {
|
||||
+ this.getHandle().setEatCounter(ticks);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getEatingTicks() {
|
||||
+ return this.getHandle().getEatCounter();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setUnhappyTicks(int ticks) {
|
||||
+ this.getHandle().setUnhappyCounter(ticks);
|
||||
+ }
|
||||
+ // Paper end - Panda API
|
||||
|
||||
@Override
|
||||
public boolean isRolling() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
|
||||
index aeda5fc001fe4ce55ee467240b275b6050a29f98..48d0a4e42e1b90d1323784d1284acabfe9497dd6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
|
||||
@@ -90,4 +90,15 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest
|
||||
public String toString() {
|
||||
return "CraftPiglin";
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setChargingCrossbow(boolean chargingCrossbow) {
|
||||
+ this.getHandle().setChargingCrossbow(chargingCrossbow);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isChargingCrossbow() {
|
||||
+ return this.getHandle().isChargingCrossbow();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java
|
||||
index da1488c9cae53bd554727c850da2192adda2478a..30a0eac179c86b0fe94a2a40b5bfcd3eee01e53b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java
|
||||
@@ -23,4 +23,16 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear {
|
||||
public EntityType getType() {
|
||||
return EntityType.POLAR_BEAR;
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isStanding() {
|
||||
+ return this.getHandle().isStanding();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setStanding(boolean standing) {
|
||||
+ this.getHandle().setStanding(standing);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java
|
||||
index 27a8a2b1e03254b1fc6fe8edc3ff77841a42f5f6..8d77b870fd9de69b57ae1affdfbd2a02f62e75c7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRaider.java
|
||||
@@ -58,4 +58,16 @@ public abstract class CraftRaider extends CraftMonster implements Raider {
|
||||
public void setCanJoinRaid(boolean join) {
|
||||
this.getHandle().setCanJoinRaid(join);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isCelebrating() {
|
||||
+ return this.getHandle().isCelebrating();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCelebrating(boolean celebrating) {
|
||||
+ this.getHandle().setCelebrating(celebrating);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
||||
index bf5b2fd6676c4430578db4cc6c603c501cc5e349..832981b07ef5c633ef00a382f56798ee87eec0df 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
||||
@@ -37,4 +37,27 @@ public class CraftTrident extends CraftArrow implements Trident {
|
||||
public EntityType getType() {
|
||||
return EntityType.TRIDENT;
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasGlint() {
|
||||
+ return this.getHandle().isFoil();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setGlint(boolean glint) {
|
||||
+ this.getHandle().setFoil(glint);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getLoyaltyLevel() {
|
||||
+ return this.getHandle().getLoyalty();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLoyaltyLevel(int loyaltyLevel) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(loyaltyLevel >= 0 && loyaltyLevel <= 127, "The loyalty level has to be between 0 and 127");
|
||||
+ this.getHandle().setLoyalty((byte) loyaltyLevel);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
index 2ba16e33dd21c3c72cb12244aa78c59bf53e76d1..634a5099fb6faea03615783f57e643ad0083fa30 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java
|
||||
@@ -29,6 +29,26 @@ public class CraftVex extends CraftMonster implements Vex {
|
||||
public void setSummoner(org.bukkit.entity.Mob summoner) {
|
||||
getHandle().setOwner(summoner == null ? null : ((CraftMob) summoner).getHandle());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasLimitedLifetime() {
|
||||
+ return this.getHandle().hasLimitedLife;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLimitedLifetime(boolean hasLimitedLifetime) {
|
||||
+ this.getHandle().hasLimitedLife = hasLimitedLifetime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getLimitedLifetimeTicks() {
|
||||
+ return this.getHandle().limitedLifeTicks;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLimitedLifetimeTicks(int ticks) {
|
||||
+ this.getHandle().limitedLifeTicks = ticks;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
|
||||
index 8a0a905f6701c6e94cbbf15793788350958fb728..2a74e6ecb4f57bc6879b37f7bc0675417223bcbf 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
|
||||
@@ -72,13 +72,20 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
|
||||
|
||||
@Override
|
||||
public void setConversionTime(int time) {
|
||||
+ // Paper start - missing entity behaviour api - converting without entity event
|
||||
+ this.setConversionTime(time, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setConversionTime(int time, boolean broadcastEntityEvent) {
|
||||
+ // Paper stop - missing entity behaviour api - converting without entity event
|
||||
if (time < 0) {
|
||||
this.getHandle().villagerConversionTime = -1;
|
||||
this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false);
|
||||
this.getHandle().conversionStarter = null;
|
||||
this.getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
} else {
|
||||
- this.getHandle().startConverting((UUID) null, time);
|
||||
+ this.getHandle().startConverting((UUID) null, time, broadcastEntityEvent); // Paper - missing entity behaviour api - converting without entity event
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
|
||||
index e92355fa2042c4cf15354a11b7058cacbe996f0d..4cf3a374c9ee7c7bcf82e778aa094eb4f8463595 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
|
||||
@@ -61,4 +61,31 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok
|
||||
Entity target = this.getHandle().getLevel().getEntity(entityId);
|
||||
return (target != null) ? (LivingEntity) target.getBukkitEntity() : null;
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isCharged() {
|
||||
+ return getHandle().isPowered();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getInvulnerableTicks() {
|
||||
+ return getHandle().getInvulnerableTicks();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setInvulnerableTicks(int ticks) {
|
||||
+ getHandle().setInvulnerableTicks(ticks);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canTravelThroughPortals() {
|
||||
+ return getHandle().canChangeDimensions();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCanTravelThroughPortals(boolean value) {
|
||||
+ getHandle().setCanTravelThroughPortals(value);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Tue, 22 Jun 2021 19:58:53 +0100
|
||||
Subject: [PATCH] Ensure disconnect for book edit is called on main
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index a768e09c5ce6718435b50f1502c5ace773fff470..dfe1966bfb30b3d2e60e6b88d0a7c2331b02e9a4 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1210,7 +1210,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Paper end
|
||||
// CraftBukkit start
|
||||
if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
|
||||
- this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||
+ server.scheduleOnMain(() -> this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause // Paper - Also ensure this is called on main
|
||||
return;
|
||||
}
|
||||
this.lastBookTick = MinecraftServer.currentTick;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Mon, 28 Jun 2021 18:16:52 -0700
|
||||
Subject: [PATCH] Fix return value of Block#applyBoneMeal always being false
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 1bd1f5993fc296b7d8255cabaf28382c2e258099..b2628b1698ef2a235e7b465f09747cafbb133b7a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -558,7 +558,7 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
}
|
||||
|
||||
- return result == InteractionResult.SUCCESS && (event == null || !event.isCancelled());
|
||||
+ return result == InteractionResult.CONSUME && (event == null || !event.isCancelled()); // Paper - CONSUME is returned on success server-side (see BoneMealItem.applyBoneMeal and InteractionResult.sidedSuccess(boolean))
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Mon, 8 Jul 2019 00:13:36 -0700
|
||||
Subject: [PATCH] Use getChunkIfLoadedImmediately in places
|
||||
|
||||
This prevents us from hitting chunk loads for chunks at or less-than
|
||||
ticket level 33 (yes getChunkIfLoaded will actually perform a chunk
|
||||
load in that case).
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 428272c1cace3a87fbcade90b5f9ee9236532418..4bebe9bc9dea53d57543e65d7300f50b0f907017 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -222,7 +222,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
||||
- return this.chunkSource.getChunk(x, z, false);
|
||||
+ return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1437,7 +1437,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
for (int l1 = j; l1 <= i1; ++l1) {
|
||||
for (int i2 = l; i2 <= k1; ++i2) {
|
||||
- LevelChunk chunk = this.getChunkSource().getChunkNow(l1, i2);
|
||||
+ LevelChunk chunk = (LevelChunk) this.getChunkIfLoadedImmediately(l1, i2); // Paper
|
||||
|
||||
if (chunk != null) {
|
||||
for (int j2 = k; j2 <= j1; ++j2) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index c21274a72dca31c9160ecbcfa7eb42de64e91454..2a4e6c6f732d9cd2567352b7fca2c284b0bb9c1b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -199,6 +199,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
return (CraftServer) Bukkit.getServer();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasChunk(int chunkX, int chunkZ) {
|
||||
+ return this.getChunkIfLoaded(chunkX, chunkZ) != null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
|
||||
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
|
@ -0,0 +1,126 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 9 Jul 2021 13:50:48 -0700
|
||||
Subject: [PATCH] Fix commands from signs not firing command events
|
||||
|
||||
This patch changes sign command logic so that `run_command` click events:
|
||||
- are logged to the console
|
||||
- fire PlayerCommandPreprocessEvent
|
||||
- work with double-slash commands like `//wand`
|
||||
- sends failure messages to the player who clicked the sign
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java b/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01a2bc1feec808790bb93618ce46adb9bea5a9c8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java
|
||||
@@ -0,0 +1,42 @@
|
||||
+package io.papermc.paper.commands;
|
||||
+
|
||||
+import net.minecraft.commands.CommandSource;
|
||||
+import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.network.chat.Component;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+public class DelegatingCommandSource implements CommandSource {
|
||||
+
|
||||
+ private final CommandSource delegate;
|
||||
+
|
||||
+ public DelegatingCommandSource(CommandSource delegate) {
|
||||
+ this.delegate = delegate;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void sendSystemMessage(Component message) {
|
||||
+ delegate.sendSystemMessage(message);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsSuccess() {
|
||||
+ return delegate.acceptsSuccess();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsFailure() {
|
||||
+ return delegate.acceptsFailure();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldInformAdmins() {
|
||||
+ return delegate.shouldInformAdmins();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
|
||||
+ return delegate.getBukkitSender(wrapper);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index 831db5ee21938d71e99bf9d17b92a6ca15531740..def4fdd2c7e4f925fa128692a744e5d10ae0203a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -40,6 +40,7 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
private boolean renderMessagedFiltered;
|
||||
private DyeColor color;
|
||||
private boolean hasGlowingText;
|
||||
+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
|
||||
|
||||
public SignBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.SIGN, pos, state);
|
||||
@@ -224,7 +225,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
ClickEvent chatclickable = chatmodifier.getClickEvent();
|
||||
|
||||
if (chatclickable != null && chatclickable.getAction() == ClickEvent.Action.RUN_COMMAND) {
|
||||
- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(player), chatclickable.getValue());
|
||||
+ // Paper start
|
||||
+ String command = chatclickable.getValue().startsWith("/") ? chatclickable.getValue() : "/" + chatclickable.getValue();
|
||||
+ if (org.spigotmc.SpigotConfig.logCommands) {
|
||||
+ LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command);
|
||||
+ }
|
||||
+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent(player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) net.minecraft.server.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState());
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,8 +271,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
String s = player == null ? "Sign" : player.getName().getString();
|
||||
Object object = player == null ? Component.literal("Sign") : player.getDisplayName();
|
||||
|
||||
+ // Paper start - send messages back to the player
|
||||
+ CommandSource commandSource = this.level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this) {
|
||||
+ @Override
|
||||
+ public void sendSystemMessage(Component message) {
|
||||
+ player.sendSystemMessage(message);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsFailure() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ } : this;
|
||||
+ // Paper end
|
||||
// CraftBukkit - this
|
||||
- return new CommandSourceStack(this, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player);
|
||||
+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(this.worldPosition), Vec2.ZERO, (ServerLevel) this.level, 2, s, (Component) object, this.level.getServer(), player); // Paper
|
||||
}
|
||||
|
||||
public DyeColor getColor() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
index 0bba36d18d56a4dc2d6c6fb7969e5e6f0e1da404..a246a0bd9e57fb0703ba756e8aa1109f1674c0e8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
@@ -50,7 +50,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman
|
||||
|
||||
@Override
|
||||
public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
- return this.server.dispatchCommand(context.getSource().getBukkitSender(), context.getInput()) ? 1 : 0;
|
||||
+ return this.server.dispatchCommand(context.getSource().getBukkitSender(), context.getRange().get(context.getInput())) ? 1 : 0; // Paper - actually use the StringRange from context
|
||||
}
|
||||
|
||||
@Override
|
19
patches/server/0677-Adds-PlayerArmSwingEvent.patch
Normal file
19
patches/server/0677-Adds-PlayerArmSwingEvent.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 19:22:21 -0800
|
||||
Subject: [PATCH] Adds PlayerArmSwingEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index dfe1966bfb30b3d2e60e6b88d0a7c2331b02e9a4..4d3874b5f44d0162e245a73b5543c9f2cc75c9ce 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2617,7 +2617,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
|
||||
// Arm swing animation
|
||||
- PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packet.getHand() == InteractionHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
|
||||
+ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getCraftPlayer(), packet.getHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); // Paper
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return;
|
|
@ -0,0 +1,85 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:19:41 -0700
|
||||
Subject: [PATCH] Fixes kick event leave message not being sent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 6e53214042ab515d9c66fb24f6aa1c07d6c3539d..7670c02dca163d360e64a1491f2efe69aaaab411 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -260,7 +260,6 @@ public class ServerPlayer extends Player {
|
||||
public boolean supressTrackerForLogin = false; // Paper
|
||||
public boolean didPlayerJoinEvent = false; // Paper
|
||||
public Integer clientViewDistance;
|
||||
- public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
// CraftBukkit end
|
||||
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4d3874b5f44d0162e245a73b5543c9f2cc75c9ce..e1993c9f08b73e4366f60369e7f147c9c8bda958 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -523,7 +523,6 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Do not kick the player
|
||||
return;
|
||||
}
|
||||
- this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
// Send the possibly modified leave message
|
||||
final Component ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure
|
||||
// CraftBukkit end
|
||||
@@ -532,7 +531,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
}));
|
||||
- this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
|
||||
+ this.onDisconnect(ichatbasecomponent, event.leaveMessage()); // CraftBukkit - fire quit instantly // Paper - use kick event leave message
|
||||
this.connection.setReadOnly();
|
||||
MinecraftServer minecraftserver = this.server;
|
||||
Connection networkmanager = this.connection;
|
||||
@@ -1994,6 +1993,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
@Override
|
||||
public void onDisconnect(Component reason) {
|
||||
+ // Paper start
|
||||
+ this.onDisconnect(reason, null);
|
||||
+ }
|
||||
+ public void onDisconnect(Component reason, @Nullable net.kyori.adventure.text.Component quitMessage) {
|
||||
+ // Paper end
|
||||
// CraftBukkit start - Rarely it would send a disconnect line twice
|
||||
if (this.processedDisconnect) {
|
||||
return;
|
||||
@@ -2010,7 +2014,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
this.player.disconnect();
|
||||
// Paper start - Adventure
|
||||
- net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().remove(this.player);
|
||||
+ quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used
|
||||
if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
|
||||
this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false);
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 9dece3470d617be02248f41847ebf77ed083653a..1a48a03e70b282847dba1da796e5b8211debb603 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -595,6 +595,11 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // Paper - return Component
|
||||
+ // Paper start
|
||||
+ return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())));
|
||||
+ }
|
||||
+ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
|
||||
+ // Paper end
|
||||
ServerLevel worldserver = entityplayer.getLevel();
|
||||
|
||||
entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
@@ -605,7 +610,7 @@ public abstract class PlayerList {
|
||||
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
|
||||
}
|
||||
|
||||
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : net.kyori.adventure.text.Component.text(entityplayer.getScoreboardName())), entityplayer.quitReason); // Paper - quit reason
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), leaveMessage, entityplayer.quitReason); // Paper - quit reason
|
||||
if (entityplayer.didPlayerJoinEvent) this.cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit
|
||||
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 21:03:02 -0800
|
||||
Subject: [PATCH] Add config for mobs immune to default effects
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 2694f7af35deff5c94929350589b2564f7bbdeff..b0f38933d25397773ac8668f9d1e759d6b43884d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1153,7 +1153,7 @@ public abstract class LivingEntity extends Entity {
|
||||
if (this.getMobType() == MobType.UNDEAD) {
|
||||
MobEffect mobeffectlist = effect.getEffect();
|
||||
|
||||
- if (mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) {
|
||||
+ if ((mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) && this.level.paperConfig().entities.mobEffects.undeadImmuneToCertainEffects) { // Paper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 92734f767fde60351a179a88350a97b861be0e88..b3e2e834f4f151497bf842796dd8e3a8b5143f1b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -612,7 +612,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig().entities.mobEffects.immuneToWitherEffect.wither ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
private class WitherDoNothingGoal extends Goal {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
index 46779380f44a037d3915f287f40515a9bd31a439..c3085ad5410b41d9c7703b28ca835dbee3f49ee7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
@@ -133,7 +133,7 @@ public class Spider extends Monster {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.POISON && this.level.paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
index ea6233cb3ca30864e54d553a5d1071ea9147a868..6449213d717271bcc516e393a78dfe1e5c762d68 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
@@ -123,6 +123,6 @@ public class WitherSkeleton extends AbstractSkeleton {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: sulu5890 <sulu@sulu.me>
|
||||
Date: Sun, 11 Jul 2021 19:34:03 -0500
|
||||
Subject: [PATCH] Fix incorrect message for outdated client
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index b02cbf6bcc57167a1373925f652950e0212dfa4f..08b21f5a7a07f44f8044f56991fb6723cd8f3eea 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -80,7 +80,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
if (packet.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
Component ichatmutablecomponent; // Paper - Fix hex colors not working in some kick messages
|
||||
|
||||
- if (packet.getProtocolVersion() < 754) {
|
||||
+ if (packet.getProtocolVersion() < SharedConstants.getCurrentVersion().getProtocolVersion()) { // Paper - Fix incorrect message for outdated clients
|
||||
ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
||||
} else {
|
||||
ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Sun, 20 Jun 2021 16:35:42 +0100
|
||||
Subject: [PATCH] Don't apply cramming damage to players
|
||||
|
||||
It does not make a lot of sense to damage players if they get crammed,
|
||||
especially as the usecase of teleporting lots of players to the same
|
||||
location isn't too uncommon and killing all those players isn't
|
||||
really what one would expect to happen.
|
||||
|
||||
For those who really want it a config option is provided.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 7670c02dca163d360e64a1491f2efe69aaaab411..f523311e822af9cbef571338fd8fef177b9fc73d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1446,7 +1446,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource damageSource) {
|
||||
- return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER;
|
||||
+ return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || this.getAbilities().invulnerable && damageSource == DamageSource.WITHER || !level.paperConfig().collisions.allowPlayerCrammingDamage && damageSource == DamageSource.CRAMMING; // Paper - disable player cramming
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,134 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Mon, 28 Jun 2021 22:38:29 +0100
|
||||
Subject: [PATCH] Rate options and timings for sensors and behaviors
|
||||
|
||||
This adds config options to specify the tick rate for sensors
|
||||
and behaviors of different entity types as well as timings
|
||||
for those in order to be able to have some metrics as to which
|
||||
ones might need tweaking.
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
index 3f540dc05315103ef97fd53628f681c67f7e7c2d..23e564b05ba438924180c91f9b19a60731eedd1b 100644
|
||||
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -114,6 +114,14 @@ public final class MinecraftTimings {
|
||||
return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType + " - " + type, tickEntityTimer);
|
||||
}
|
||||
|
||||
+ public static Timing getBehaviorTimings(String type) {
|
||||
+ return Timings.ofSafe("## Behavior - " + type);
|
||||
+ }
|
||||
+
|
||||
+ public static Timing getSensorTimings(String type, int rate) {
|
||||
+ return Timings.ofSafe("## Sensor - " + type + " (Default rate: " + rate + ")");
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Get a named timer for the specified tile entity type to track type specific timings.
|
||||
* @param entity
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
index ea5dea8fc6af73afb3b9f79bcb254e1644a3b302..eb5a332f0705dd2e5568749a22f2f318d68010d1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
@@ -13,6 +13,10 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
private long endTimestamp;
|
||||
private final int minDuration;
|
||||
private final int maxDuration;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Behavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState) {
|
||||
this(requiredMemoryState, 60);
|
||||
@@ -26,6 +30,15 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
this.minDuration = minRunTime;
|
||||
this.maxDuration = maxRunTime;
|
||||
this.entryCondition = requiredMemoryState;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public Behavior.Status getStatus() {
|
||||
@@ -33,11 +46,19 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
public final boolean tryStart(ServerLevel world, E entity, long time) {
|
||||
+ // Paper start - behavior tick rate
|
||||
+ int tickRate = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.behavior.get(entity.getType(), this.configKey), -1);
|
||||
+ if (tickRate > -1 && time < this.endTimestamp + tickRate) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.hasRequiredMemories(entity) && this.checkExtraStartConditions(world, entity)) {
|
||||
this.status = Behavior.Status.RUNNING;
|
||||
int i = this.minDuration + world.getRandom().nextInt(this.maxDuration + 1 - this.minDuration);
|
||||
this.endTimestamp = time + (long)i;
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
this.start(world, entity, time);
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -48,11 +69,13 @@ public abstract class Behavior<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
public final void tickOrStop(ServerLevel world, E entity, long time) {
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
if (!this.timedOut(time) && this.canStillUse(world, entity, time)) {
|
||||
this.tick(world, entity, time);
|
||||
} else {
|
||||
this.doStop(world, entity, time);
|
||||
}
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
index 7970eebbd6935402223e6bba962bb8ba7d861dfd..fcdb9bde8e1605e30dde3e580491522d4b62cdc0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
@@ -19,8 +19,21 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
private static final TargetingConditions ATTACK_TARGET_CONDITIONS_IGNORE_INVISIBILITY_AND_LINE_OF_SIGHT = TargetingConditions.forCombat().range(16.0D).ignoreLineOfSight().ignoreInvisibilityTesting();
|
||||
private final int scanRate;
|
||||
private long timeToTick;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Sensor(int senseInterval) {
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval);
|
||||
+ // Paper end
|
||||
this.scanRate = senseInterval;
|
||||
this.timeToTick = (long)RANDOM.nextInt(senseInterval);
|
||||
}
|
||||
@@ -31,8 +44,12 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
|
||||
public final void tick(ServerLevel world, E entity) {
|
||||
if (--this.timeToTick <= 0L) {
|
||||
- this.timeToTick = (long)this.scanRate;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ this.timeToTick = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate);
|
||||
+ this.timing.startTiming();
|
||||
+ // Paper end
|
||||
this.doTick(world, entity);
|
||||
+ this.timing.stopTiming(); // Paper - sensor timings
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 20 Jul 2021 21:25:35 -0700
|
||||
Subject: [PATCH] Add a bunch of missing forceDrop toggles
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
index e47f3092b6bd6b86b577de705db1a575d0952348..490212cfe4e5cea7219eaf4304e14bfac0e6472d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
@@ -100,7 +100,9 @@ public class WorkAtComposter extends WorkAtPoi {
|
||||
ItemStack itemstack = inventorysubcontainer.addItem(new ItemStack(Items.BREAD, j));
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ entity.forceDrops = true; // Paper
|
||||
entity.spawnAtLocation(itemstack, 0.5F);
|
||||
+ entity.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
index 9c07e3f5554b3b9cf2a2c4d9239a72342567d7f1..39c26f486d6392eb0a9b623cdb2161846357174b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
@@ -522,7 +522,9 @@ public class Panda extends Animal {
|
||||
}
|
||||
|
||||
if (!this.level.isClientSide() && this.random.nextInt(700) == 0 && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation((ItemLike) Items.SLIME_BALL);
|
||||
+ this.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index d733bcf1049a21009c2548679a51563c15f79523..793576928dad6752dddd86e62d4c0800d8515fc4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -306,7 +306,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel world) {
|
||||
PiglinAi.cancelAdmiring(this);
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.inventory.removeAllItems().forEach(this::spawnAtLocation);
|
||||
+ this.forceDrops = false; // Paper
|
||||
super.finishConversion(world);
|
||||
}
|
||||
|
39
patches/server/0684-Stinger-API.patch
Normal file
39
patches/server/0684-Stinger-API.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Tue, 22 Jun 2021 23:15:44 -0400
|
||||
Subject: [PATCH] Stinger API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index ca176b9331345e343c19a02b6ba2ea886d20962d..c022751e3b45469cc0ad6732e2d6ff08918bafa4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -321,7 +321,28 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
|
||||
this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count);
|
||||
}
|
||||
+ // Paper Start - Bee Stinger API
|
||||
+ @Override
|
||||
+ public int getBeeStingerCooldown() {
|
||||
+ return getHandle().removeStingerTime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingerCooldown(int ticks) {
|
||||
+ getHandle().removeStingerTime = ticks;
|
||||
+ }
|
||||
|
||||
+ @Override
|
||||
+ public int getBeeStingersInBody() {
|
||||
+ return getHandle().getStingerCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingersInBody(int count) {
|
||||
+ Preconditions.checkArgument(count >= 0, "New bee stinger amount must be >= 0");
|
||||
+ getHandle().setStingerCount(count);
|
||||
+ }
|
||||
+ // Paper End - Bee Stinger API
|
||||
@Override
|
||||
public void damage(double amount) {
|
||||
this.damage(amount, null);
|
|
@ -0,0 +1,31 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 1 Aug 2021 09:49:06 +0100
|
||||
Subject: [PATCH] Fix incosistency issue with empty map items in CB
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
index d407cf849a31a7a77fda07aa687ebb254f43d6ab..45a7e01288f780cf8a812d8e0ae12c4fb79d79e1 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
@@ -71,7 +71,7 @@ public class MapItem extends ComplexItem {
|
||||
public static Integer getMapId(ItemStack stack) {
|
||||
CompoundTag nbttagcompound = stack.getTag();
|
||||
|
||||
- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
|
||||
+ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; // CraftBukkit - make new maps for no tag // Paper - don't return invalid ID
|
||||
}
|
||||
|
||||
public static int createNewSavedData(Level world, int x, int z, int scale, boolean showIcons, boolean unlimitedTracking, ResourceKey<Level> dimension) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
index 96ab7d53f4e089c7666872f9fd0f09283259a726..8e634ccb91b58000412c572903e57d30ddb2caba 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
@@ -144,6 +144,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
|
||||
|
||||
@Override
|
||||
public int getMapId() {
|
||||
+ Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
|
||||
return this.mapId;
|
||||
}
|
||||
|
118
patches/server/0686-Add-System.out-err-catcher.patch
Normal file
118
patches/server/0686-Add-System.out-err-catcher.patch
Normal file
|
@ -0,0 +1,118 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: underscore11code <minecrafter11mrt@gmail.com>
|
||||
Date: Fri, 23 Jul 2021 23:01:42 -0700
|
||||
Subject: [PATCH] Add System.out/err catcher
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..76d0d00cd6742991e3f3ec827a75ee87d856b6c9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
@@ -0,0 +1,94 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.plugin.java.JavaPlugin;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.OutputStream;
|
||||
+import java.io.PrintStream;
|
||||
+import java.util.Objects;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import java.util.concurrent.ConcurrentMap;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public final class SysoutCatcher {
|
||||
+ private static final boolean SUPPRESS_NAGS = Boolean.getBoolean("io.papermc.paper.suppress.sout.nags");
|
||||
+ // Nanoseconds between nag at most; if interval is caught first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_TIMEOUT = TimeUnit.MILLISECONDS.toNanos(
|
||||
+ Long.getLong("io.papermc.paper.sout.nags.timeout", TimeUnit.MINUTES.toMillis(5L)));
|
||||
+ // Count since last nag; if timeout is first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_INTERVAL = Long.getLong("io.papermc.paper.sout.nags.interval", 200L);
|
||||
+
|
||||
+ // We don't particularly care about how correct this is at any given moment; let's do it on a best attempt basis.
|
||||
+ // The records are also pretty small, so let's just go for a size of 64 to start...
|
||||
+ //
|
||||
+ // Content: Plugin name => nag object
|
||||
+ // Why plugin name?: This doesn't store a reference to the plugin; keeps the reload ability.
|
||||
+ // Why not clean on reload?: Effort.
|
||||
+ private final ConcurrentMap<String, PluginNag> nagRecords = new ConcurrentHashMap<>(64);
|
||||
+
|
||||
+ public SysoutCatcher() {
|
||||
+ System.setOut(new WrappedOutStream(System.out, Level.INFO, "[STDOUT] "));
|
||||
+ System.setErr(new WrappedOutStream(System.err, Level.SEVERE, "[STDERR] "));
|
||||
+ }
|
||||
+
|
||||
+ private final class WrappedOutStream extends PrintStream {
|
||||
+ private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
||||
+ private final Level level;
|
||||
+ private final String prefix;
|
||||
+
|
||||
+ public WrappedOutStream(@NotNull final OutputStream out, final Level level, final String prefix) {
|
||||
+ super(out);
|
||||
+ this.level = level;
|
||||
+ this.prefix = prefix;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void println(@Nullable final String line) {
|
||||
+ final Class<?> clazz = STACK_WALKER.getCallerClass();
|
||||
+ try {
|
||||
+ final JavaPlugin plugin = JavaPlugin.getProvidingPlugin(clazz);
|
||||
+
|
||||
+ // Instead of just printing the message, send it to the plugin's logger
|
||||
+ plugin.getLogger().log(this.level, this.prefix + line);
|
||||
+
|
||||
+ if (SysoutCatcher.SUPPRESS_NAGS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (SysoutCatcher.NAG_INTERVAL > 0 || SysoutCatcher.NAG_TIMEOUT > 0) {
|
||||
+ final PluginNag nagRecord = SysoutCatcher.this.nagRecords.computeIfAbsent(plugin.getName(), k -> new PluginNag());
|
||||
+ final boolean hasTimePassed = SysoutCatcher.NAG_TIMEOUT > 0
|
||||
+ && (nagRecord.lastNagTimestamp == Long.MIN_VALUE
|
||||
+ || nagRecord.lastNagTimestamp + SysoutCatcher.NAG_TIMEOUT <= System.nanoTime());
|
||||
+ final boolean hasMessagesPassed = SysoutCatcher.NAG_INTERVAL > 0
|
||||
+ && (nagRecord.messagesSinceNag == Long.MIN_VALUE
|
||||
+ || ++nagRecord.messagesSinceNag >= SysoutCatcher.NAG_INTERVAL);
|
||||
+ if (!hasMessagesPassed && !hasTimePassed) {
|
||||
+ return;
|
||||
+ }
|
||||
+ nagRecord.lastNagTimestamp = System.nanoTime();
|
||||
+ nagRecord.messagesSinceNag = 0;
|
||||
+ }
|
||||
+ Bukkit.getLogger().warning(
|
||||
+ String.format("Nag author(s): '%s' of '%s' about their usage of System.out/err.print. "
|
||||
+ + "Please use your plugin's logger instead (JavaPlugin#getLogger).",
|
||||
+ plugin.getDescription().getAuthors(),
|
||||
+ plugin.getName())
|
||||
+ );
|
||||
+ } catch (final IllegalArgumentException | IllegalStateException e) {
|
||||
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
|
||||
+ // Just print out normally, with some added information
|
||||
+ Bukkit.getLogger().log(this.level, String.format("%s[%s] %s", this.prefix, clazz.getName(), line));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static class PluginNag {
|
||||
+ private long lastNagTimestamp = Long.MIN_VALUE;
|
||||
+ private long messagesSinceNag = Long.MIN_VALUE;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e8f327693e8b488790bf58d4927497402211bf1d..2f91be86f31c868dee3699ce5426a3ce5c8296b0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -282,6 +282,7 @@ public final class CraftServer implements Server {
|
||||
public int reloadCount;
|
||||
private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
|
||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
+ private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
|
24
patches/server/0687-Fix-test-not-bootstrapping.patch
Normal file
24
patches/server/0687-Fix-test-not-bootstrapping.patch
Normal file
|
@ -0,0 +1,24 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Mon, 2 Aug 2021 08:52:21 +0200
|
||||
Subject: [PATCH] Fix test not bootstrapping
|
||||
|
||||
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
|
||||
diff --git a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
index 19777eaca02640f220626940f5384563777dd74a..9873addca9e7a2a7eaa30a1c1cd332260ca07b35 100644
|
||||
--- a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
+++ b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
@@ -5,10 +5,11 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
-public class EnchantmentTargetTest {
|
||||
+public class EnchantmentTargetTest extends AbstractTestingBase { // Paper
|
||||
|
||||
@Test
|
||||
public void test() {
|
|
@ -0,0 +1,246 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SirYwell <hannesgreule@outlook.de>
|
||||
Date: Sat, 10 Jul 2021 11:12:30 +0200
|
||||
Subject: [PATCH] Rewrite LogEvents to contain the source jars in stack traces
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6ffd1befe64c6c3036c22e05ed1c44808d64bd28
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
@@ -0,0 +1,130 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.Marker;
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+import org.apache.logging.log4j.core.time.Instant;
|
||||
+import org.apache.logging.log4j.message.Message;
|
||||
+import org.apache.logging.log4j.util.ReadOnlyStringMap;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public class DelegateLogEvent implements LogEvent {
|
||||
+ private final LogEvent original;
|
||||
+
|
||||
+ protected DelegateLogEvent(LogEvent original) {
|
||||
+ this.original = original;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public LogEvent toImmutable() {
|
||||
+ return this.original.toImmutable();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Map<String, String> getContextMap() {
|
||||
+ return this.original.getContextMap();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ReadOnlyStringMap getContextData() {
|
||||
+ return this.original.getContextData();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThreadContext.ContextStack getContextStack() {
|
||||
+ return this.original.getContextStack();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerFqcn() {
|
||||
+ return this.original.getLoggerFqcn();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Level getLevel() {
|
||||
+ return this.original.getLevel();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerName() {
|
||||
+ return this.original.getLoggerName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Marker getMarker() {
|
||||
+ return this.original.getMarker();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Message getMessage() {
|
||||
+ return this.original.getMessage();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getTimeMillis() {
|
||||
+ return this.original.getTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Instant getInstant() {
|
||||
+ return this.original.getInstant();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public StackTraceElement getSource() {
|
||||
+ return this.original.getSource();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getThreadName() {
|
||||
+ return this.original.getThreadName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getThreadId() {
|
||||
+ return this.original.getThreadId();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getThreadPriority() {
|
||||
+ return this.original.getThreadPriority();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Throwable getThrown() {
|
||||
+ return this.original.getThrown();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ return this.original.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEndOfBatch() {
|
||||
+ return this.original.isEndOfBatch();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isIncludeLocation() {
|
||||
+ return this.original.isIncludeLocation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEndOfBatch(boolean endOfBatch) {
|
||||
+ this.original.setEndOfBatch(endOfBatch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setIncludeLocation(boolean locationRequired) {
|
||||
+ this.original.setIncludeLocation(locationRequired);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getNanoTime() {
|
||||
+ return this.original.getNanoTime();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..558427c65b4051923f73d15d85ee519be005060a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedClassInfo;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+
|
||||
+public class ExtraClassInfoLogEvent extends DelegateLogEvent {
|
||||
+
|
||||
+ private boolean fixed;
|
||||
+
|
||||
+ public ExtraClassInfoLogEvent(LogEvent original) {
|
||||
+ super(original);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ if (fixed) {
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+ rewriteStackTrace(super.getThrownProxy());
|
||||
+ fixed = true;
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ private void rewriteStackTrace(ThrowableProxy throwable) {
|
||||
+ ExtendedStackTraceElement[] stackTrace = throwable.getExtendedStackTrace();
|
||||
+ for (int i = 0; i < stackTrace.length; i++) {
|
||||
+ ExtendedClassInfo classInfo = stackTrace[i].getExtraClassInfo();
|
||||
+ if (classInfo.getLocation().equals("?")) {
|
||||
+ StackTraceElement element = stackTrace[i].getStackTraceElement();
|
||||
+ String classLoaderName = element.getClassLoaderName();
|
||||
+ if (classLoaderName != null) {
|
||||
+ stackTrace[i] = new ExtendedStackTraceElement(element,
|
||||
+ new ExtendedClassInfo(classInfo.getExact(), classLoaderName, "?"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (throwable.getCauseProxy() != null) {
|
||||
+ rewriteStackTrace(throwable.getCauseProxy());
|
||||
+ }
|
||||
+ if (throwable.getSuppressedProxies() != null) {
|
||||
+ for (ThrowableProxy proxy : throwable.getSuppressedProxies()) {
|
||||
+ rewriteStackTrace(proxy);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..34734bb969a1a74c7a4f9c17d40ebf007ad5d701
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
@@ -0,0 +1,29 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.Core;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy;
|
||||
+import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+@Plugin(
|
||||
+ name = "ExtraClassInfoRewritePolicy",
|
||||
+ category = Core.CATEGORY_NAME,
|
||||
+ elementType = "rewritePolicy",
|
||||
+ printObject = true
|
||||
+)
|
||||
+public final class ExtraClassInfoRewritePolicy implements RewritePolicy {
|
||||
+ @Override
|
||||
+ public LogEvent rewrite(LogEvent source) {
|
||||
+ if (source.getThrown() != null) {
|
||||
+ return new ExtraClassInfoLogEvent(source);
|
||||
+ }
|
||||
+ return source;
|
||||
+ }
|
||||
+
|
||||
+ @PluginFactory
|
||||
+ public static @NotNull ExtraClassInfoRewritePolicy createPolicy() {
|
||||
+ return new ExtraClassInfoRewritePolicy();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
||||
index 2e421eaac80cf251b32e0bb504dd54a73edf4986..74ccc67e3c12dc5182602fb691ef3ddeb5b53280 100644
|
||||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -34,6 +34,10 @@
|
||||
</Async>
|
||||
<Rewrite name="rewrite">
|
||||
<StacktraceDeobfuscatingRewritePolicy />
|
||||
+ <AppenderRef ref="rewrite2"/>
|
||||
+ </Rewrite>
|
||||
+ <Rewrite name="rewrite2">
|
||||
+ <ExtraClassInfoRewritePolicy />
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
70
patches/server/0689-Improve-boat-collision-performance.patch
Normal file
70
patches/server/0689-Improve-boat-collision-performance.patch
Normal file
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
||||
Subject: [PATCH] Improve boat collision performance
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index 4fce18c52c8144460ebf0c1e336dce712d796cc6..384ddb03af26ae360fd22e2e231d9d14d6ad0865 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -112,6 +112,7 @@ public class Util {
|
||||
}).findFirst().orElseThrow(() -> {
|
||||
return new IllegalStateException("No jar file system provider found");
|
||||
});
|
||||
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper
|
||||
private static Consumer<String> thePauser = (message) -> {
|
||||
};
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b0f38933d25397773ac8668f9d1e759d6b43884d..bc01742e3e762fbb5b7eb712a9211e4a8d411e03 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1341,7 +1341,7 @@ public abstract class LivingEntity extends Entity {
|
||||
if (!source.isProjectile()) {
|
||||
Entity entity = source.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
this.blockUsingShield((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
@@ -1449,11 +1449,12 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
if (entity1 != null) {
|
||||
- double d0 = entity1.getX() - this.getX();
|
||||
+ final boolean far = entity1.distanceToSqr(this) > (200.0 * 200.0); // Paper
|
||||
+ double d0 = far ? (Math.random() - Math.random()) : entity1.getX() - this.getX(); // Paper
|
||||
|
||||
double d1;
|
||||
|
||||
- for (d1 = entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
|
||||
+ for (d1 = far ? Math.random() - Math.random() : entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { // Paper
|
||||
d0 = (Math.random() - Math.random()) * 0.01D;
|
||||
}
|
||||
|
||||
@@ -2141,7 +2142,7 @@ public abstract class LivingEntity extends Entity {
|
||||
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
Entity entity = damagesource.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
this.blockUsingShield((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index 5641a7b5c5e3d93cddabd91703c6f001700c5869..29da8a42406feccf7932097b07b1d32a38fa96b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -691,8 +691,8 @@ public class Boat extends Entity {
|
||||
this.invFriction = 0.05F;
|
||||
if (this.oldStatus == Boat.Status.IN_AIR && this.status != Boat.Status.IN_AIR && this.status != Boat.Status.ON_LAND) {
|
||||
this.waterLevel = this.getY(1.0D);
|
||||
- this.setPos(this.getX(), (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D, this.getZ());
|
||||
- this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
||||
+ this.move(MoverType.SELF, new Vec3(0.0, ((double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D) - this.getY(), 0.0)); // Paper
|
||||
+ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); // Paper
|
||||
this.lastYd = 0.0D;
|
||||
this.status = Boat.Status.IN_WATER;
|
||||
} else {
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Noah van der Aa <ndvdaa@gmail.com>
|
||||
Date: Sat, 24 Jul 2021 16:54:11 +0200
|
||||
Subject: [PATCH] Prevent AFK kick while watching end credits.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index e1993c9f08b73e4366f60369e7f147c9c8bda958..e8cd8adad14c6bcab3ccef7fcc458b38d90592c3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -441,7 +441,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
--this.dropSpamTickCount;
|
||||
}
|
||||
|
||||
- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
|
||||
+ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60) && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits.
|
||||
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Professor Bloodstone <git@bloodstone.dev>
|
||||
Date: Fri, 23 Jul 2021 02:32:04 +0200
|
||||
Subject: [PATCH] Allow skipping writing of comments to server.properties
|
||||
|
||||
Makes less git noise, as it won't update the date every single time
|
||||
|
||||
Use -DPaper.skipServerPropertiesComments=true flag to disable writing it
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
index 7c35fb22df0bca2c2ca885a872ee42d6073d852f..aafa84578c7fb25feeee043259f9c056929ca008 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/Settings.java
|
||||
@@ -23,6 +23,7 @@ public abstract class Settings<T extends Settings<T>> {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public final Properties properties;
|
||||
+ private static final boolean skipComments = Boolean.getBoolean("Paper.skipServerPropertiesComments"); // Paper - allow skipping server.properties comments
|
||||
// CraftBukkit start
|
||||
private OptionSet options = null;
|
||||
|
||||
@@ -79,9 +80,47 @@ public abstract class Settings<T extends Settings<T>> {
|
||||
}
|
||||
// CraftBukkit end
|
||||
OutputStream outputstream = Files.newOutputStream(path);
|
||||
+ // Paper start - disable writing comments to properties file
|
||||
+ java.io.BufferedOutputStream bufferedOutputStream = !skipComments ? new java.io.BufferedOutputStream(outputstream) : new java.io.BufferedOutputStream(outputstream) {
|
||||
+ private boolean isRightAfterNewline = true; // If last written char was newline
|
||||
+ private boolean isComment = false; // Are we writing comment currently?
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@org.jetbrains.annotations.NotNull byte[] b) throws IOException {
|
||||
+ this.write(b, 0, b.length);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void write(@org.jetbrains.annotations.NotNull byte[] bbuf, int off, int len) throws IOException {
|
||||
+ int latest_offset = off; // The latest offset, updated when comment ends
|
||||
+ for (int index = off; index < off + len; ++index ) {
|
||||
+ byte c = bbuf[index];
|
||||
+ boolean isNewline = (c == '\n' || c == '\r');
|
||||
+ if (isNewline && isComment) {
|
||||
+ // Comment has ended
|
||||
+ isComment = false;
|
||||
+ latest_offset = index+1;
|
||||
+ }
|
||||
+ if (c == '#' && isRightAfterNewline) {
|
||||
+ isComment = true;
|
||||
+ if (index != latest_offset) {
|
||||
+ // We got some non-comment data earlier
|
||||
+ super.write(bbuf, latest_offset, index-latest_offset);
|
||||
+ }
|
||||
+ }
|
||||
+ isRightAfterNewline = isNewline; // Store for next iteration
|
||||
+
|
||||
+ }
|
||||
+ if (latest_offset < off+len && !isComment) {
|
||||
+ // We have some unwritten data, that isn't part of a comment
|
||||
+ super.write(bbuf, latest_offset, (off + len) - latest_offset);
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+ // Paper end
|
||||
|
||||
try {
|
||||
- this.properties.store(outputstream, "Minecraft server properties");
|
||||
+ this.properties.store(bufferedOutputStream, "Minecraft server properties"); // Paper - use bufferedOutputStream
|
||||
} catch (Throwable throwable) {
|
||||
if (outputstream != null) {
|
||||
try {
|
146
patches/server/0692-Add-PlayerSetSpawnEvent.patch
Normal file
146
patches/server/0692-Add-PlayerSetSpawnEvent.patch
Normal file
|
@ -0,0 +1,146 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 19 May 2021 18:59:10 -0700
|
||||
Subject: [PATCH] Add PlayerSetSpawnEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
index ce1c7512cc368e196ae94ee22c6a228c975b4980..1e41de9523c5fa3b9cfced798a5c35a24ec9d349 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
@@ -32,9 +32,21 @@ public class SetSpawnCommand {
|
||||
private static int setSpawn(CommandSourceStack source, Collection<ServerPlayer> targets, BlockPos pos, float angle) {
|
||||
ResourceKey<Level> resourceKey = source.getLevel().dimension();
|
||||
|
||||
+ final Collection<ServerPlayer> actualTargets = new java.util.ArrayList<>(); // Paper
|
||||
for(ServerPlayer serverPlayer : targets) {
|
||||
- serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false);
|
||||
+ // Paper start - PlayerSetSpawnEvent
|
||||
+ if (serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) {
|
||||
+ actualTargets.add(serverPlayer);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (actualTargets.isEmpty()) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ targets = actualTargets;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
String string = resourceKey.location().toString();
|
||||
if (targets.size() == 1) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index f523311e822af9cbef571338fd8fef177b9fc73d..ec713ffb7c4cba53dc983ebde5596e4749107493 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1287,7 +1287,7 @@ public class ServerPlayer extends Player {
|
||||
} else if (this.bedBlocked(blockposition, enumdirection)) {
|
||||
return Either.left(Player.BedSleepingProblem.OBSTRUCTED);
|
||||
} else {
|
||||
- this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true);
|
||||
+ this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - PlayerSetSpawnEvent
|
||||
if (this.level.isDay()) {
|
||||
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -2123,12 +2123,33 @@ public class ServerPlayer extends Player {
|
||||
return this.respawnForced;
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
|
||||
+ // Paper start
|
||||
+ this.setRespawnPosition(dimension, pos, angle, forced, sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+ public boolean setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) {
|
||||
+ Location spawnLoc = null;
|
||||
+ boolean willNotify = false;
|
||||
if (pos != null) {
|
||||
boolean flag2 = pos.equals(this.respawnPosition) && dimension.equals(this.respawnDimension);
|
||||
+ spawnLoc = net.minecraft.server.MCUtil.toLocation(this.getServer().getLevel(dimension), pos);
|
||||
+ spawnLoc.setYaw(angle);
|
||||
+ willNotify = sendMessage && !flag2;
|
||||
+ }
|
||||
+ com.destroystokyo.paper.event.player.PlayerSetSpawnEvent event = new com.destroystokyo.paper.event.player.PlayerSetSpawnEvent(this.getBukkitEntity(), cause, spawnLoc, forced, willNotify, willNotify ? net.kyori.adventure.text.Component.translatable("block.minecraft.set_spawn") : null);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (event.getLocation() != null) {
|
||||
+ dimension = event.getLocation().getWorld() != null ? ((CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension;
|
||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(event.getLocation());
|
||||
+ angle = (float) event.getLocation().getYaw();
|
||||
+ forced = event.isForced();
|
||||
+ // Paper end
|
||||
|
||||
- if (sendMessage && !flag2) {
|
||||
- this.sendSystemMessage(Component.translatable("block.minecraft.set_spawn"));
|
||||
+ if (event.willNotifyPlayer() && event.getNotification() != null) { // Paper
|
||||
+ this.sendSystemMessage(PaperAdventure.asVanilla(event.getNotification())); // Paper
|
||||
}
|
||||
|
||||
this.respawnPosition = pos;
|
||||
@@ -2142,6 +2163,7 @@ public class ServerPlayer extends Player {
|
||||
this.respawnForced = false;
|
||||
}
|
||||
|
||||
+ return true; // Paper
|
||||
}
|
||||
|
||||
public void trackChunk(ChunkPos chunkPos, Packet<?> chunkDataPacket) {
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 1a48a03e70b282847dba1da796e5b8211debb603..dda357b4f52030435c012f10b11f1ccb3f6688be 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -899,13 +899,13 @@ public abstract class PlayerList {
|
||||
f1 = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
|
||||
- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false);
|
||||
+ entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // Paper - PlayerSetSpawnEvent
|
||||
flag2 = !flag && flag3;
|
||||
isBedSpawn = true;
|
||||
location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
} else if (blockposition != null) {
|
||||
entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
- entityplayer1.setRespawnPosition(null, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
index c3e49a781f838e6a46cb89744f3f1846de182275..c2f3d3a09327e7cb7d3167609eb3ce68eadf6443 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
@@ -72,9 +72,14 @@ public class RespawnAnchorBlock extends Block {
|
||||
if (!world.isClientSide) {
|
||||
ServerPlayer serverPlayer = (ServerPlayer)player;
|
||||
if (serverPlayer.getRespawnDimension() != world.dimension() || !pos.equals(serverPlayer.getRespawnPosition())) {
|
||||
- serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true);
|
||||
+ if (serverPlayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - PlayerSetSpawnEvent
|
||||
world.playSound((Player)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return InteractionResult.SUCCESS;
|
||||
+ // Paper start - handle failed set spawn
|
||||
+ } else {
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 8ffef2843d8d4fa6ddfc0fb1403c6eacdafa63a9..0d7da68faa8c3401dcc12c67ae9edd977c436e55 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1204,9 +1204,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location location, boolean override) {
|
||||
if (location == null) {
|
||||
- this.getHandle().setRespawnPosition(null, null, 0.0F, override, false);
|
||||
+ this.getHandle().setRespawnPosition(null, null, 0.0F, override, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLUGIN); // Paper - PlayerSetSpawnEvent
|
||||
} else {
|
||||
- this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false);
|
||||
+ this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), override, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLUGIN); // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:30:17 -0700
|
||||
Subject: [PATCH] Make hoppers respect inventory max stack size
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index a7ac6b528aecae528a17af157f8ec29371e4484c..ccad692aba2ed77259f6814d88f01b91ed9d229b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -586,17 +586,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
+ ItemStack leftover = ItemStack.EMPTY; // Paper
|
||||
if (!stack.isEmpty() && stack.getCount() > to.getMaxStackSize()) {
|
||||
+ leftover = stack; // Paper
|
||||
stack = stack.split(to.getMaxStackSize());
|
||||
}
|
||||
// Spigot end
|
||||
IGNORE_TILE_UPDATES = true; // Paper
|
||||
to.setItem(slot, stack);
|
||||
IGNORE_TILE_UPDATES = false; // Paper
|
||||
- stack = ItemStack.EMPTY;
|
||||
+ stack = leftover; // Paper
|
||||
flag = true;
|
||||
} else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) {
|
||||
- int j = stack.getMaxStackSize() - itemstack1.getCount();
|
||||
+ int j = Math.min(stack.getMaxStackSize(), to.getMaxStackSize()) - itemstack1.getCount(); // Paper
|
||||
int k = Math.min(stack.getCount(), j);
|
||||
|
||||
stack.shrink(k);
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Sun, 8 Aug 2021 00:52:54 -0400
|
||||
Subject: [PATCH] Optimize entity tracker passenger checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index ddc5b4849939a96b76611cfa1cd34c06c7acc0f8..5246d427973f34843046e59c198785c73fccec33 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -71,7 +71,7 @@ public class ServerEntity {
|
||||
this.trackedPlayers = trackedPlayers;
|
||||
// CraftBukkit end
|
||||
this.ap = Vec3.ZERO;
|
||||
- this.lastPassengers = Collections.emptyList();
|
||||
+ this.lastPassengers = com.google.common.collect.ImmutableList.of(); // Paper - optimize passenger checks
|
||||
this.level = worldserver;
|
||||
this.broadcast = consumer;
|
||||
this.entity = entity;
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 2 Dec 2020 03:07:58 -0800
|
||||
Subject: [PATCH] Config option for Piglins guarding chests
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
index 8aecd15cfb915f44bc6208b656e7db309270c132..9f220cf0668b5153c419215e8e25e418e765a1d6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -463,6 +463,7 @@ public class PiglinAi {
|
||||
}
|
||||
|
||||
public static void angerNearbyPiglins(Player player, boolean blockOpen) {
|
||||
+ if (!player.level.paperConfig().entities.behavior.piglinsGuardChests) return; // Paper
|
||||
List<Piglin> list = player.level.getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D));
|
||||
|
||||
list.stream().filter(PiglinAi::isIdle).filter((entitypiglin) -> {
|
65
patches/server/0696-Added-EntityDamageItemEvent.patch
Normal file
65
patches/server/0696-Added-EntityDamageItemEvent.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 22 Dec 2020 13:52:48 -0800
|
||||
Subject: [PATCH] Added EntityDamageItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index b4ad1610d30396be344a04f5f3a565ae2b8f2265..5c987e863a6ef257caebf8321fa3048dfc7a93c5 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -547,7 +547,7 @@ public final class ItemStack {
|
||||
return this.getItem().getMaxDamage();
|
||||
}
|
||||
|
||||
- public boolean hurt(int amount, RandomSource random, @Nullable ServerPlayer player) {
|
||||
+ public boolean hurt(int amount, RandomSource random, @Nullable LivingEntity player) { // Paper - allow any living entity instead of only ServerPlayers
|
||||
if (!this.isDamageableItem()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -565,8 +565,8 @@ public final class ItemStack {
|
||||
|
||||
amount -= k;
|
||||
// CraftBukkit start
|
||||
- if (player != null) {
|
||||
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer) { // Paper
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (amount != event.getDamage() || event.isCancelled()) {
|
||||
@@ -577,6 +577,14 @@ public final class ItemStack {
|
||||
}
|
||||
|
||||
amount = event.getDamage();
|
||||
+ // Paper start - EntityDamageItemEvent
|
||||
+ } else if (player != null) {
|
||||
+ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ amount = event.getDamage();
|
||||
+ // Paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (amount <= 0) {
|
||||
@@ -584,8 +592,8 @@ public final class ItemStack {
|
||||
}
|
||||
}
|
||||
|
||||
- if (player != null && amount != 0) {
|
||||
- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(player, this, this.getDamageValue() + amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer && amount != 0) { // Paper
|
||||
+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, this.getDamageValue() + amount); // Paper
|
||||
}
|
||||
|
||||
j = this.getDamageValue() + amount;
|
||||
@@ -597,7 +605,7 @@ public final class ItemStack {
|
||||
public <T extends LivingEntity> void hurtAndBreak(int amount, T entity, Consumer<T> breakCallback) {
|
||||
if (!entity.level.isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) {
|
||||
if (this.isDamageableItem()) {
|
||||
- if (this.hurt(amount, entity.getRandom(), entity instanceof ServerPlayer ? (ServerPlayer) entity : null)) {
|
||||
+ if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent
|
||||
breakCallback.accept(entity);
|
||||
Item item = this.getItem();
|
||||
// CraftBukkit start - Check for item breaking
|
|
@ -0,0 +1,52 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 9 Aug 2021 00:38:37 -0400
|
||||
Subject: [PATCH] Optimize indirect passenger iteration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 4888873a5efa026a1082c9f216eecc950b6f2471..460b51374e41c3d88e1c3641fb9f2f0205399b54 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3596,26 +3596,41 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
private Stream<Entity> getIndirectPassengersStream() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(); } // Paper
|
||||
return this.passengers.stream().flatMap(Entity::getSelfAndPassengers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getSelfAndPassengers() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(Stream.of(this), this.getIndirectPassengersStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getPassengersAndSelf() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(this.passengers.stream().flatMap(Entity::getPassengersAndSelf), Stream.of(this));
|
||||
}
|
||||
|
||||
public Iterable<Entity> getIndirectPassengers() {
|
||||
+ // Paper start - rewrite this method
|
||||
+ if (this.passengers.isEmpty()) { return ImmutableList.of(); }
|
||||
+ ImmutableList.Builder<Entity> indirectPassengers = ImmutableList.builder();
|
||||
+ for (Entity passenger : this.passengers) {
|
||||
+ indirectPassengers.add(passenger);
|
||||
+ indirectPassengers.addAll(passenger.getIndirectPassengers());
|
||||
+ }
|
||||
+ return indirectPassengers.build();
|
||||
+ }
|
||||
+ private Iterable<Entity> getIndirectPassengers_old() {
|
||||
+ // Paper end
|
||||
return () -> {
|
||||
return this.getIndirectPassengersStream().iterator();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean hasExactlyOnePlayerPassenger() {
|
||||
+ if (this.passengers.isEmpty()) { return false; } // Paper
|
||||
return this.getIndirectPassengersStream().filter((entity) -> {
|
||||
return entity instanceof Player;
|
||||
}).count() == 1L;
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Thu, 12 Aug 2021 21:15:38 -0700
|
||||
Subject: [PATCH] Fix block drops position losing precision millions of blocks
|
||||
out
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index cb11cef117fc896ddcb40993ddb852a2e717c2ad..2db7b9f145b53df5ef79ae235a0de7ccff50db7e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -346,9 +346,11 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
|
||||
public static void popResource(Level world, BlockPos pos, ItemStack stack) {
|
||||
float f = EntityType.ITEM.getHeight() / 2.0F;
|
||||
- double d0 = (double) ((float) pos.getX() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
- double d1 = (double) ((float) pos.getY() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D) - (double) f;
|
||||
- double d2 = (double) ((float) pos.getZ() + 0.5F) + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ // Paper start - don't convert potentially massive numbers to floats
|
||||
+ double d0 = pos.getX() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ double d1 = pos.getY() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D) - (double) f;
|
||||
+ double d2 = pos.getZ() + 0.5D + Mth.nextDouble(world.random, -0.25D, 0.25D);
|
||||
+ // Paper end
|
||||
|
||||
Block.popResource(world, () -> {
|
||||
return new ItemEntity(world, d0, d1, d2, stack);
|
||||
@@ -361,9 +363,11 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
int k = direction.getStepZ();
|
||||
float f = EntityType.ITEM.getWidth() / 2.0F;
|
||||
float f1 = EntityType.ITEM.getHeight() / 2.0F;
|
||||
- double d0 = (double) ((float) pos.getX() + 0.5F) + (i == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) i * (0.5F + f)));
|
||||
- double d1 = (double) ((float) pos.getY() + 0.5F) + (j == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) j * (0.5F + f1))) - (double) f1;
|
||||
- double d2 = (double) ((float) pos.getZ() + 0.5F) + (k == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) k * (0.5F + f)));
|
||||
+ // Paper start - don't convert potentially massive numbers to floats
|
||||
+ double d0 = pos.getX() + 0.5D + (i == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) i * (0.5F + f)));
|
||||
+ double d1 = pos.getY() + 0.5D + (j == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) j * (0.5F + f1))) - (double) f1;
|
||||
+ double d2 = pos.getZ() + 0.5D + (k == 0 ? Mth.nextDouble(world.random, -0.25D, 0.25D) : (double) ((float) k * (0.5F + f)));
|
||||
+ // Paper end
|
||||
double d3 = i == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double) i * 0.1D;
|
||||
double d4 = j == 0 ? Mth.nextDouble(world.random, 0.0D, 0.1D) : (double) j * 0.1D + 0.1D;
|
||||
double d5 = k == 0 ? Mth.nextDouble(world.random, -0.1D, 0.1D) : (double) k * 0.1D;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
|
||||
Date: Fri, 13 Aug 2021 01:14:38 +0200
|
||||
Subject: [PATCH] Configurable item frame map cursor update interval
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 5246d427973f34843046e59c198785c73fccec33..c84ec3b93f2783de7a2815f23a9f1de89c1ab109 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -100,7 +100,7 @@ public class ServerEntity {
|
||||
if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
|
||||
ItemStack itemstack = entityitemframe.getItem();
|
||||
|
||||
- if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
+ if (this.level.paperConfig().maps.itemFrameCursorUpdateInterval > 0 && this.tickCount % this.level.paperConfig().maps.itemFrameCursorUpdateInterval == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks // Paper - Make item frame map cursor update interval configurable
|
||||
Integer integer = MapItem.getMapId(itemstack);
|
||||
MapItemSavedData worldmap = MapItem.getSavedData(integer, this.level);
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 21:25:31 -0800
|
||||
Subject: [PATCH] Make EntityUnleashEvent cancellable
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 837c0a8bd15388bdb60d6950a437640459adde3c..a49dfe4f81d449c5dd7ba5b8f9af7fec5c54f5de 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1482,7 +1482,7 @@ public abstract class Mob extends LivingEntity {
|
||||
if (flag1 && this.isLeashed()) {
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return flag1; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
index f5cb3576aa2560c86f4a1df9d51d8ecde4e98905..7b2a81f9a79c5e96beba44ffe9b56a305ac2404f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level.paperConfig().misc.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level.getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) return;
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
20
patches/server/0701-Clear-bucket-NBT-after-dispense.patch
Normal file
20
patches/server/0701-Clear-bucket-NBT-after-dispense.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 13 Aug 2021 15:00:06 -0700
|
||||
Subject: [PATCH] Clear bucket NBT after dispense
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
index 15fc100e468e68cbb0c43363c0eb25dc2ef8c6e0..3d2b5f040715a0e4fac0e6786bd11a4d715330ce 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
@@ -642,8 +642,7 @@ public interface DispenseItemBehavior {
|
||||
Item item = Items.BUCKET;
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty()) {
|
||||
- stack.setItem(Items.BUCKET);
|
||||
- stack.setCount(1);
|
||||
+ stack = new ItemStack(item); // Paper - clear tag
|
||||
} else if (((DispenserBlockEntity) pointer.getEntity()).addItem(new ItemStack(item)) < 0) {
|
||||
this.defaultDispenseItemBehavior.dispense(pointer, new ItemStack(item));
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 21 Aug 2021 12:13:53 -0700
|
||||
Subject: [PATCH] Change EnderEye target without changing other things
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
index 16f520706c22bd55135fe2bc114bdf440925333b..ac4b6840cca345416a9e5695fc07879cd96f64d2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
@@ -75,6 +75,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
}
|
||||
|
||||
public void signalTo(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ this.signalTo(pos, true);
|
||||
+ }
|
||||
+ public void signalTo(BlockPos pos, boolean update) {
|
||||
+ // Paper end
|
||||
double d0 = (double) pos.getX();
|
||||
int i = pos.getY();
|
||||
double d1 = (double) pos.getZ();
|
||||
@@ -92,8 +97,10 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
this.tz = d1;
|
||||
}
|
||||
|
||||
+ if (update) { // Paper
|
||||
this.life = 0;
|
||||
this.surviveAfterDeath = this.random.nextInt(5) > 0;
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
index 705dcae8f881cbdf5ff468f945b9269f9eae0e58..13c1188639e00cd96e00b179c4e353582bf66e64 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
@@ -38,8 +38,15 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
|
||||
|
||||
@Override
|
||||
public void setTargetLocation(Location location) {
|
||||
+ // Paper start
|
||||
+ this.setTargetLocation(location, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTargetLocation(Location location, boolean update) {
|
||||
+ // Paper end
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
|
||||
- this.getHandle().signalTo(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
+ this.getHandle().signalTo(new BlockPos(location.getX(), location.getY(), location.getZ()), update); // Paper
|
||||
}
|
||||
|
||||
@Override
|
86
patches/server/0703-Add-BlockBreakBlockEvent.patch
Normal file
86
patches/server/0703-Add-BlockBreakBlockEvent.patch
Normal file
|
@ -0,0 +1,86 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 17:58:11 -0800
|
||||
Subject: [PATCH] Add BlockBreakBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index 2db7b9f145b53df5ef79ae235a0de7ccff50db7e..2e65b44f10aeb44fd524a58e7eb815a566c1ad61 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -333,6 +333,23 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
}
|
||||
|
||||
}
|
||||
+ // Paper start
|
||||
+ public static boolean dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity, BlockPos source) {
|
||||
+ if (world instanceof ServerLevel) {
|
||||
+ List<org.bukkit.inventory.ItemStack> items = com.google.common.collect.Lists.newArrayList();
|
||||
+ for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) {
|
||||
+ items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop));
|
||||
+ }
|
||||
+ io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items);
|
||||
+ event.callEvent();
|
||||
+ for (var drop : event.getDrops()) {
|
||||
+ popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop));
|
||||
+ }
|
||||
+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) {
|
||||
if (world instanceof ServerLevel) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index 8d73893100884c08aa552ff41c2a07a3e714df47..24a822ade17849a083161216c184f02c30b5cb1f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -400,7 +400,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
iblockdata1 = world.getBlockState(blockposition3);
|
||||
BlockEntity tileentity = iblockdata1.hasBlockEntity() ? world.getBlockEntity(blockposition3) : null;
|
||||
|
||||
- dropResources(iblockdata1, world, blockposition3, tileentity);
|
||||
+ dropResources(iblockdata1, world, blockposition3, tileentity, pos); // Paper
|
||||
world.setBlock(blockposition3, Blocks.AIR.defaultBlockState(), 18);
|
||||
world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition3, GameEvent.Context.of(iblockdata1));
|
||||
if (!iblockdata1.is(BlockTags.FIRE)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index 02be7c3d104fe3b3a2772201f5ebdfb6d16e9b49..ff40fe323964f173561a6838fb443e79abf9df38 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -294,7 +294,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
((LiquidBlockContainer) state.getBlock()).placeLiquid(world, pos, state, fluidState);
|
||||
} else {
|
||||
if (!state.isAir()) {
|
||||
- this.beforeDestroyingBlock(world, pos, state);
|
||||
+ this.beforeDestroyingBlock(world, pos, state, pos.relative(direction.getOpposite())); // Paper
|
||||
}
|
||||
|
||||
world.setBlock(pos, fluidState.createLegacyBlock(), 3);
|
||||
@@ -302,6 +302,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
}
|
||||
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) { beforeDestroyingBlock(world, pos, state); } // Paper - add source parameter
|
||||
protected abstract void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state);
|
||||
|
||||
private static short getCacheKey(BlockPos blockposition, BlockPos blockposition1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
index a10b6a6b0ff9c104a94be3e9d0d1757333d81a00..ac33ba631f4b0ae0e08bff5748440ef5b76c2117 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
@@ -63,6 +63,13 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) {
|
||||
+ BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
+ Block.dropResources(state, world, pos, tileentity, source);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
|
@ -0,0 +1,84 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 26 Sep 2021 12:57:28 -0700
|
||||
Subject: [PATCH] Option to prevent NBT copy in smithing recipes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java b/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
index d80fc47820edbb3bea439aedf2e02e82c1931e35..076e10e5d7908c590402cfbb739bf73bc00276ce 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
@@ -25,8 +25,15 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
final Ingredient addition;
|
||||
final ItemStack result;
|
||||
private final ResourceLocation id;
|
||||
+ final boolean copyNbt; // Paper
|
||||
|
||||
public UpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result) {
|
||||
+ // Paper start
|
||||
+ this(id, base, addition, result, true);
|
||||
+ }
|
||||
+ public UpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result, boolean copyNbt) {
|
||||
+ this.copyNbt = copyNbt;
|
||||
+ // Paper end
|
||||
this.id = id;
|
||||
this.base = base;
|
||||
this.addition = addition;
|
||||
@@ -41,11 +48,13 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
@Override
|
||||
public ItemStack assemble(Container inventory) {
|
||||
ItemStack itemstack = this.result.copy();
|
||||
+ if (copyNbt) { // Paper - copy nbt conditionally
|
||||
CompoundTag nbttagcompound = inventory.getItem(0).getTag();
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
itemstack.setTag(nbttagcompound.copy());
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -96,7 +105,7 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
public Recipe toBukkitRecipe() {
|
||||
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
|
||||
- CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper
|
||||
|
||||
return recipe;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
index 0353ba44015cb72efa3892c527568902c9fa626b..bfd6b859fcfed89d0ebaca5200b7ca6f5d353d04 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
@@ -8,15 +8,21 @@ import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.SmithingRecipe;
|
||||
|
||||
public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
+ @Deprecated // Paper
|
||||
public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, result, base, addition);
|
||||
}
|
||||
+ // Paper start
|
||||
+ public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
||||
+ super(key, result, base, addition, copyNbt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static CraftSmithingRecipe fromBukkitRecipe(SmithingRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingRecipe) {
|
||||
return (CraftSmithingRecipe) recipe;
|
||||
}
|
||||
- CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition());
|
||||
+ CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,6 +30,6 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.UpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.UpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt())); // Paper
|
||||
}
|
||||
}
|
100
patches/server/0705-More-CommandBlock-API.patch
Normal file
100
patches/server/0705-More-CommandBlock-API.patch
Normal file
|
@ -0,0 +1,100 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 23 Sep 2021 10:40:09 -0700
|
||||
Subject: [PATCH] More CommandBlock API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0b42306f17bf8850a13a51067c2d19e7583187e5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package io.papermc.paper.commands;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.command.CommandBlockHolder;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.minecraft.world.level.BaseCommandBlock;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public interface PaperCommandBlockHolder extends CommandBlockHolder {
|
||||
+
|
||||
+ BaseCommandBlock getCommandBlockHandle();
|
||||
+
|
||||
+ @Override
|
||||
+ default @NotNull Component lastOutput() {
|
||||
+ return PaperAdventure.asAdventure(getCommandBlockHandle().getLastOutput());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void lastOutput(@Nullable Component lastOutput) {
|
||||
+ getCommandBlockHandle().setLastOutput(PaperAdventure.asVanilla(lastOutput));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default int getSuccessCount() {
|
||||
+ return getCommandBlockHandle().getSuccessCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void setSuccessCount(int successCount) {
|
||||
+ getCommandBlockHandle().setSuccessCount(successCount);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
index c4ea6760f489e6171f9e6e170160b932597f842f..245a9b062a0033a39fd42f3ff94350192570aec4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
-public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
|
||||
+public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
|
||||
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
@@ -41,5 +41,10 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
public void name(net.kyori.adventure.text.Component name) {
|
||||
getSnapshot().getCommandBlock().setName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getSnapshot().getCommandBlock();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
index f9863e138994f6c7a7975a852f106faa96d52315..b709a1d909c189f60d0c3aa97b4b96623e7c1db0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
-public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
|
||||
+public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
private final PermissibleBase perm = new PermissibleBase(this);
|
||||
|
||||
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
|
||||
@@ -70,6 +70,17 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
||||
public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getHandle().getCommandBlock();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lastOutput(net.kyori.adventure.text.Component lastOutput) {
|
||||
+ io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput);
|
||||
+ getCommandBlockHandle().onUpdated();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 1 Oct 2021 08:04:39 -0700
|
||||
Subject: [PATCH] Add missing team sidebar display slots
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
index f1be7a4f96a556569e4a607959bfd085fa0cb64c..ca58cde37f4e5abeb33e2f583b3d53e80697eba9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
@@ -7,7 +7,8 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.RenderType;
|
||||
|
||||
public final class CraftScoreboardTranslations {
|
||||
- static final int MAX_DISPLAY_SLOT = 3;
|
||||
+ static final int MAX_DISPLAY_SLOT = Scoreboard.getDisplaySlotNames().length; // Paper
|
||||
+ @Deprecated // Paper
|
||||
static ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.of(
|
||||
DisplaySlot.BELOW_NAME, "belowName",
|
||||
DisplaySlot.PLAYER_LIST, "list",
|
||||
@@ -16,10 +17,12 @@ public final class CraftScoreboardTranslations {
|
||||
private CraftScoreboardTranslations() {}
|
||||
|
||||
public static DisplaySlot toBukkitSlot(int i) {
|
||||
+ if (true) return org.bukkit.scoreboard.DisplaySlot.NAMES.value(Scoreboard.getDisplaySlotName(i)); // Paper
|
||||
return CraftScoreboardTranslations.SLOTS.inverse().get(Scoreboard.getDisplaySlotName(i));
|
||||
}
|
||||
|
||||
public static int fromBukkitSlot(DisplaySlot slot) {
|
||||
+ if (true) return Scoreboard.getDisplaySlotByName(slot.getId()); // Paper
|
||||
return Scoreboard.getDisplaySlotByName(CraftScoreboardTranslations.SLOTS.get(slot));
|
||||
}
|
||||
|
||||
diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bb41a2f2c0a5e3b4cb3fe1b584e0ceb7a7116afb
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package io.papermc.paper.scoreboard;
|
||||
+
|
||||
+import net.minecraft.world.scores.Scoreboard;
|
||||
+import org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations;
|
||||
+import org.bukkit.scoreboard.DisplaySlot;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertNotEquals;
|
||||
+import static org.junit.Assert.assertNotNull;
|
||||
+
|
||||
+public class DisplaySlotTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testBukkitToMinecraftDisplaySlots() {
|
||||
+ for (DisplaySlot value : DisplaySlot.values()) {
|
||||
+ assertNotEquals(-1, CraftScoreboardTranslations.fromBukkitSlot(value));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testMinecraftToBukkitDisplaySlots() {
|
||||
+ for (String name : Scoreboard.getDisplaySlotNames()) {
|
||||
+ assertNotNull(CraftScoreboardTranslations.toBukkitSlot(Scoreboard.getDisplaySlotByName(name)));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
45
patches/server/0707-Add-back-EntityPortalExitEvent.patch
Normal file
45
patches/server/0707-Add-back-EntityPortalExitEvent.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 16 May 2021 09:39:46 -0700
|
||||
Subject: [PATCH] Add back EntityPortalExitEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 460b51374e41c3d88e1c3641fb9f2f0205399b54..3f4436a2257376f604926ff35c8589ba59c859e2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3098,6 +3098,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
worldserver = shapedetectorshape.world;
|
||||
+ // Paper start - Call EntityPortalExitEvent
|
||||
+ CraftEntity bukkitEntity = this.getBukkitEntity();
|
||||
+ Vec3 position = shapedetectorshape.pos;
|
||||
+ float yaw = shapedetectorshape.yRot;
|
||||
+ float pitch = bukkitEntity.getLocation().getPitch(); // Keep entity pitch as per moveTo line below
|
||||
+ Vec3 velocity = shapedetectorshape.speed;
|
||||
+ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(bukkitEntity,
|
||||
+ bukkitEntity.getLocation(), new Location(worldserver.getWorld(), position.x, position.y, position.z, yaw, pitch),
|
||||
+ bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed));
|
||||
+ if (event.callEvent() && event.getTo() != null && this.isAlive()) {
|
||||
+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
+ position = new Vec3(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
+ yaw = event.getTo().getYaw();
|
||||
+ pitch = event.getTo().getPitch();
|
||||
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (worldserver == this.level) {
|
||||
// SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
|
||||
this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
|
||||
@@ -3117,8 +3134,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
if (entity != null) {
|
||||
entity.restoreFrom(this);
|
||||
- entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
|
||||
- entity.setDeltaMovement(shapedetectorshape.speed);
|
||||
+ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - use EntityPortalExitEvent values
|
||||
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
||||
worldserver.addDuringTeleport(entity);
|
||||
if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit
|
||||
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
|
|
@ -0,0 +1,58 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Zacek <dawon@dawon.eu>
|
||||
Date: Mon, 4 Oct 2021 10:16:44 +0200
|
||||
Subject: [PATCH] Add methods to find targets for lightning strikes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 4bebe9bc9dea53d57543e65d7300f50b0f907017..8c95d537c7bf5cc9b63f0e412c9ad67f5e6fe51e 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -776,6 +776,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
protected BlockPos findLightningTargetAround(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ return this.findLightningTargetAround(pos, false);
|
||||
+ }
|
||||
+ public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) {
|
||||
+ // Paper end
|
||||
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
|
||||
|
||||
@@ -790,6 +795,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (!list.isEmpty()) {
|
||||
return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition();
|
||||
} else {
|
||||
+ if (returnNullWhenNoTarget) return null; // Paper
|
||||
if (blockposition1.getY() == this.getMinBuildHeight() - 1) {
|
||||
blockposition1 = blockposition1.above(2);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 59bf99a51d386851501b0acf2f07679f497d3132..9d3f7f196c4331662c4c78cac0b047bcd2ff5e77 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -697,6 +697,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return (LightningStrike) lightning.getBukkitEntity();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public Location findLightningRod(Location location) {
|
||||
+ return this.world.findLightningRod(net.minecraft.server.MCUtil.toBlockPosition(location))
|
||||
+ .map(blockPos -> net.minecraft.server.MCUtil.toLocation(this.world, blockPos)
|
||||
+ // get the actual rod pos
|
||||
+ .subtract(0, 1, 0))
|
||||
+ .orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location findLightningTarget(Location location) {
|
||||
+ final BlockPos pos = this.world.findLightningTargetAround(net.minecraft.server.MCUtil.toBlockPosition(location), true);
|
||||
+ return pos == null ? null : net.minecraft.server.MCUtil.toLocation(this.world, pos);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type) {
|
||||
return generateTree(loc, CraftWorld.rand, type);
|
159
patches/server/0709-Get-entity-default-attributes.patch
Normal file
159
patches/server/0709-Get-entity-default-attributes.patch
Normal file
|
@ -0,0 +1,159 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 20 Aug 2021 13:03:21 -0700
|
||||
Subject: [PATCH] Get entity default attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12135ffeacd648f6bc4d7d327059ea1a7e8c79c4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
@@ -0,0 +1,30 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+
|
||||
+public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
|
||||
+
|
||||
+ public UnmodifiableAttributeInstance(AttributeInstance handle, Attribute attribute) {
|
||||
+ super(handle, attribute);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBaseValue(double d) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addModifier(AttributeModifier modifier) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void removeModifier(AttributeModifier modifier) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4ecba0b02c2813a890aecc558698787946d2ccb8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java
|
||||
@@ -0,0 +1,43 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import com.google.common.util.concurrent.Callables;
|
||||
+import com.google.common.util.concurrent.Runnables;
|
||||
+import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
+import org.bukkit.attribute.Attributable;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeInstance;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+
|
||||
+public class UnmodifiableAttributeMap implements Attributable {
|
||||
+
|
||||
+
|
||||
+ private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
+ private final AttributeSupplier handle;
|
||||
+
|
||||
+ public UnmodifiableAttributeMap(@NotNull AttributeSupplier handle) {
|
||||
+ this.handle = handle;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable AttributeInstance getAttribute(@NotNull Attribute attribute) {
|
||||
+ var nmsAttribute = CraftAttributeMap.toMinecraft(attribute);
|
||||
+ var nmsAttributeInstance = this.handle.instances.get(nmsAttribute);
|
||||
+ if (nmsAttribute == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return new UnmodifiableAttributeInstance(nmsAttributeInstance, attribute);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void registerAttribute(@NotNull Attribute attribute) {
|
||||
+ throw new UnsupportedOperationException("Cannot register new attributes here");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index c98c5e070349e5c9356a3dec2344a135ad8f0b56..7e024b0f0a5201b4e9e7fcd7a160b146d7f12b52 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -562,6 +562,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public int getProtocolVersion() {
|
||||
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasDefaultEntityAttributes(NamespacedKey bukkitEntityKey) {
|
||||
+ return net.minecraft.world.entity.ai.attributes.DefaultAttributes.hasSupplier(net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.attribute.Attributable getDefaultEntityAttributes(NamespacedKey bukkitEntityKey) {
|
||||
+ Preconditions.checkArgument(hasDefaultEntityAttributes(bukkitEntityKey), bukkitEntityKey + " doesn't have default attributes");
|
||||
+ var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
+ return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java b/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7b999deba66aa6d22cd7520f6c13550a44ca327d
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import org.bukkit.attribute.Attributable;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeInstance;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertFalse;
|
||||
+import static org.junit.Assert.assertNotNull;
|
||||
+import static org.junit.Assert.assertThrows;
|
||||
+import static org.junit.Assert.assertTrue;
|
||||
+
|
||||
+public class EntityTypeAttributesTest extends AbstractTestingBase {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testIllegalEntity() {
|
||||
+ assertFalse(EntityType.EGG.hasDefaultAttributes());
|
||||
+ assertThrows(IllegalArgumentException.class, () -> EntityType.EGG.getDefaultAttributes());
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testLegalEntity() {
|
||||
+ assertTrue(EntityType.ZOMBIE.hasDefaultAttributes());
|
||||
+ EntityType.ZOMBIE.getDefaultAttributes();
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testUnmodifiabilityOfAttributable() {
|
||||
+ Attributable attributable = EntityType.ZOMBIE.getDefaultAttributes();
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> attributable.registerAttribute(Attribute.GENERIC_ATTACK_DAMAGE));
|
||||
+ AttributeInstance instance = attributable.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
||||
+ assertNotNull(instance);
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> instance.addModifier(new AttributeModifier("test", 3, AttributeModifier.Operation.ADD_NUMBER)));
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> instance.setBaseValue(3.2));
|
||||
+ }
|
||||
+}
|
26
patches/server/0710-Left-handed-API.patch
Normal file
26
patches/server/0710-Left-handed-API.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 14 Oct 2021 12:36:58 -0500
|
||||
Subject: [PATCH] Left handed API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
index d9008049188c1933f2b6b39b9219983ff947b4bf..d775e19402188e35f79affb4ed636b6533f90ab5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
@@ -130,5 +130,15 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||
public int getMaxHeadPitch() {
|
||||
return getHandle().getMaxHeadXRot();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isLeftHanded() {
|
||||
+ return getHandle().isLeftHanded();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLeftHanded(boolean leftHanded) {
|
||||
+ getHandle().setLeftHanded(leftHanded);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
159
patches/server/0711-Add-advancement-display-API.patch
Normal file
159
patches/server/0711-Add-advancement-display-API.patch
Normal file
|
@ -0,0 +1,159 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: syldium <syldium@mailo.com>
|
||||
Date: Fri, 9 Jul 2021 18:50:40 +0200
|
||||
Subject: [PATCH] Add advancement display API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java b/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0567e500c40d3d424ddc19062c4f6da902e8586e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java
|
||||
@@ -0,0 +1,63 @@
|
||||
+package io.papermc.paper.advancement;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.minecraft.advancements.DisplayInfo;
|
||||
+import net.minecraft.advancements.FrameType;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public record PaperAdvancementDisplay(DisplayInfo handle) implements AdvancementDisplay {
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Frame frame() {
|
||||
+ return asPaperFrame(this.handle.getFrame());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component title() {
|
||||
+ return PaperAdventure.asAdventure(this.handle.getTitle());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component description() {
|
||||
+ return PaperAdventure.asAdventure(this.handle.getDescription());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull ItemStack icon() {
|
||||
+ return CraftItemStack.asBukkitCopy(this.handle.getIcon());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doesShowToast() {
|
||||
+ return this.handle.shouldShowToast();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doesAnnounceToChat() {
|
||||
+ return this.handle.shouldAnnounceChat();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isHidden() {
|
||||
+ return this.handle.isHidden();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable NamespacedKey backgroundPath() {
|
||||
+ return this.handle.getBackground() == null ? null : CraftNamespacedKey.fromMinecraft(this.handle.getBackground());
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull Frame asPaperFrame(@NotNull FrameType frameType) {
|
||||
+ return switch (frameType) {
|
||||
+ case TASK -> Frame.TASK;
|
||||
+ case CHALLENGE -> Frame.CHALLENGE;
|
||||
+ case GOAL -> Frame.GOAL;
|
||||
+ };
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
index db939a754e9308ad68f1b09a970f7a1b00a673bf..538f19f15b553d14ad95f09b1c81359f4c68b17f 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
@@ -28,6 +28,7 @@ public class DisplayInfo {
|
||||
private final boolean hidden;
|
||||
private float x;
|
||||
private float y;
|
||||
+ public final io.papermc.paper.advancement.AdvancementDisplay paper = new io.papermc.paper.advancement.PaperAdvancementDisplay(this); // Paper
|
||||
|
||||
public DisplayInfo(ItemStack icon, Component title, Component description, @Nullable ResourceLocation background, FrameType frame, boolean showToast, boolean announceToChat, boolean hidden) {
|
||||
this.title = title;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
index c47cae84f3b6970247d78382f48ae8ddbc202b59..0a46eeefa7d704350321828166f0049d497e3e41 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
@@ -29,12 +29,33 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
||||
return Collections.unmodifiableCollection(this.handle.getCriteria().keySet());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
@Override
|
||||
- public AdvancementDisplay getDisplay() {
|
||||
- if (this.handle.getDisplay() == null) {
|
||||
- return null;
|
||||
+ public io.papermc.paper.advancement.AdvancementDisplay getDisplay() {
|
||||
+ return this.handle.getDisplay() == null ? null : this.handle.getDisplay().paper;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.advancement.Advancement getParent() {
|
||||
+ return this.handle.getParent() == null ? null : this.handle.getParent().bukkit;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Collection<org.bukkit.advancement.Advancement> getChildren() {
|
||||
+ final var children = com.google.common.collect.ImmutableList.<org.bukkit.advancement.Advancement>builder();
|
||||
+ for (Advancement advancement : this.handle.getChildren()) {
|
||||
+ children.add(advancement.bukkit);
|
||||
}
|
||||
+ return children.build();
|
||||
+ }
|
||||
|
||||
- return new CraftAdvancementDisplay(this.handle.getDisplay());
|
||||
+ @Override
|
||||
+ public org.bukkit.advancement.Advancement getRoot() {
|
||||
+ Advancement advancement = this.handle;
|
||||
+ while (advancement.getParent() != null) {
|
||||
+ advancement = advancement.getParent();
|
||||
+ }
|
||||
+ return advancement.bukkit;
|
||||
}
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4d043e0e43ef8bb75788e195f95b5a50a51a2a48
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
|
||||
@@ -0,0 +1,24 @@
|
||||
+package io.papermc.paper.advancement;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import net.minecraft.advancements.FrameType;
|
||||
+import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertEquals;
|
||||
+
|
||||
+public class AdvancementFrameTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void test() {
|
||||
+ for (FrameType nmsFrameType : FrameType.values()) {
|
||||
+ final TextColor expectedColor = PaperAdventure.asAdventure(nmsFrameType.getChatColor());
|
||||
+ final String expectedTranslationKey = ((TranslatableContents) nmsFrameType.getDisplayName().getContents()).getKey();
|
||||
+ final var frame = PaperAdvancementDisplay.asPaperFrame(nmsFrameType);
|
||||
+ assertEquals("The translation keys should be the same", expectedTranslationKey, frame.translationKey());
|
||||
+ assertEquals("The frame colors should be the same", expectedColor, frame.color());
|
||||
+ assertEquals(nmsFrameType.getName(), AdvancementDisplay.Frame.NAMES.key(frame));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
28
patches/server/0712-Add-ItemFactory-getMonsterEgg-API.patch
Normal file
28
patches/server/0712-Add-ItemFactory-getMonsterEgg-API.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 14 Oct 2021 12:09:39 -0500
|
||||
Subject: [PATCH] Add ItemFactory#getMonsterEgg API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
index f3a6a4d97b5be2e75c438a6f7010a8f588afe86c..4a8ac558d308c4e3bc63cdd8d7071a3f9ff3aa81 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
@@ -440,5 +440,17 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
entity.getUniqueId().toString(),
|
||||
new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack getSpawnEgg(org.bukkit.entity.EntityType type) {
|
||||
+ if (type == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ String typeId = type.getKey().toString();
|
||||
+ net.minecraft.resources.ResourceLocation typeKey = new net.minecraft.resources.ResourceLocation(typeId);
|
||||
+ net.minecraft.world.entity.EntityType<?> nmsType = net.minecraft.core.Registry.ENTITY_TYPE.get(typeKey);
|
||||
+ net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.BY_ID.get(nmsType);
|
||||
+ return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
135
patches/server/0713-Add-critical-damage-API.patch
Normal file
135
patches/server/0713-Add-critical-damage-API.patch
Normal file
|
@ -0,0 +1,135 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dodison <kacpik@mapik.eu>
|
||||
Date: Mon, 26 Jul 2021 17:32:36 +0200
|
||||
Subject: [PATCH] Add critical damage API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
index 752f9f11227a47b7bed675b93e95af89c6732f63..67bce77093dcc126098731047447da2031e3388d 100644
|
||||
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
@@ -64,6 +64,19 @@ public class DamageSource {
|
||||
return this;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - add critical damage API
|
||||
+ private boolean critical;
|
||||
+ public boolean isCritical() {
|
||||
+ return this.critical;
|
||||
+ }
|
||||
+ public DamageSource critical() {
|
||||
+ return this.critical(true);
|
||||
+ }
|
||||
+ public DamageSource critical(boolean critical) {
|
||||
+ this.critical = critical;
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static DamageSource sting(LivingEntity attacker) {
|
||||
return new EntityDamageSource("sting", attacker);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 92a5aadef076cb905962dab86f32d4ff253fef93..5451b1d61ae2ee4fa461c2a334bfe8f794868030 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1274,7 +1274,7 @@ public abstract class Player extends LivingEntity {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
- boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity;
|
||||
+ boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; // Paper - Add critical damage API - conflict on change
|
||||
|
||||
flag2 = flag2 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper
|
||||
flag2 = flag2 && !this.isSprinting();
|
||||
@@ -1314,7 +1314,7 @@ public abstract class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
Vec3 vec3d = target.getDeltaMovement();
|
||||
- boolean flag5 = target.hurt(DamageSource.playerAttack(this), f);
|
||||
+ boolean flag5 = target.hurt(DamageSource.playerAttack(this).critical(flag2), f); // Paper - add critical damage API
|
||||
|
||||
if (flag5) {
|
||||
if (i > 0) {
|
||||
@@ -1342,7 +1342,7 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
|
||||
// CraftBukkit start - Only apply knockback if the damage hits
|
||||
- if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) {
|
||||
+ if (entityliving.hurt(DamageSource.playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API
|
||||
entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index f02fb03c63975e5c1ccdd848f5727559929cce00..8564ecd20578d907bcfa1b9c149da22e424e254a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -382,6 +382,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (this.isCritArrow()) damagesource = damagesource.critical(); // Paper - add critical damage API
|
||||
boolean flag = entity.getType() == EntityType.ENDERMAN;
|
||||
int k = entity.getRemainingFireTicks();
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 82d8a8c2199673315c7b52e694f798cc59c5f96c..03d389f3458cd77166a0319fa38c7207e8714e6f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -979,7 +979,7 @@ public class CraftEventFactory {
|
||||
} else {
|
||||
damageCause = DamageCause.ENTITY_EXPLOSION;
|
||||
}
|
||||
- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions);
|
||||
+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API
|
||||
}
|
||||
event.setCancelled(cancelled);
|
||||
|
||||
@@ -1008,7 +1008,7 @@ public class CraftEventFactory {
|
||||
cause = DamageCause.SONIC_BOOM;
|
||||
}
|
||||
|
||||
- return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
+ return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
||||
} else if (source == DamageSource.OUT_OF_WORLD) {
|
||||
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
|
||||
event.setCancelled(cancelled);
|
||||
@@ -1078,7 +1078,7 @@ public class CraftEventFactory {
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.msgId));
|
||||
}
|
||||
- EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
+ EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API
|
||||
event.setCancelled(cancelled);
|
||||
CraftEventFactory.callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
@@ -1123,20 +1123,28 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
- return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
+ return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.msgId));
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper - Add critical damage API
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
|
||||
return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false);
|
||||
}
|
||||
|
||||
+ // Paper start - Add critical damage API
|
||||
+ @Deprecated
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
||||
+ return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false, false);
|
||||
+ }
|
||||
+
|
||||
+ private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, boolean critical) {
|
||||
+ // Paper end
|
||||
EntityDamageEvent event;
|
||||
if (damager != null) {
|
||||
- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions, critical); // Paper - add critical damage API
|
||||
} else {
|
||||
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
}
|
44
patches/server/0714-Fix-issues-with-mob-conversion.patch
Normal file
44
patches/server/0714-Fix-issues-with-mob-conversion.patch
Normal file
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 24 Oct 2021 20:29:45 -0700
|
||||
Subject: [PATCH] Fix issues with mob conversion
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
index ded88c78c9000d4401d293d18b89b07ea46088dd..3a3f3358c4bbd16bdcadc56c6a865ecfb942ad54 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
@@ -86,10 +86,15 @@ public class Skeleton extends AbstractSkeleton {
|
||||
}
|
||||
|
||||
protected void doFreezeConversion() {
|
||||
- this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
|
||||
- if (!this.isSilent()) {
|
||||
+ Stray stray = this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons // Paper - track result of conversion
|
||||
+ if (stray != null && !this.isSilent()) { // Paper - only send event if conversion succeeded
|
||||
this.level.levelEvent((Player) null, 1048, this.blockPosition(), 0);
|
||||
}
|
||||
+ // Paper start - reset conversion time to prevent event spam
|
||||
+ if (stray == null) {
|
||||
+ this.conversionTime = 300;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
index 38f56cb4adeac0d7dcad63d0fbd98f17ab6e3b46..5e0e6ab7eaa9825b2f8c90353c30673dd43dd8b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
@@ -105,6 +105,11 @@ public abstract class AbstractPiglin extends Monster {
|
||||
if (entitypigzombie != null) {
|
||||
entitypigzombie.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
|
||||
}
|
||||
+ // Paper start - reset to prevent event spam
|
||||
+ else {
|
||||
+ this.timeInOverworld = 0;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 4 Nov 2021 11:50:40 -0700
|
||||
Subject: [PATCH] Add isCollidable methods to various places
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index b2628b1698ef2a235e7b465f09747cafbb133b7a..2881bcb570dc86a7602309e1f540ecd1c7f00284 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -480,6 +480,11 @@ public class CraftBlock implements Block {
|
||||
public boolean isSolid() {
|
||||
return getNMS().getMaterial().blocksMotion();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return getNMS().getBlock().hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
index 7b9e943b391c061782fccd2b8d705ceec8db50fe..966ac60daebb7bb211ab8096fc0c5f33db67320a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
@@ -324,4 +324,11 @@ public class CraftBlockState implements BlockState {
|
||||
throw new IllegalStateException("The blockState must be placed to call this method");
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return this.data.getBlock().hasCollision;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 7e024b0f0a5201b4e9e7fcd7a160b146d7f12b52..c3ac503bd2c04a94bc3c172b2c6bfe1308da29aa 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -574,6 +574,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable(Material material) {
|
||||
+ Preconditions.checkArgument(material.isBlock(), material + " is not a block");
|
||||
+ return getBlock(material).hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
42
patches/server/0716-Goat-ram-API.patch
Normal file
42
patches/server/0716-Goat-ram-API.patch
Normal file
|
@ -0,0 +1,42 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Seggan <segganew@gmail.com>
|
||||
Date: Thu, 5 Aug 2021 13:10:27 -0400
|
||||
Subject: [PATCH] Goat ram API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 1935db7bd6d0976fd0bb9e482cd8044b79b0a452..56dd01801f56c56d07101e7e22b58ac059f5f07f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -359,4 +359,15 @@ public class Goat extends Animal {
|
||||
public static boolean checkGoatSpawnRules(EntityType<? extends Animal> entityType, LevelAccessor world, MobSpawnType spawnReason, BlockPos pos, RandomSource random) {
|
||||
return world.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(world, pos);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Goat ram API
|
||||
+ public void ram(net.minecraft.world.entity.LivingEntity entity) {
|
||||
+ Brain<Goat> brain = this.getBrain();
|
||||
+ brain.setMemory(MemoryModuleType.RAM_TARGET, entity.position());
|
||||
+ brain.eraseMemory(MemoryModuleType.RAM_COOLDOWN_TICKS);
|
||||
+ brain.eraseMemory(MemoryModuleType.BREED_TARGET);
|
||||
+ brain.eraseMemory(MemoryModuleType.TEMPTING_PLAYER);
|
||||
+ brain.setActiveActivityIfPossible(net.minecraft.world.entity.schedule.Activity.RAM);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
index 9142b132f045af55b6bb436a39a9ca416bcfc698..e4be28b130e35ea263f85b3157898cd3a7e80561 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
@@ -54,4 +54,11 @@ public class CraftGoat extends CraftAnimals implements Goat {
|
||||
public void setScreaming(boolean screaming) {
|
||||
this.getHandle().setScreamingGoat(screaming);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Goat ram API
|
||||
+ @Override
|
||||
+ public void ram(@org.jetbrains.annotations.NotNull org.bukkit.entity.LivingEntity entity) {
|
||||
+ this.getHandle().ram(((CraftLivingEntity) entity).getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: booky10 <boooky10@gmail.com>
|
||||
Date: Fri, 5 Nov 2021 21:01:36 +0100
|
||||
Subject: [PATCH] Add API for resetting a single score
|
||||
|
||||
It was only possible to reset all scores for a specific entry, instead of resetting only specific scores.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
index 2c4ffed5e828f051c44f494a8ed599a8197d7450..3b26793b67282c3a20c023b9c13a2a9b54d5d932 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
@@ -68,4 +68,12 @@ final class CraftScore implements Score {
|
||||
public CraftScoreboard getScoreboard() {
|
||||
return this.objective.getScoreboard();
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void resetScore() {
|
||||
+ Scoreboard board = this.objective.checkState().board;
|
||||
+ board.resetPlayerScore(entry, this.objective.getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
81
patches/server/0718-Add-Raw-Byte-Entity-Serialization.patch
Normal file
81
patches/server/0718-Add-Raw-Byte-Entity-Serialization.patch
Normal file
|
@ -0,0 +1,81 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sun, 24 Oct 2021 16:20:31 -0400
|
||||
Subject: [PATCH] Add Raw Byte Entity Serialization
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 3f4436a2257376f604926ff35c8589ba59c859e2..6f3147713b5bec3b2771e1ec52917fd4aee681bc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -1921,6 +1921,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Entity serialization api
|
||||
+ public boolean serializeEntity(CompoundTag compound) {
|
||||
+ List<Entity> pass = new java.util.ArrayList<>(this.getPassengers());
|
||||
+ this.passengers = ImmutableList.of();
|
||||
+ boolean result = save(compound);
|
||||
+ this.passengers = ImmutableList.copyOf(pass);
|
||||
+ return result;
|
||||
+ }
|
||||
+ // Paper end
|
||||
public boolean save(CompoundTag nbt) {
|
||||
return this.isPassenger() ? false : this.saveAsPassenger(nbt);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index b8e5205c165bcba5b8383334f3d0d1daf9d0a8cd..ff8562821ebb363c755e9d316679226d9febe54f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1295,5 +1295,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
return set;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean spawnAt(Location location, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ Preconditions.checkNotNull(location, "location cannot be null");
|
||||
+ Preconditions.checkNotNull(reason, "reason cannot be null");
|
||||
+ entity.level = ((CraftWorld) location.getWorld()).getHandle();
|
||||
+ entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
+ entity.setRot(location.getYaw(), location.getPitch());
|
||||
+ return !entity.valid && entity.level.addFreshEntity(entity, reason);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index c3ac503bd2c04a94bc3c172b2c6bfe1308da29aa..1f491d48b591281e3a054c33683ac4cf76ada802 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -457,6 +457,30 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of((CompoundTag) converted.getValue()));
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public byte[] serializeEntity(org.bukkit.entity.Entity entity) {
|
||||
+ Preconditions.checkNotNull(entity, "null cannot be serialized");
|
||||
+ Preconditions.checkArgument(entity instanceof org.bukkit.craftbukkit.entity.CraftEntity, "only CraftEntities can be serialized");
|
||||
+
|
||||
+ CompoundTag compound = new CompoundTag();
|
||||
+ ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().serializeEntity(compound);
|
||||
+ return serializeNbtToBytes(compound);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.entity.Entity deserializeEntity(byte[] data, org.bukkit.World world, boolean preserveUUID) {
|
||||
+ Preconditions.checkNotNull(data, "null cannot be deserialized");
|
||||
+ Preconditions.checkArgument(data.length > 0, "cannot deserialize nothing");
|
||||
+
|
||||
+ CompoundTag compound = deserializeNbtFromBytes(data);
|
||||
+ int dataVersion = compound.getInt("DataVersion");
|
||||
+ Dynamic<Tag> converted = DataFixers.getDataFixer().update(References.ENTITY_TREE, new Dynamic<>(NbtOps.INSTANCE, compound), dataVersion, getDataVersion());
|
||||
+ compound = (CompoundTag) converted.getValue();
|
||||
+ if (!preserveUUID) compound.remove("UUID"); // Generate a new UUID so we don't have to worry about deserializing the same entity twice
|
||||
+ return net.minecraft.world.entity.EntityType.create(compound, ((org.bukkit.craftbukkit.CraftWorld) world).getHandle())
|
||||
+ .orElseThrow(() -> new IllegalArgumentException("An ID was not found for the data. Did you downgrade?")).getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
private byte[] serializeNbtToBytes(CompoundTag compound) {
|
||||
compound.putInt("DataVersion", getDataVersion());
|
||||
java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
|
79
patches/server/0719-Vanilla-command-permission-fixes.patch
Normal file
79
patches/server/0719-Vanilla-command-permission-fixes.patch
Normal file
|
@ -0,0 +1,79 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 25 Aug 2021 13:19:53 -0700
|
||||
Subject: [PATCH] Vanilla command permission fixes
|
||||
|
||||
Fixes permission checks for vanilla commands which don't have a
|
||||
requirement, as well as for namespaced vanilla commands.
|
||||
|
||||
diff --git a/src/main/java/com/mojang/brigadier/builder/ArgumentBuilder.java b/src/main/java/com/mojang/brigadier/builder/ArgumentBuilder.java
|
||||
index 899008b2980d13f1be6280cd8cb959c53a29bebf..f875507241ac6769545e91cd3285232b75b892f0 100644
|
||||
--- a/src/main/java/com/mojang/brigadier/builder/ArgumentBuilder.java
|
||||
+++ b/src/main/java/com/mojang/brigadier/builder/ArgumentBuilder.java
|
||||
@@ -14,9 +14,17 @@ import java.util.Collections;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class ArgumentBuilder<S, T extends ArgumentBuilder<S, T>> {
|
||||
+ // Paper start
|
||||
+ private static final Predicate<Object> DEFAULT_REQUIREMENT = s -> true;
|
||||
+
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ public static <S> Predicate<S> defaultRequirement() {
|
||||
+ return (Predicate<S>) DEFAULT_REQUIREMENT;
|
||||
+ }
|
||||
+ // Paper end
|
||||
private final RootCommandNode<S> arguments = new RootCommandNode<>();
|
||||
private Command<S> command;
|
||||
- private Predicate<S> requirement = s -> true;
|
||||
+ private Predicate<S> requirement = defaultRequirement(); // Paper
|
||||
private CommandNode<S> target;
|
||||
private RedirectModifier<S> modifier = null;
|
||||
private boolean forks;
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index edf980cf8992ddfe003ced279fe1324fc2364e5a..e70e5af7e49e4ccf332d9ce44e1a106344b35490 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -213,7 +213,13 @@ public class Commands {
|
||||
if (environment.includeIntegrated) {
|
||||
PublishCommand.register(this.dispatcher);
|
||||
}
|
||||
-
|
||||
+ // Paper start
|
||||
+ for (final CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
|
||||
+ if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.<CommandSourceStack>defaultRequirement()) {
|
||||
+ node.requirement = stack -> stack.source == CommandSource.NULL || stack.getBukkitSender().hasPermission(org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(node));
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
|
||||
index 5ed34b60a32a2aac214de84c44689fd5a0b00a10..8dca2ad7d25f740941187698d77819af8ebc2805 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/VanillaCommandWrapper.java
|
||||
@@ -87,7 +87,23 @@ public final class VanillaCommandWrapper extends BukkitCommand {
|
||||
}
|
||||
|
||||
public static String getPermission(CommandNode<CommandSourceStack> vanillaCommand) {
|
||||
- return "minecraft.command." + ((vanillaCommand.getRedirect() == null) ? vanillaCommand.getName() : vanillaCommand.getRedirect().getName());
|
||||
+ // Paper start
|
||||
+ final String commandName;
|
||||
+ if (vanillaCommand.getRedirect() == null) {
|
||||
+ commandName = vanillaCommand.getName();
|
||||
+ } else {
|
||||
+ commandName = vanillaCommand.getRedirect().getName();
|
||||
+ }
|
||||
+ return "minecraft.command." + stripDefaultNamespace(commandName);
|
||||
+ }
|
||||
+
|
||||
+ private static String stripDefaultNamespace(final String maybeNamespaced) {
|
||||
+ final String prefix = "minecraft:";
|
||||
+ if (maybeNamespaced.startsWith(prefix)) {
|
||||
+ return maybeNamespaced.substring(prefix.length());
|
||||
+ }
|
||||
+ return maybeNamespaced;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
private String toDispatcher(String[] args, String name) {
|
48
patches/server/0720-Make-CallbackExecutor-strict-again.patch
Normal file
48
patches/server/0720-Make-CallbackExecutor-strict-again.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Fri, 24 Apr 2020 09:06:15 -0700
|
||||
Subject: [PATCH] Make CallbackExecutor strict again
|
||||
|
||||
The correct fix for double scheduling is to avoid it. The reason
|
||||
this class is used is because double scheduling causes issues
|
||||
elsewhere, and it acts as an explicit detector of what double
|
||||
schedules. Effectively, use the callback executor as a tool of
|
||||
finding issues rather than hiding these issues.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index b659a058a0b6eb6b1827aacbd703e15fcbb1609c..2418f1c0dc050d224bb866e62f414a55900d9652 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -165,17 +165,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
||||
|
||||
- private final java.util.Queue<Runnable> queue = new java.util.ArrayDeque<>();
|
||||
+ private Runnable queued; // Paper - revert CB changes
|
||||
|
||||
@Override
|
||||
public void execute(Runnable runnable) {
|
||||
- this.queue.add(runnable);
|
||||
+ // Paper start - revert CB changes
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("Callback Executor execute");
|
||||
+ if (this.queued != null) {
|
||||
+ LOGGER.error("Failed to schedule runnable", new IllegalStateException("Already queued"));
|
||||
+ throw new IllegalStateException("Already queued");
|
||||
+ }
|
||||
+ this.queued = runnable;
|
||||
+ // Paper end - revert CB changes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
- Runnable task;
|
||||
- while ((task = this.queue.poll()) != null) {
|
||||
+ // Paper start - revert CB changes
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("Callback Executor execute");
|
||||
+ Runnable task = this.queued;
|
||||
+ if (task != null) {
|
||||
+ this.queued = null;
|
||||
+ // Paper end - revert CB changes
|
||||
task.run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 11 Mar 2021 02:32:30 -0800
|
||||
Subject: [PATCH] Do not allow the server to unload chunks at request of
|
||||
plugins
|
||||
|
||||
In general the chunk system is not well suited for this behavior,
|
||||
especially if it is called during a chunk load. The chunks pushed
|
||||
to be unloaded will simply be unloaded next tick, rather than
|
||||
immediately.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 918fda0fbbafa39ce0f421dcaf10f8dcf1e5dabb..30347bba40c77c95933997800b9149fcd2326bb1 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -873,6 +873,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
// CraftBukkit start - modelled on below
|
||||
public void purgeUnload() {
|
||||
+ if (true) return; // Paper - tickets will be removed later, this behavior isn't really well accounted for by the chunk system
|
||||
this.level.getProfiler().push("purge");
|
||||
this.distanceManager.purgeStaleTickets();
|
||||
this.runDistanceManagerUpdates();
|
|
@ -0,0 +1,68 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 11 Mar 2021 03:03:32 -0800
|
||||
Subject: [PATCH] Do not run close logic for inventories on chunk unload
|
||||
|
||||
Still call the event and change the active container though. We
|
||||
want to avoid close logic because it's possible to load the
|
||||
chunk through it. This should also be OK from a leak prevention/
|
||||
state desync POV because the TE is getting unloaded anyways.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 8c95d537c7bf5cc9b63f0e412c9ad67f5e6fe51e..2634eba0537648c0e013455e813e25897ea71ff0 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1334,9 +1334,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// Spigot Start
|
||||
for (net.minecraft.world.level.block.entity.BlockEntity tileentity : chunk.getBlockEntities().values()) {
|
||||
if (tileentity instanceof net.minecraft.world.Container) {
|
||||
+ // Paper start - this area looks like it can load chunks, change the behavior
|
||||
+ // chests for example can apply physics to the world
|
||||
+ // so instead we just change the active container and call the event
|
||||
for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) {
|
||||
- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
|
||||
+ ((org.bukkit.craftbukkit.entity.CraftHumanEntity)h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper
|
||||
}
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
// Spigot End
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index ec713ffb7c4cba53dc983ebde5596e4749107493..62f2c9645a3bf5b2bfd9fe99d3e6ec08c7dafa9a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1588,6 +1588,18 @@ public class ServerPlayer extends Player {
|
||||
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
+ // Paper start - special close for unloaded inventory
|
||||
+ @Override
|
||||
+ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
+ // copied from above
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit
|
||||
+ // Paper end
|
||||
+ // copied from below
|
||||
+ this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
||||
+ this.containerMenu = this.inventoryMenu;
|
||||
+ // do not run close logic
|
||||
+ }
|
||||
+ // Paper end - special close for unloaded inventory
|
||||
|
||||
public void doCloseContainer() {
|
||||
this.containerMenu.removed(this);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 5451b1d61ae2ee4fa461c2a334bfe8f794868030..9b131f0a827413e9f5d6d0f7491c5481576cb8b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -506,6 +506,11 @@ public abstract class Player extends LivingEntity {
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
// Paper end
|
||||
+ // Paper start - special close for unloaded inventory
|
||||
+ public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
+ this.containerMenu = this.inventoryMenu;
|
||||
+ }
|
||||
+ // Paper end - special close for unloaded inventory
|
||||
|
||||
public void closeContainer() {
|
||||
this.containerMenu = this.inventoryMenu;
|
|
@ -0,0 +1,37 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 21 Mar 2021 17:32:47 -0700
|
||||
Subject: [PATCH] Correctly handle recursion for chunkholder updates
|
||||
|
||||
If a chunk ticket level is brought up while unloading it would
|
||||
cause a recursive call which would handle the increase but then
|
||||
the caller would think the chunk would be unloaded.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index 96fb6e6ba3d1f9d5bd412f4f2bfb9450efa17948..eda3929ea7dee63c3598f676f719770637940f53 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -467,8 +467,10 @@ public class ChunkHolder {
|
||||
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
|
||||
}
|
||||
|
||||
+ protected long updateCount; // Paper - correctly handle recursion
|
||||
protected void updateFutures(ChunkMap chunkStorage, Executor executor) {
|
||||
io.papermc.paper.util.TickThread.ensureTickThread("Async ticket level update"); // Paper
|
||||
+ long updateCount = ++this.updateCount; // Paper - correctly handle recursion
|
||||
ChunkStatus chunkstatus = ChunkHolder.getStatus(this.oldTicketLevel);
|
||||
ChunkStatus chunkstatus1 = ChunkHolder.getStatus(this.ticketLevel);
|
||||
boolean flag = this.oldTicketLevel <= ChunkMap.MAX_CHUNK_DISTANCE;
|
||||
@@ -510,6 +512,12 @@ public class ChunkHolder {
|
||||
|
||||
// Run callback right away if the future was already done
|
||||
chunkStorage.callbackExecutor.run();
|
||||
+ // Paper start - correctly handle recursion
|
||||
+ if (this.updateCount != updateCount) {
|
||||
+ // something else updated ticket level for us.
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - correctly handle recursion
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
128
patches/server/0724-Fix-GameProfileCache-concurrency.patch
Normal file
128
patches/server/0724-Fix-GameProfileCache-concurrency.patch
Normal file
|
@ -0,0 +1,128 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sat, 11 Jul 2020 05:09:28 -0700
|
||||
Subject: [PATCH] Fix GameProfileCache concurrency
|
||||
|
||||
Separate lookup and state access locks prevent lookups
|
||||
from stalling simple state access/write calls
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
index 5e3bc0590e59770490b1c6c818d99be054214a8a..84bdf4a849b09a90da6c22f4080386e85a53f6b3 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
@@ -62,6 +62,11 @@ public class GameProfileCache {
|
||||
@Nullable
|
||||
private Executor executor;
|
||||
|
||||
+ // Paper start
|
||||
+ protected final java.util.concurrent.locks.ReentrantLock stateLock = new java.util.concurrent.locks.ReentrantLock();
|
||||
+ protected final java.util.concurrent.locks.ReentrantLock lookupLock = new java.util.concurrent.locks.ReentrantLock();
|
||||
+ // Paper end
|
||||
+
|
||||
public GameProfileCache(GameProfileRepository profileRepository, File cacheFile) {
|
||||
this.profileRepository = profileRepository;
|
||||
this.file = cacheFile;
|
||||
@@ -69,6 +74,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
private void safeAdd(GameProfileCache.GameProfileInfo entry) {
|
||||
+ try { this.stateLock.lock(); // Paper - allow better concurrency
|
||||
GameProfile gameprofile = entry.getProfile();
|
||||
|
||||
entry.setLastAccess(this.getNextOperation());
|
||||
@@ -83,6 +89,7 @@ public class GameProfileCache {
|
||||
if (uuid != null) {
|
||||
this.profilesByUUID.put(uuid, entry);
|
||||
}
|
||||
+ } finally { this.stateLock.unlock(); } // Paper - allow better concurrency
|
||||
|
||||
}
|
||||
|
||||
@@ -138,17 +145,20 @@ public class GameProfileCache {
|
||||
|
||||
// Paper start
|
||||
public @Nullable GameProfile getProfileIfCached(String name) {
|
||||
+ try { this.stateLock.lock(); // Paper - allow better concurrency
|
||||
GameProfileCache.GameProfileInfo entry = this.profilesByName.get(name.toLowerCase(Locale.ROOT));
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
entry.setLastAccess(this.getNextOperation());
|
||||
return entry.getProfile();
|
||||
+ } finally { this.stateLock.unlock(); } // Paper - allow better concurrency
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public Optional<GameProfile> get(String name) {
|
||||
String s1 = name.toLowerCase(Locale.ROOT);
|
||||
+ boolean stateLocked = true; try { this.stateLock.lock(); // Paper - allow better concurrency
|
||||
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
|
||||
boolean flag = false;
|
||||
|
||||
@@ -164,8 +174,12 @@ public class GameProfileCache {
|
||||
if (usercache_usercacheentry != null) {
|
||||
usercache_usercacheentry.setLastAccess(this.getNextOperation());
|
||||
optional = Optional.of(usercache_usercacheentry.getProfile());
|
||||
+ stateLocked = false; this.stateLock.unlock(); // Paper - allow better concurrency
|
||||
} else {
|
||||
+ stateLocked = false; this.stateLock.unlock(); // Paper - allow better concurrency
|
||||
+ try { this.lookupLock.lock(); // Paper - allow better concurrency
|
||||
optional = GameProfileCache.lookupGameProfile(this.profileRepository, name); // Spigot - use correct case for offline players
|
||||
+ } finally { this.lookupLock.unlock(); } // Paper - allow better concurrency
|
||||
if (optional.isPresent()) {
|
||||
this.add((GameProfile) optional.get());
|
||||
flag = false;
|
||||
@@ -177,6 +191,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
return optional;
|
||||
+ } finally { if (stateLocked) { this.stateLock.unlock(); } } // Paper - allow better concurrency
|
||||
}
|
||||
|
||||
public void getAsync(String username, Consumer<Optional<GameProfile>> consumer) {
|
||||
@@ -203,6 +218,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
public Optional<GameProfile> get(UUID uuid) {
|
||||
+ try { this.stateLock.lock(); // Paper - allow better concurrency
|
||||
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByUUID.get(uuid);
|
||||
|
||||
if (usercache_usercacheentry == null) {
|
||||
@@ -211,6 +227,7 @@ public class GameProfileCache {
|
||||
usercache_usercacheentry.setLastAccess(this.getNextOperation());
|
||||
return Optional.of(usercache_usercacheentry.getProfile());
|
||||
}
|
||||
+ } finally { this.stateLock.unlock(); } // Paper - allow better concurrency
|
||||
}
|
||||
|
||||
public void setExecutor(Executor executor) {
|
||||
@@ -291,7 +308,7 @@ public class GameProfileCache {
|
||||
JsonArray jsonarray = new JsonArray();
|
||||
DateFormat dateformat = GameProfileCache.createDateFormat();
|
||||
|
||||
- this.getTopMRUProfiles(org.spigotmc.SpigotConfig.userCacheCap).forEach((usercache_usercacheentry) -> { // Spigot
|
||||
+ this.listTopMRUProfiles(org.spigotmc.SpigotConfig.userCacheCap).forEach((usercache_usercacheentry) -> { // Spigot // Paper - allow better concurrency
|
||||
jsonarray.add(GameProfileCache.writeGameProfile(usercache_usercacheentry, dateformat));
|
||||
});
|
||||
String s = this.gson.toJson(jsonarray);
|
||||
@@ -332,8 +349,19 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
private Stream<GameProfileCache.GameProfileInfo> getTopMRUProfiles(int limit) {
|
||||
- return ImmutableList.copyOf(this.profilesByUUID.values()).stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit((long) limit);
|
||||
+ // Paper start - allow better concurrency
|
||||
+ return this.listTopMRUProfiles(limit).stream();
|
||||
+ }
|
||||
+
|
||||
+ private List<GameProfileCache.GameProfileInfo> listTopMRUProfiles(int limit) {
|
||||
+ try {
|
||||
+ this.stateLock.lock();
|
||||
+ return this.profilesByUUID.values().stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit(limit).toList();
|
||||
+ } finally {
|
||||
+ this.stateLock.unlock();
|
||||
+ }
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
private static JsonElement writeGameProfile(GameProfileCache.GameProfileInfo entry, DateFormat dateFormat) {
|
||||
JsonObject jsonobject = new JsonObject();
|
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Mon, 1 Feb 2021 15:35:14 -0800
|
||||
Subject: [PATCH] Fix chunks refusing to unload at low TPS
|
||||
|
||||
The full chunk future is appended to the chunk save future, but
|
||||
when moving to unloaded ticket level it is not being completed with
|
||||
the empty chunk access, so the chunk save must wait for the full
|
||||
chunk future to complete. We can simply schedule to the immediate
|
||||
executor to get this effect, rather than the main mailbox.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 2418f1c0dc050d224bb866e62f414a55900d9652..f29d77572a3cd977fc492ada8ffc8b77467fabc5 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1328,9 +1328,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
return chunk;
|
||||
});
|
||||
- }, (runnable) -> {
|
||||
- this.mainThreadMailbox.tell(ChunkTaskPriorityQueueSorter.message(holder, runnable));
|
||||
- });
|
||||
+ }, this.mainThreadExecutor); // Paper - queue to execute immediately so this doesn't delay chunk unloading
|
||||
}
|
||||
|
||||
public int getTickingGenerated() {
|
|
@ -0,0 +1,62 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sat, 19 Sep 2020 15:29:16 -0700
|
||||
Subject: [PATCH] Do not allow ticket level changes while unloading
|
||||
playerchunks
|
||||
|
||||
Sync loading the chunk at this stage would cause it to load
|
||||
older data, as well as screwing our region state.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index f29d77572a3cd977fc492ada8ffc8b77467fabc5..ae0d7295c88005749f13dd230136f4a39d0a578e 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -314,6 +314,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
@@ -725,6 +726,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
@Nullable
|
||||
ChunkHolder updateChunkScheduling(long pos, int level, @Nullable ChunkHolder holder, int k) {
|
||||
+ if (this.unloadingPlayerChunk) { net.minecraft.server.MinecraftServer.LOGGER.error("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
|
||||
if (k > ChunkMap.MAX_CHUNK_DISTANCE && level > ChunkMap.MAX_CHUNK_DISTANCE) {
|
||||
return holder;
|
||||
} else {
|
||||
@@ -928,6 +930,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
if (completablefuture1 != completablefuture) {
|
||||
this.scheduleUnload(pos, holder);
|
||||
} else {
|
||||
+ // Paper start - do not allow ticket level changes while unloading chunks
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("playerchunk unload");
|
||||
+ boolean unloadingBefore = this.unloadingPlayerChunk;
|
||||
+ this.unloadingPlayerChunk = true;
|
||||
+ try {
|
||||
+ // Paper end - do not allow ticket level changes while unloading chunks
|
||||
// Paper start
|
||||
boolean removed;
|
||||
if ((removed = this.pendingUnloads.remove(pos, holder)) && ichunkaccess != null) {
|
||||
@@ -965,6 +973,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
this.regionManagers.get(index).removeChunk(holder.pos.x, holder.pos.z);
|
||||
}
|
||||
} // Paper end
|
||||
+ } finally { this.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes while unloading chunks
|
||||
|
||||
}
|
||||
};
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 30347bba40c77c95933997800b9149fcd2326bb1..591c9577a66f5663f7728b70f44e33ca029af085 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -809,6 +809,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
public boolean runDistanceManagerUpdates() {
|
||||
if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority
|
||||
+ if (this.chunkMap.unloadingPlayerChunk) { LOGGER.error("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
|
||||
boolean flag = this.distanceManager.runAllUpdates(this.chunkMap);
|
||||
boolean flag1 = this.chunkMap.promoteChunkMap();
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 20 Jun 2021 00:08:13 -0700
|
||||
Subject: [PATCH] Do not allow ticket level changes when updating chunk ticking
|
||||
state
|
||||
|
||||
This WILL cause state corruption if it happens. So, don't
|
||||
allow it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index eda3929ea7dee63c3598f676f719770637940f53..b75b3c4d274252a3a5c53059b9702728eeada389 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -447,7 +447,13 @@ public class ChunkHolder {
|
||||
CompletableFuture<Void> completablefuture1 = new CompletableFuture();
|
||||
|
||||
completablefuture1.thenRunAsync(() -> {
|
||||
+ // Paper start - do not allow ticket level changes
|
||||
+ boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk;
|
||||
+ this.chunkMap.unloadingPlayerChunk = true;
|
||||
+ try {
|
||||
+ // Paper end - do not allow ticket level changes
|
||||
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
|
||||
+ } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes
|
||||
}, executor);
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((either) -> {
|
||||
@@ -464,7 +470,12 @@ public class ChunkHolder {
|
||||
|
||||
private void demoteFullChunk(ChunkMap playerchunkmap, ChunkHolder.FullChunkStatus playerchunk_state) {
|
||||
this.pendingFullStateConfirmation.cancel(false);
|
||||
+ // Paper start - do not allow ticket level changes
|
||||
+ boolean unloadingBefore = this.chunkMap.unloadingPlayerChunk;
|
||||
+ this.chunkMap.unloadingPlayerChunk = true;
|
||||
+ try { // Paper end - do not allow ticket level changes
|
||||
playerchunkmap.onFullChunkStatusChange(this.pos, playerchunk_state);
|
||||
+ } finally { this.chunkMap.unloadingPlayerChunk = unloadingBefore; } // Paper - do not allow ticket level changes
|
||||
}
|
||||
|
||||
protected long updateCount; // Paper - correctly handle recursion
|
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Wed, 25 Aug 2021 20:17:12 -0700
|
||||
Subject: [PATCH] Log when the async catcher is tripped
|
||||
|
||||
The chunk system can swallow the exception given it's all
|
||||
built with completablefuture, so ensure it is at least printed.
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index 7585a30e8f063ac2656b5de519b1e9edaceffbc7..0c41413ad32f8f6a094462fcd637dd3229abda45 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -12,6 +12,7 @@ public class AsyncCatcher
|
||||
{
|
||||
if ( (AsyncCatcher.enabled || io.papermc.paper.util.TickThread.STRICT_THREAD_CHECKS) && Thread.currentThread() != MinecraftServer.getServer().serverThread ) // Paper
|
||||
{
|
||||
+ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable()); // Paper
|
||||
throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,349 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Mon, 16 Aug 2021 01:31:54 -0500
|
||||
Subject: [PATCH] Add '/paper mobcaps' and '/paper playermobcaps'
|
||||
|
||||
Add commands to get the mobcaps for a world, as well as the mobcaps for
|
||||
each player when per-player mob spawning is enabled.
|
||||
|
||||
Also has a hover text on each mob category listing what entity types are
|
||||
in said category
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
index d2536f4ffae721f4df714b5345fa3329c3b8e3f5..60b0ce4557390ee7030efe4c90933402c57bab59 100644
|
||||
--- a/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -5,6 +5,7 @@ import io.papermc.paper.command.subcommands.DumpItemCommand;
|
||||
import io.papermc.paper.command.subcommands.EntityCommand;
|
||||
import io.papermc.paper.command.subcommands.FixLightCommand;
|
||||
import io.papermc.paper.command.subcommands.HeapDumpCommand;
|
||||
+import io.papermc.paper.command.subcommands.MobcapsCommand;
|
||||
import io.papermc.paper.command.subcommands.ReloadCommand;
|
||||
import io.papermc.paper.command.subcommands.SyncLoadInfoCommand;
|
||||
import io.papermc.paper.command.subcommands.VersionCommand;
|
||||
@@ -48,6 +49,7 @@ public final class PaperCommand extends Command {
|
||||
commands.put(Set.of("fixlight"), new FixLightCommand());
|
||||
commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand());
|
||||
commands.put(Set.of("dumpitem"), new DumpItemCommand());
|
||||
+ commands.put(Set.of("mobcaps", "playermobcaps"), new MobcapsCommand());
|
||||
|
||||
return commands.entrySet().stream()
|
||||
.flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2e02d94e2903c48f6d08e743c1cf8bad9f9662df
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java
|
||||
@@ -0,0 +1,229 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import com.google.common.collect.ImmutableMap;
|
||||
+import io.papermc.paper.command.CommandUtil;
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.ToIntFunction;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.ComponentLike;
|
||||
+import net.kyori.adventure.text.JoinConfiguration;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.world.entity.MobCategory;
|
||||
+import net.minecraft.world.level.NaturalSpawner;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class MobcapsCommand implements PaperSubcommand {
|
||||
+ static final Map<MobCategory, TextColor> MOB_CATEGORY_COLORS = ImmutableMap.<MobCategory, TextColor>builder()
|
||||
+ .put(MobCategory.MONSTER, NamedTextColor.RED)
|
||||
+ .put(MobCategory.CREATURE, NamedTextColor.GREEN)
|
||||
+ .put(MobCategory.AMBIENT, NamedTextColor.GRAY)
|
||||
+ .put(MobCategory.AXOLOTLS, TextColor.color(0x7324FF))
|
||||
+ .put(MobCategory.UNDERGROUND_WATER_CREATURE, TextColor.color(0x3541E6))
|
||||
+ .put(MobCategory.WATER_CREATURE, TextColor.color(0x006EFF))
|
||||
+ .put(MobCategory.WATER_AMBIENT, TextColor.color(0x00B3FF))
|
||||
+ .put(MobCategory.MISC, TextColor.color(0x636363))
|
||||
+ .build();
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ switch (subCommand) {
|
||||
+ case "mobcaps" -> this.printMobcaps(sender, args);
|
||||
+ case "playermobcaps" -> this.printPlayerMobcaps(sender, args);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ return switch (subCommand) {
|
||||
+ case "mobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestMobcaps(args));
|
||||
+ case "playermobcaps" -> CommandUtil.getListMatchingLast(sender, args, this.suggestPlayerMobcaps(sender, args));
|
||||
+ default -> throw new IllegalArgumentException();
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ private List<String> suggestMobcaps(final String[] args) {
|
||||
+ if (args.length == 1) {
|
||||
+ final List<String> worlds = new ArrayList<>(Bukkit.getWorlds().stream().map(World::getName).toList());
|
||||
+ worlds.add("*");
|
||||
+ return worlds;
|
||||
+ }
|
||||
+
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ private List<String> suggestPlayerMobcaps(final CommandSender sender, final String[] args) {
|
||||
+ if (args.length == 1) {
|
||||
+ final List<String> list = new ArrayList<>();
|
||||
+ for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
+ if (!(sender instanceof Player senderPlayer) || senderPlayer.canSee(player)) {
|
||||
+ list.add(player.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ return list;
|
||||
+ }
|
||||
+
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ private void printMobcaps(final CommandSender sender, final String[] args) {
|
||||
+ final List<World> worlds;
|
||||
+ if (args.length == 0) {
|
||||
+ if (sender instanceof Player player) {
|
||||
+ worlds = List.of(player.getWorld());
|
||||
+ } else {
|
||||
+ sender.sendMessage(Component.text("Must specify a world! ex: '/paper mobcaps world'", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (args.length == 1) {
|
||||
+ final String input = args[0];
|
||||
+ if (input.equals("*")) {
|
||||
+ worlds = Bukkit.getWorlds();
|
||||
+ } else {
|
||||
+ final @Nullable World world = Bukkit.getWorld(input);
|
||||
+ if (world == null) {
|
||||
+ sender.sendMessage(Component.text("'" + input + "' is not a valid world!", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ } else {
|
||||
+ worlds = List.of(world);
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ sender.sendMessage(Component.text("Too many arguments!", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (final World world : worlds) {
|
||||
+ final ServerLevel level = ((CraftWorld) world).getHandle();
|
||||
+ final NaturalSpawner.@Nullable SpawnState state = level.getChunkSource().getLastSpawnState();
|
||||
+
|
||||
+ final int chunks;
|
||||
+ if (state == null) {
|
||||
+ chunks = 0;
|
||||
+ } else {
|
||||
+ chunks = state.getSpawnableChunkCount();
|
||||
+ }
|
||||
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
|
||||
+ Component.text("Mobcaps for world: "),
|
||||
+ Component.text(world.getName(), NamedTextColor.AQUA),
|
||||
+ Component.text(" (" + chunks + " spawnable chunks)")
|
||||
+ ));
|
||||
+
|
||||
+ sender.sendMessage(createMobcapsComponent(
|
||||
+ category -> {
|
||||
+ if (state == null) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ return state.getMobCategoryCounts().getOrDefault(category, 0);
|
||||
+ }
|
||||
+ },
|
||||
+ category -> NaturalSpawner.globalLimitForCategory(level, category, chunks)
|
||||
+ ));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void printPlayerMobcaps(final CommandSender sender, final String[] args) {
|
||||
+ final @Nullable Player player;
|
||||
+ if (args.length == 0) {
|
||||
+ if (sender instanceof Player pl) {
|
||||
+ player = pl;
|
||||
+ } else {
|
||||
+ sender.sendMessage(Component.text("Must specify a player! ex: '/paper playermobcount playerName'", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (args.length == 1) {
|
||||
+ final String input = args[0];
|
||||
+ player = Bukkit.getPlayerExact(input);
|
||||
+ if (player == null) {
|
||||
+ sender.sendMessage(Component.text("Could not find player named '" + input + "'", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ sender.sendMessage(Component.text("Too many arguments!", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
+ final ServerLevel level = serverPlayer.getLevel();
|
||||
+
|
||||
+ if (!level.paperConfig().entities.spawning.perPlayerMobSpawns) {
|
||||
+ sender.sendMessage(Component.text("Use '/paper mobcaps' for worlds where per-player mob spawning is disabled.", NamedTextColor.RED));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ sender.sendMessage(Component.join(JoinConfiguration.noSeparators(), Component.text("Mobcaps for player: "), Component.text(player.getName(), NamedTextColor.GREEN)));
|
||||
+ sender.sendMessage(createMobcapsComponent(
|
||||
+ category -> level.chunkSource.chunkMap.getMobCountNear(serverPlayer, category),
|
||||
+ category -> level.getWorld().getSpawnLimitUnsafe(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category))
|
||||
+ ));
|
||||
+ }
|
||||
+
|
||||
+ private static Component createMobcapsComponent(final ToIntFunction<MobCategory> countGetter, final ToIntFunction<MobCategory> limitGetter) {
|
||||
+ return MOB_CATEGORY_COLORS.entrySet().stream()
|
||||
+ .map(entry -> {
|
||||
+ final MobCategory category = entry.getKey();
|
||||
+ final TextColor color = entry.getValue();
|
||||
+
|
||||
+ final Component categoryHover = Component.join(JoinConfiguration.noSeparators(),
|
||||
+ Component.text("Entity types in category ", TextColor.color(0xE0E0E0)),
|
||||
+ Component.text(category.getName(), color),
|
||||
+ Component.text(':', NamedTextColor.GRAY),
|
||||
+ Component.newline(),
|
||||
+ Component.newline(),
|
||||
+ Registry.ENTITY_TYPE.entrySet().stream()
|
||||
+ .filter(it -> it.getValue().getCategory() == category)
|
||||
+ .map(it -> Component.translatable(it.getValue().getDescriptionId()))
|
||||
+ .collect(Component.toComponent(Component.text(", ", NamedTextColor.GRAY)))
|
||||
+ );
|
||||
+
|
||||
+ final Component categoryComponent = Component.text()
|
||||
+ .content(" " + category.getName())
|
||||
+ .color(color)
|
||||
+ .hoverEvent(categoryHover)
|
||||
+ .build();
|
||||
+
|
||||
+ final TextComponent.Builder builder = Component.text()
|
||||
+ .append(
|
||||
+ categoryComponent,
|
||||
+ Component.text(": ", NamedTextColor.GRAY)
|
||||
+ );
|
||||
+ final int limit = limitGetter.applyAsInt(category);
|
||||
+ if (limit != -1) {
|
||||
+ builder.append(
|
||||
+ Component.text(countGetter.applyAsInt(category)),
|
||||
+ Component.text("/", NamedTextColor.GRAY),
|
||||
+ Component.text(limit)
|
||||
+ );
|
||||
+ } else {
|
||||
+ builder.append(Component.text()
|
||||
+ .append(
|
||||
+ Component.text('n'),
|
||||
+ Component.text("/", NamedTextColor.GRAY),
|
||||
+ Component.text('a')
|
||||
+ )
|
||||
+ .hoverEvent(Component.text("This category does not naturally spawn.")));
|
||||
+ }
|
||||
+ return builder;
|
||||
+ })
|
||||
+ .map(ComponentLike::asComponent)
|
||||
+ .collect(Component.toComponent(Component.newline()));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index fa23e9c476d4edc6176d8b8a6cb13c52d2f66a87..4150e8cd7197eac53042d56f0a53a4951f8824ce 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -191,6 +191,16 @@ public final class NaturalSpawner {
|
||||
world.getProfiler().pop();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) {
|
||||
+ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category));
|
||||
+ if (categoryLimit < 1) {
|
||||
+ return categoryLimit;
|
||||
+ }
|
||||
+ return categoryLimit * spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) {
|
||||
// Paper start - add parameters and int ret type
|
||||
spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 2f91be86f31c868dee3699ce5426a3ce5c8296b0..669dade4853ae52ba011ede9bc8944ea11e5fa54 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2154,6 +2154,11 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public int getSpawnLimit(SpawnCategory spawnCategory) {
|
||||
+ // Paper start
|
||||
+ return this.getSpawnLimitUnsafe(spawnCategory);
|
||||
+ }
|
||||
+ public int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
|
||||
+ // Paper end
|
||||
return this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 9d3f7f196c4331662c4c78cac0b047bcd2ff5e77..21bf39ef5b20ecc989881b07c4e6b90c68540afd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1712,9 +1712,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
Validate.notNull(spawnCategory, "SpawnCategory cannot be null");
|
||||
Validate.isTrue(CraftSpawnCategory.isValidForLimits(spawnCategory), "SpawnCategory." + spawnCategory + " are not supported.");
|
||||
|
||||
+ // Paper start
|
||||
+ return this.getSpawnLimitUnsafe(spawnCategory);
|
||||
+ }
|
||||
+ public final int getSpawnLimitUnsafe(final SpawnCategory spawnCategory) {
|
||||
int limit = this.spawnCategoryLimit.getOrDefault(spawnCategory, -1);
|
||||
if (limit < 0) {
|
||||
- limit = this.server.getSpawnLimit(spawnCategory);
|
||||
+ limit = this.server.getSpawnLimitUnsafe(spawnCategory);
|
||||
+ // Paper end
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
diff --git a/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java b/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f1dd3bca7fa0df8b6ed177bb435877229af1c0c5
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/command/subcommands/MobcapsCommandTest.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+import net.minecraft.world.entity.MobCategory;
|
||||
+import org.junit.Assert;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+public class MobcapsCommandTest {
|
||||
+ @Test
|
||||
+ public void testMobCategoryColors() {
|
||||
+ final Set<String> missing = new HashSet<>();
|
||||
+ for (final MobCategory value : MobCategory.values()) {
|
||||
+ if (!MobcapsCommand.MOB_CATEGORY_COLORS.containsKey(value)) {
|
||||
+ missing.add(value.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ Assert.assertTrue("MobcapsCommand.MOB_CATEGORY_COLORS map missing TextColors for [" + String.join(", ", missing + "]"), missing.isEmpty());
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,80 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Thu, 18 Jun 2020 18:23:20 -0700
|
||||
Subject: [PATCH] Prevent unload() calls removing tickets for sync loads
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/DistanceManager.java b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
index b2df5e18ce5260a9781052db7afb0b9786fb887c..537d34a0325a985948c744929b90144a66a35ee3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/DistanceManager.java
|
||||
@@ -545,7 +545,7 @@ public abstract class DistanceManager {
|
||||
}
|
||||
|
||||
public void removeTicketsOnClosing() {
|
||||
- ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD); // Paper - add additional tickets to preserve
|
||||
+ ImmutableSet<TicketType<?>> immutableset = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.LIGHT, TicketType.FUTURE_AWAIT, TicketType.ASYNC_LOAD, TicketType.REQUIRED_LOAD); // Paper - add additional tickets to preserve
|
||||
ObjectIterator objectiterator = this.tickets.long2ObjectEntrySet().fastIterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 591c9577a66f5663f7728b70f44e33ca029af085..ce88da358c8a89564a911e6c818e906e845006ff 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -714,6 +714,8 @@ public class ServerChunkCache extends ChunkSource {
|
||||
return completablefuture;
|
||||
}
|
||||
|
||||
+ private long syncLoadCounter; // Paper - prevent plugin unloads from removing our ticket
|
||||
+
|
||||
private CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getChunkFutureMainThread(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) {
|
||||
// Paper start - add isUrgent - old sig left in place for dirty nms plugins
|
||||
return getChunkFutureMainThread(chunkX, chunkZ, leastStatus, create, false);
|
||||
@@ -732,9 +734,12 @@ public class ServerChunkCache extends ChunkSource {
|
||||
ChunkHolder.FullChunkStatus currentChunkState = ChunkHolder.getFullChunkStatus(playerchunk.getTicketLevel());
|
||||
currentlyUnloading = (oldChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER) && !currentChunkState.isOrAfter(ChunkHolder.FullChunkStatus.BORDER));
|
||||
}
|
||||
+ final Long identifier; // Paper - prevent plugin unloads from removing our ticket
|
||||
if (create && !currentlyUnloading) {
|
||||
// CraftBukkit end
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
+ identifier = Long.valueOf(this.syncLoadCounter++); // Paper - prevent plugin unloads from removing our ticket
|
||||
+ this.distanceManager.addTicket(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); // Paper - prevent plugin unloads from removing our ticket
|
||||
if (isUrgent) this.distanceManager.markUrgent(chunkcoordintpair); // Paper - Chunk priority
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
@@ -745,13 +750,21 @@ public class ServerChunkCache extends ChunkSource {
|
||||
playerchunk = this.getVisibleChunkIfPresent(k);
|
||||
gameprofilerfiller.pop();
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
+ this.distanceManager.removeTicket(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier); // Paper
|
||||
throw (IllegalStateException) Util.pauseInIde(new IllegalStateException("No chunk holder after ticket has been added"));
|
||||
}
|
||||
}
|
||||
- }
|
||||
|
||||
+ } else { identifier = null; } // Paper - prevent plugin unloads from removing our ticket
|
||||
// Paper start - Chunk priority
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> future = this.chunkAbsent(playerchunk, l) ? ChunkHolder.UNLOADED_CHUNK_FUTURE : playerchunk.getOrScheduleFuture(leastStatus, this.chunkMap);
|
||||
+ // Paper start - prevent plugin unloads from removing our ticket
|
||||
+ if (create && !currentlyUnloading) {
|
||||
+ future.thenAcceptAsync((either) -> {
|
||||
+ ServerChunkCache.this.distanceManager.removeTicket(TicketType.REQUIRED_LOAD, chunkcoordintpair, l, identifier);
|
||||
+ }, ServerChunkCache.this.mainThreadProcessor);
|
||||
+ }
|
||||
+ // Paper end - prevent plugin unloads from removing our ticket
|
||||
if (isUrgent) {
|
||||
future.thenAccept(either -> this.distanceManager.clearUrgent(chunkcoordintpair));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java
|
||||
index 3c1698ba0d3bc412ab957777d9b5211dbc555208..41ddcf6775f99c56cf4b13b284420061e5dd6bdc 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/TicketType.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/TicketType.java
|
||||
@@ -31,6 +31,7 @@ public class TicketType<T> {
|
||||
public static final TicketType<Unit> PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit
|
||||
public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
|
||||
public static final TicketType<Long> DELAY_UNLOAD = create("delay_unload", Long::compareTo, 300); // Paper
|
||||
+ public static final TicketType<Long> REQUIRED_LOAD = create("required_load", Long::compareTo); // Paper - make sure getChunkAt does not fail
|
||||
|
||||
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
|
||||
return new TicketType<>(name, argumentComparator, 0L);
|
|
@ -0,0 +1,22 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <jahnke.nassim@gmail.com>
|
||||
Date: Thu, 26 Aug 2021 12:09:47 +0200
|
||||
Subject: [PATCH] Sanitize ResourceLocation error logging
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/resources/ResourceLocation.java b/src/main/java/net/minecraft/resources/ResourceLocation.java
|
||||
index 0e04275f62c5c2d8afede431f78f38f06e8009e6..7017dd42f832d928f1008a05f01701667d951644 100644
|
||||
--- a/src/main/java/net/minecraft/resources/ResourceLocation.java
|
||||
+++ b/src/main/java/net/minecraft/resources/ResourceLocation.java
|
||||
@@ -32,9 +32,9 @@ public class ResourceLocation implements Comparable<ResourceLocation> {
|
||||
this.namespace = StringUtils.isEmpty(id[0]) ? "minecraft" : id[0];
|
||||
this.path = id[1];
|
||||
if (!isValidNamespace(this.namespace)) {
|
||||
- throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + this.namespace + ":" + this.path);
|
||||
+ throw new ResourceLocationException("Non [a-z0-9_.-] character in namespace of location: " + org.apache.commons.lang3.StringUtils.normalizeSpace(this.namespace) + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(this.path)); // Paper
|
||||
} else if (!isValidPath(this.path)) {
|
||||
- throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + this.namespace + ":" + this.path);
|
||||
+ throw new ResourceLocationException("Non [a-z0-9/._-] character in path of location: " + this.namespace + ":" + org.apache.commons.lang3.StringUtils.normalizeSpace(this.path)); // Paper
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sat, 4 Apr 2020 15:27:44 -0700
|
||||
Subject: [PATCH] Allow controlled flushing for network manager
|
||||
|
||||
Only make one flush call when emptying the packet queue too
|
||||
|
||||
This patch will be used to optimise out flush calls in later
|
||||
patches.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index ca6b12b61874913f6d4abac97a3df67d0053cd8f..2195024a7b2626f4e6844db56071130226cf1364 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -99,6 +99,39 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
public ConnectionProtocol protocol;
|
||||
// Paper end
|
||||
|
||||
+ // Paper start - allow controlled flushing
|
||||
+ volatile boolean canFlush = true;
|
||||
+ private final java.util.concurrent.atomic.AtomicInteger packetWrites = new java.util.concurrent.atomic.AtomicInteger();
|
||||
+ private int flushPacketsStart;
|
||||
+ private final Object flushLock = new Object();
|
||||
+
|
||||
+ public void disableAutomaticFlush() {
|
||||
+ synchronized (this.flushLock) {
|
||||
+ this.flushPacketsStart = this.packetWrites.get(); // must be volatile and before canFlush = false
|
||||
+ this.canFlush = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void enableAutomaticFlush() {
|
||||
+ synchronized (this.flushLock) {
|
||||
+ this.canFlush = true;
|
||||
+ if (this.packetWrites.get() != this.flushPacketsStart) { // must be after canFlush = true
|
||||
+ this.flush(); // only make the flush call if we need to
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private final void flush() {
|
||||
+ if (this.channel.eventLoop().inEventLoop()) {
|
||||
+ this.channel.flush();
|
||||
+ } else {
|
||||
+ this.channel.eventLoop().execute(() -> {
|
||||
+ this.channel.flush();
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - allow controlled flushing
|
||||
+
|
||||
public Connection(PacketFlow side) {
|
||||
this.receiving = side;
|
||||
}
|
||||
@@ -264,7 +297,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
|
||||
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
|
||||
))) {
|
||||
- this.sendPacket(packet, packetsendlistener);
|
||||
+ this.sendPacket(packet, packetsendlistener, null); // Paper
|
||||
return;
|
||||
}
|
||||
// write the packets to the queue, then flush - antixray hooks there already
|
||||
@@ -288,6 +321,14 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
|
||||
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||
+ // Paper start - add flush parameter
|
||||
+ this.sendPacket(packet, packetsendlistener, Boolean.TRUE);
|
||||
+ }
|
||||
+ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, Boolean flushConditional) {
|
||||
+ this.packetWrites.getAndIncrement(); // must be befeore using canFlush
|
||||
+ boolean effectiveFlush = flushConditional == null ? this.canFlush : flushConditional.booleanValue();
|
||||
+ final boolean flush = effectiveFlush || packet instanceof net.minecraft.network.protocol.game.ClientboundKeepAlivePacket || packet instanceof ClientboundDisconnectPacket; // no delay for certain packets
|
||||
+ // Paper end - add flush parameter
|
||||
ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet);
|
||||
ConnectionProtocol enumprotocol1 = this.getCurrentProtocol();
|
||||
|
||||
@@ -298,16 +339,21 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
|
||||
if (this.channel.eventLoop().inEventLoop()) {
|
||||
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
|
||||
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
|
||||
} else {
|
||||
this.channel.eventLoop().execute(() -> {
|
||||
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
|
||||
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState) {
|
||||
+ // Paper start - add flush parameter
|
||||
+ this.doSendPacket(packet, packetsendlistener, packetState, currentState, true);
|
||||
+ }
|
||||
+ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState, boolean flush) {
|
||||
+ // Paper end - add flush parameter
|
||||
if (packetState != currentState) {
|
||||
this.setProtocol(packetState);
|
||||
}
|
||||
@@ -321,7 +367,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
|
||||
try {
|
||||
// Paper end
|
||||
- ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
|
||||
+ ChannelFuture channelfuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Paper - add flush parameter
|
||||
|
||||
if (packetsendlistener != null) {
|
||||
channelfuture.addListener((future) -> {
|
||||
@@ -376,6 +422,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
private boolean processQueue() {
|
||||
if (this.queue.isEmpty()) return true;
|
||||
+ // Paper start - make only one flush call per sendPacketQueue() call
|
||||
+ final boolean needsFlush = this.canFlush;
|
||||
+ boolean hasWrotePacket = false;
|
||||
+ // Paper end - make only one flush call per sendPacketQueue() call
|
||||
// If we are on main, we are safe here in that nothing else should be processing queue off main anymore
|
||||
// But if we are not on main due to login/status, the parent is synchronized on packetQueue
|
||||
java.util.Iterator<PacketHolder> iterator = this.queue.iterator();
|
||||
@@ -383,16 +433,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
PacketHolder queued = iterator.next(); // poll -> peek
|
||||
|
||||
// Fix NPE (Spigot bug caused by handleDisconnection())
|
||||
- if (queued == null) {
|
||||
+ if (false && queued == null) { // Paper - diff on change, this logic is redundant: iterator guarantees ret of an element - on change, hook the flush logic here
|
||||
return true;
|
||||
}
|
||||
|
||||
Packet<?> packet = queued.packet;
|
||||
if (!packet.isReady()) {
|
||||
+ // Paper start - make only one flush call per sendPacketQueue() call
|
||||
+ if (hasWrotePacket && (needsFlush || this.canFlush)) {
|
||||
+ this.flush();
|
||||
+ }
|
||||
+ // Paper end - make only one flush call per sendPacketQueue() call
|
||||
return false;
|
||||
} else {
|
||||
iterator.remove();
|
||||
- this.sendPacket(packet, queued.listener);
|
||||
+ this.writePacket(packet, queued.listener, (!iterator.hasNext() && (needsFlush || this.canFlush)) ? Boolean.TRUE : Boolean.FALSE); // Paper - make only one flush call per sendPacketQueue() call
|
||||
+ hasWrotePacket = true; // Paper - make only one flush call per sendPacketQueue() call
|
||||
}
|
||||
}
|
||||
return true;
|
1059
patches/server/0733-Optimise-general-POI-access.patch
Normal file
1059
patches/server/0733-Optimise-general-POI-access.patch
Normal file
File diff suppressed because it is too large
Load diff
44
patches/server/0734-Add-more-async-catchers.patch
Normal file
44
patches/server/0734-Add-more-async-catchers.patch
Normal file
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 15 Jul 2021 01:41:53 -0700
|
||||
Subject: [PATCH] Add more async catchers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java
|
||||
index 2830d32bba3dc85847e3a5d9b4d98f822e34b606..a176a886235494fdc722030a93658d361bf50f03 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java
|
||||
@@ -29,11 +29,13 @@ public class EntityTickList {
|
||||
}
|
||||
|
||||
public void add(Entity entity) {
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Asynchronous entity ticklist addition"); // Paper
|
||||
this.ensureActiveIsNotIterated();
|
||||
this.active.put(entity.getId(), entity);
|
||||
}
|
||||
|
||||
public void remove(Entity entity) {
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Asynchronous entity ticklist removal"); // Paper
|
||||
this.ensureActiveIsNotIterated();
|
||||
this.active.remove(entity.getId());
|
||||
}
|
||||
@@ -43,6 +45,7 @@ public class EntityTickList {
|
||||
}
|
||||
|
||||
public void forEach(Consumer<Entity> action) {
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Asynchronous entity ticklist iteration"); // Paper
|
||||
if (this.iterated != null) {
|
||||
throw new UnsupportedOperationException("Only one concurrent iteration supported");
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
index e53e912351a0753c429512f018281a656837bde2..fcf85047d89d5c55df78ab2a6d81cb6da254ecd7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
@@ -166,6 +166,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
||||
}
|
||||
|
||||
public void updateChunkStatus(ChunkPos chunkPos, ChunkHolder.FullChunkStatus levelType) {
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Asynchronous chunk ticking status update"); // Paper
|
||||
Visibility visibility = Visibility.fromFullChunkStatus(levelType);
|
||||
|
||||
this.updateChunkStatus(chunkPos, visibility);
|
1300
patches/server/0735-Rewrite-entity-bounding-box-lookup-calls.patch
Normal file
1300
patches/server/0735-Rewrite-entity-bounding-box-lookup-calls.patch
Normal file
File diff suppressed because it is too large
Load diff
203
patches/server/0736-Optimise-chunk-tick-iteration.patch
Normal file
203
patches/server/0736-Optimise-chunk-tick-iteration.patch
Normal file
|
@ -0,0 +1,203 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Thu, 7 May 2020 05:48:54 -0700
|
||||
Subject: [PATCH] Optimise chunk tick iteration
|
||||
|
||||
Use a dedicated list of entity ticking chunks to reduce the cost
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index b75b3c4d274252a3a5c53059b9702728eeada389..8bea90cb57f38f33e8b3162e24e353993a98ebbf 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -86,11 +86,21 @@ public class ChunkHolder {
|
||||
long key = net.minecraft.server.MCUtil.getCoordinateKey(this.pos);
|
||||
this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key);
|
||||
this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
|
||||
+ // Paper start - optimise chunk tick iteration
|
||||
+ if (this.needsBroadcastChanges()) {
|
||||
+ this.chunkMap.needsChangeBroadcasting.add(this);
|
||||
+ }
|
||||
+ // Paper end - optimise chunk tick iteration
|
||||
}
|
||||
|
||||
void onChunkRemove() {
|
||||
this.playersInMobSpawnRange = null;
|
||||
this.playersInChunkTickRange = null;
|
||||
+ // Paper start - optimise chunk tick iteration
|
||||
+ if (this.needsBroadcastChanges()) {
|
||||
+ this.chunkMap.needsChangeBroadcasting.remove(this);
|
||||
+ }
|
||||
+ // Paper end - optimise chunk tick iteration
|
||||
}
|
||||
// Paper end - optimise anyPlayerCloseEnoughForSpawning
|
||||
long lastAutoSaveTime; // Paper - incremental autosave
|
||||
@@ -253,7 +263,7 @@ public class ChunkHolder {
|
||||
|
||||
if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
- this.hasChangedSections = true;
|
||||
+ this.hasChangedSections = true; this.addToBroadcastMap(); // Paper - optimise chunk tick iteration
|
||||
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
|
||||
}
|
||||
|
||||
@@ -276,6 +286,7 @@ public class ChunkHolder {
|
||||
int k = this.lightEngine.getMaxLightSection();
|
||||
|
||||
if (y >= j && y <= k) {
|
||||
+ this.addToBroadcastMap(); // Paper - optimise chunk tick iteration
|
||||
int l = y - j;
|
||||
|
||||
if (lightType == LightLayer.SKY) {
|
||||
@@ -290,8 +301,19 @@ public class ChunkHolder {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - optimise chunk tick iteration
|
||||
+ public final boolean needsBroadcastChanges() {
|
||||
+ return this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ private void addToBroadcastMap() {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("ChunkHolder update");
|
||||
+ this.chunkMap.needsChangeBroadcasting.add(this);
|
||||
+ }
|
||||
+ // Paper end - optimise chunk tick iteration
|
||||
+
|
||||
public void broadcastChanges(LevelChunk chunk) {
|
||||
- if (this.hasChangedSections || !this.skyChangedLightSectionFilter.isEmpty() || !this.blockChangedLightSectionFilter.isEmpty()) {
|
||||
+ if (this.needsBroadcastChanges()) { // Paper - moved into above, other logic needs to call
|
||||
Level world = chunk.getLevel();
|
||||
int i = 0;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index ae0d7295c88005749f13dd230136f4a39d0a578e..1bbb15354e457a6056d380f9ef318a4661f460e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -160,6 +160,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
private final Queue<Runnable> unloadQueue;
|
||||
int viewDistance;
|
||||
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper
|
||||
+ public final ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new ReferenceOpenHashSet<>();
|
||||
|
||||
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||||
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index ce88da358c8a89564a911e6c818e906e845006ff..438406936633b9c67d21b26527c3d1654118c744 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -47,6 +47,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
import net.minecraft.world.level.storage.LevelData;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
+import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // Paper
|
||||
|
||||
public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
@@ -987,34 +988,42 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
this.lastSpawnState = spawnercreature_d;
|
||||
gameprofilerfiller.popPush("filteringLoadedChunks");
|
||||
- List<ServerChunkCache.ChunkAndHolder> list = Lists.newArrayListWithCapacity(l);
|
||||
- Iterator iterator = this.chunkMap.getChunks().iterator();
|
||||
+ // Paper - moved down
|
||||
this.level.timings.chunkTicks.startTiming(); // Paper
|
||||
|
||||
- while (iterator.hasNext()) {
|
||||
- ChunkHolder playerchunk = (ChunkHolder) iterator.next();
|
||||
- LevelChunk chunk = playerchunk.getTickingChunk();
|
||||
-
|
||||
- if (chunk != null) {
|
||||
- list.add(new ServerChunkCache.ChunkAndHolder(chunk, playerchunk));
|
||||
- }
|
||||
- }
|
||||
+ // Paper - moved down
|
||||
|
||||
gameprofilerfiller.popPush("spawnAndTick");
|
||||
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
||||
|
||||
- Collections.shuffle(list);
|
||||
+ // Paper - only shuffle if per-player mob spawning is disabled
|
||||
// Paper - moved natural spawn event up
|
||||
- Iterator iterator1 = list.iterator();
|
||||
+ // Paper start - optimise chunk tick iteration
|
||||
+ Iterator<LevelChunk> iterator1;
|
||||
+ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
|
||||
+ iterator1 = this.entityTickingChunks.iterator();
|
||||
+ } else {
|
||||
+ iterator1 = this.entityTickingChunks.unsafeIterator();
|
||||
+ List<LevelChunk> shuffled = Lists.newArrayListWithCapacity(this.entityTickingChunks.size());
|
||||
+ while (iterator1.hasNext()) {
|
||||
+ shuffled.add(iterator1.next());
|
||||
+ }
|
||||
+ Collections.shuffle(shuffled);
|
||||
+ iterator1 = shuffled.iterator();
|
||||
+ }
|
||||
|
||||
+ try {
|
||||
while (iterator1.hasNext()) {
|
||||
- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next();
|
||||
- LevelChunk chunk1 = chunkproviderserver_a.chunk;
|
||||
+ LevelChunk chunk1 = iterator1.next();
|
||||
+ ChunkHolder holder = chunk1.playerChunk;
|
||||
+ if (holder != null) {
|
||||
+ // Paper - move down
|
||||
+ // Paper end - optimise chunk tick iteration
|
||||
ChunkPos chunkcoordintpair = chunk1.getPos();
|
||||
|
||||
- if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkproviderserver_a.holder, chunkcoordintpair, false)) { // Paper - optimise anyPlayerCloseEnoughForSpawning
|
||||
+ if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, false)) { // Paper - optimise anyPlayerCloseEnoughForSpawning
|
||||
chunk1.incrementInhabitedTime(j);
|
||||
- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkproviderserver_a.holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning
|
||||
+ if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(holder, chunkcoordintpair, true)) { // Spigot // Paper - optimise anyPlayerCloseEnoughForSpawning & optimise chunk tick iteration
|
||||
NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||
}
|
||||
|
||||
@@ -1022,7 +1031,16 @@ public class ServerChunkCache extends ChunkSource {
|
||||
this.level.tickChunk(chunk1, k);
|
||||
}
|
||||
}
|
||||
+ // Paper start - optimise chunk tick iteration
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ } finally {
|
||||
+ if (iterator1 instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
|
||||
+ safeIterator.finishedIterating();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - optimise chunk tick iteration
|
||||
this.level.timings.chunkTicks.stopTiming(); // Paper
|
||||
gameprofilerfiller.popPush("customSpawners");
|
||||
if (flag2) {
|
||||
@@ -1030,15 +1048,24 @@ public class ServerChunkCache extends ChunkSource {
|
||||
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
|
||||
} // Paper - timings
|
||||
}
|
||||
-
|
||||
- gameprofilerfiller.popPush("broadcast");
|
||||
- list.forEach((chunkproviderserver_a1) -> {
|
||||
- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
|
||||
- chunkproviderserver_a1.holder.broadcastChanges(chunkproviderserver_a1.chunk);
|
||||
- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
|
||||
- });
|
||||
gameprofilerfiller.pop();
|
||||
+ // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded
|
||||
+ gameprofilerfiller.popPush("broadcast");
|
||||
+ this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
|
||||
+ if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) {
|
||||
+ ReferenceOpenHashSet<ChunkHolder> copy = this.chunkMap.needsChangeBroadcasting.clone();
|
||||
+ this.chunkMap.needsChangeBroadcasting.clear();
|
||||
+ for (ChunkHolder holder : copy) {
|
||||
+ holder.broadcastChanges(holder.getFullChunkNowUnchecked()); // LevelChunks are NEVER unloaded
|
||||
+ if (holder.needsBroadcastChanges()) {
|
||||
+ // I DON'T want to KNOW what DUMB plugins might be doing.
|
||||
+ this.chunkMap.needsChangeBroadcasting.add(holder);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
|
||||
gameprofilerfiller.pop();
|
||||
+ // Paper end - use set of chunks requiring updates, rather than iterating every single one loaded
|
||||
this.chunkMap.tick();
|
||||
}
|
||||
}
|
179
patches/server/0737-Execute-chunk-tasks-mid-tick.patch
Normal file
179
patches/server/0737-Execute-chunk-tasks-mid-tick.patch
Normal file
|
@ -0,0 +1,179 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 6 Apr 2020 04:20:44 -0700
|
||||
Subject: [PATCH] Execute chunk tasks mid-tick
|
||||
|
||||
This will help the server load chunks if tick times are high.
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
index 23e564b05ba438924180c91f9b19a60731eedd1b..5ec241d49ff5e3a161a39006f05823a5de847c5e 100644
|
||||
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -46,6 +46,8 @@ public final class MinecraftTimings {
|
||||
public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
|
||||
public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
|
||||
|
||||
+ public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks");
|
||||
+
|
||||
private static final Map<Class<?>, String> taskNameCache = new MapMaker().weakKeys().makeMap();
|
||||
|
||||
private MinecraftTimings() {}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d605c4355674644e47ea5ea9e979f7806aed1607..421872f7cc1a3cbb4dc596d0e0fa0f9b63602a8a 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1303,6 +1303,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
private boolean pollTaskInternal() {
|
||||
if (super.pollTask()) {
|
||||
+ this.executeMidTickTasks(); // Paper - execute chunk tasks mid tick
|
||||
return true;
|
||||
} else {
|
||||
if (this.haveTime()) {
|
||||
@@ -2665,4 +2666,74 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Paper start - execute chunk tasks mid tick
|
||||
+ static final long CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME = 25L * 1000L; // 25us
|
||||
+ static final long MAX_CHUNK_EXEC_TIME = 1000L; // 1us
|
||||
+
|
||||
+ static final long TASK_EXECUTION_FAILURE_BACKOFF = 5L * 1000L; // 5us
|
||||
+
|
||||
+ private static long lastMidTickExecute;
|
||||
+ private static long lastMidTickExecuteFailure;
|
||||
+
|
||||
+ private boolean tickMidTickTasks() {
|
||||
+ // give all worlds a fair chance at by targetting them all.
|
||||
+ // if we execute too many tasks, that's fine - we have logic to correctly handle overuse of allocated time.
|
||||
+ boolean executed = false;
|
||||
+ for (ServerLevel world : this.getAllLevels()) {
|
||||
+ long currTime = System.nanoTime();
|
||||
+ if (currTime - world.lastMidTickExecuteFailure <= TASK_EXECUTION_FAILURE_BACKOFF) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!world.getChunkSource().pollTask()) {
|
||||
+ // we need to back off if this fails
|
||||
+ world.lastMidTickExecuteFailure = currTime;
|
||||
+ } else {
|
||||
+ executed = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return executed;
|
||||
+ }
|
||||
+
|
||||
+ public final void executeMidTickTasks() {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("mid tick chunk task execution");
|
||||
+ long startTime = System.nanoTime();
|
||||
+ if ((startTime - lastMidTickExecute) <= CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME || (startTime - lastMidTickExecuteFailure) <= TASK_EXECUTION_FAILURE_BACKOFF) {
|
||||
+ // it's shown to be bad to constantly hit the queue (chunk loads slow to a crawl), even if no tasks are executed.
|
||||
+ // so, backoff to prevent this
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ co.aikar.timings.MinecraftTimings.midTickChunkTasks.startTiming();
|
||||
+ try {
|
||||
+ for (;;) {
|
||||
+ boolean moreTasks = this.tickMidTickTasks();
|
||||
+ long currTime = System.nanoTime();
|
||||
+ long diff = currTime - startTime;
|
||||
+
|
||||
+ if (!moreTasks || diff >= MAX_CHUNK_EXEC_TIME) {
|
||||
+ if (!moreTasks) {
|
||||
+ lastMidTickExecuteFailure = currTime;
|
||||
+ }
|
||||
+
|
||||
+ // note: negative values reduce the time
|
||||
+ long overuse = diff - MAX_CHUNK_EXEC_TIME;
|
||||
+ if (overuse >= (10L * 1000L * 1000L)) { // 10ms
|
||||
+ // make sure something like a GC or dumb plugin doesn't screw us over...
|
||||
+ overuse = 10L * 1000L * 1000L; // 10ms
|
||||
+ }
|
||||
+
|
||||
+ double overuseCount = (double)overuse/(double)MAX_CHUNK_EXEC_TIME;
|
||||
+ long extraSleep = (long)Math.round(overuseCount*CHUNK_TASK_QUEUE_BACKOFF_MIN_TIME);
|
||||
+
|
||||
+ lastMidTickExecute = currTime + extraSleep;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ } finally {
|
||||
+ co.aikar.timings.MinecraftTimings.midTickChunkTasks.stopTiming();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - execute chunk tasks mid tick
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 438406936633b9c67d21b26527c3d1654118c744..2de322ffc2eedae9efe39f9b771c447dd76f26fb 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -1012,6 +1012,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
iterator1 = shuffled.iterator();
|
||||
}
|
||||
|
||||
+ int chunksTicked = 0; // Paper
|
||||
try {
|
||||
while (iterator1.hasNext()) {
|
||||
LevelChunk chunk1 = iterator1.next();
|
||||
@@ -1029,6 +1030,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
||||
if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) {
|
||||
this.level.tickChunk(chunk1, k);
|
||||
+ if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper
|
||||
}
|
||||
}
|
||||
// Paper start - optimise chunk tick iteration
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 306e40f7fa6435cfb3c2da7382daf71a51b58e18..53105ca96f5056adbba6a97ac428587e7c3b683a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -211,6 +211,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
private final StructureManager structureManager;
|
||||
private final StructureCheck structureCheck;
|
||||
private final boolean tickTime;
|
||||
+ public long lastMidTickExecuteFailure; // Paper - execute chunk tasks mid tick
|
||||
|
||||
// CraftBukkit start
|
||||
public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
@@ -987,6 +988,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (fluid1.is(fluid)) {
|
||||
fluid1.tick(this, pos);
|
||||
}
|
||||
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
|
||||
|
||||
}
|
||||
|
||||
@@ -996,6 +998,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (iblockdata.is(block)) {
|
||||
iblockdata.tick(this, pos, this.random);
|
||||
}
|
||||
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - exec chunk tasks during world tick
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4f484e71c93a5243d242e116e2f204ead407f598..7c4ec47829bb0818f489544f2b396852d42a35d3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -799,6 +799,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// Spigot end
|
||||
} else if (this.shouldTickBlocksAt(tickingblockentity.getPos())) {
|
||||
tickingblockentity.tick();
|
||||
+ // Paper start - execute chunk tasks during tick
|
||||
+ if ((this.tileTickPosition & 7) == 0) {
|
||||
+ MinecraftServer.getServer().executeMidTickTasks();
|
||||
+ }
|
||||
+ // Paper end - execute chunk tasks during tick
|
||||
}
|
||||
}
|
||||
this.blockEntityTickers.removeAll(toRemove);
|
||||
@@ -813,6 +818,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
|
||||
try {
|
||||
tickConsumer.accept(entity);
|
||||
+ MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick
|
||||
} catch (Throwable throwable) {
|
||||
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
||||
// Paper start - Prevent tile entity and entity crashes
|
238
patches/server/0738-Do-not-copy-visible-chunks.patch
Normal file
238
patches/server/0738-Do-not-copy-visible-chunks.patch
Normal file
|
@ -0,0 +1,238 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 21 Mar 2021 11:22:10 -0700
|
||||
Subject: [PATCH] Do not copy visible chunks
|
||||
|
||||
For servers with a lot of chunk holders, copying for each
|
||||
tickDistanceManager call can take up quite a bit in
|
||||
the function. I saw approximately 1/3rd of the function
|
||||
on the copy.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
|
||||
index 029ad37df71e74d9feb57e4b31b3602e55d49113..4b367982fae4662c326aa247824e9c4185896de1 100644
|
||||
--- a/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/ChunkDebugCommand.java
|
||||
@@ -90,7 +90,7 @@ public final class ChunkDebugCommand implements PaperSubcommand {
|
||||
int ticking = 0;
|
||||
int entityTicking = 0;
|
||||
|
||||
- for (final ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunkMap.values()) {
|
||||
+ for (final ChunkHolder chunk : world.getChunkSource().chunkMap.updatingChunks.getUpdatingMap().values()) { // Paper - change updating chunks map
|
||||
if (chunk.getFullChunkNowUnchecked() == null) {
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
index 613988c9ea892ab15516e1c8b4f376d52415ae34..1eb71004a19866590a3d27fa6e72842934989177 100644
|
||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -625,7 +625,7 @@ public final class MCUtil {
|
||||
|
||||
ServerLevel world = ((org.bukkit.craftbukkit.CraftWorld)bukkitWorld).getHandle();
|
||||
ChunkMap chunkMap = world.getChunkSource().chunkMap;
|
||||
- Long2ObjectLinkedOpenHashMap<ChunkHolder> visibleChunks = chunkMap.visibleChunkMap;
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkHolder> visibleChunks = chunkMap.updatingChunks.getVisibleMap(); // Paper
|
||||
DistanceManager chunkMapDistance = chunkMap.distanceManager;
|
||||
List<ChunkHolder> allChunks = new ArrayList<>(visibleChunks.values());
|
||||
List<ServerPlayer> players = world.players;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 1bbb15354e457a6056d380f9ef318a4661f460e3..b3dc2e71230304ab42b9dd935025f0bd3117bd01 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -123,9 +123,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
private static final int MIN_VIEW_DISTANCE = 3;
|
||||
public static final int MAX_VIEW_DISTANCE = 33;
|
||||
public static final int MAX_CHUNK_DISTANCE = 33 + ChunkStatus.maxDistance();
|
||||
+ // Paper start - Don't copy
|
||||
+ public final com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<ChunkHolder> updatingChunks = new com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object<>();
|
||||
+ // Paper end - Don't copy
|
||||
public static final int FORCED_TICKET_LEVEL = 31;
|
||||
- public final Long2ObjectLinkedOpenHashMap<ChunkHolder> updatingChunkMap = new Long2ObjectLinkedOpenHashMap();
|
||||
- public volatile Long2ObjectLinkedOpenHashMap<ChunkHolder> visibleChunkMap;
|
||||
+ // Paper - Don't copy
|
||||
private final Long2ObjectLinkedOpenHashMap<ChunkHolder> pendingUnloads;
|
||||
public final LongSet entitiesInLevel;
|
||||
public final ServerLevel level;
|
||||
@@ -318,7 +320,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
boolean unloadingPlayerChunk = false; // Paper - do not allow ticket level changes while unloading chunks
|
||||
public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
|
||||
super(session.getDimensionPath(world.dimension()).resolve("region"), dataFixer, dsync);
|
||||
- this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
+ // Paper - don't copy
|
||||
this.pendingUnloads = new Long2ObjectLinkedOpenHashMap();
|
||||
this.entitiesInLevel = new LongOpenHashSet();
|
||||
this.toDrop = new LongOpenHashSet();
|
||||
@@ -559,12 +561,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
@Nullable
|
||||
public ChunkHolder getUpdatingChunkIfPresent(long pos) {
|
||||
- return (ChunkHolder) this.updatingChunkMap.get(pos);
|
||||
+ return this.updatingChunks.getUpdating(pos); // Paper - Don't copy
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ChunkHolder getVisibleChunkIfPresent(long pos) {
|
||||
- return (ChunkHolder) this.visibleChunkMap.get(pos);
|
||||
+ // Paper start - Don't copy
|
||||
+ if (Thread.currentThread() == this.level.thread) {
|
||||
+ return this.updatingChunks.getVisible(pos);
|
||||
+ }
|
||||
+ return this.updatingChunks.getVisibleAsync(pos);
|
||||
+ // Paper end - Don't copy
|
||||
}
|
||||
|
||||
protected IntSupplier getChunkQueueLevel(long pos) {
|
||||
@@ -704,9 +711,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
};
|
||||
|
||||
stringbuilder.append("Updating:").append(System.lineSeparator());
|
||||
- this.updatingChunkMap.values().forEach(consumer);
|
||||
+ this.updatingChunks.getUpdatingValuesCopy().forEach(consumer); // Paper
|
||||
stringbuilder.append("Visible:").append(System.lineSeparator());
|
||||
- this.visibleChunkMap.values().forEach(consumer);
|
||||
+ this.updatingChunks.getVisibleValuesCopy().forEach(consumer); // Paper
|
||||
CrashReport crashreport = CrashReport.forThrowable(exception, "Chunk loading");
|
||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Chunk loading");
|
||||
|
||||
@@ -757,7 +764,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
// Paper end
|
||||
}
|
||||
|
||||
- this.updatingChunkMap.put(pos, holder);
|
||||
+ this.updatingChunks.queueUpdate(pos, holder); // Paper - Don't copy
|
||||
this.modified = true;
|
||||
}
|
||||
|
||||
@@ -837,7 +844,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
protected void saveAllChunks(boolean flush) {
|
||||
if (flush) {
|
||||
- List<ChunkHolder> list = (List) this.visibleChunkMap.values().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList());
|
||||
+ List<ChunkHolder> list = (List) this.updatingChunks.getVisibleValuesCopy().stream().filter(ChunkHolder::wasAccessibleSinceLastSave).peek(ChunkHolder::refreshAccessibility).collect(Collectors.toList()); // Paper
|
||||
MutableBoolean mutableboolean = new MutableBoolean();
|
||||
|
||||
do {
|
||||
@@ -868,7 +875,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
//this.flushWorker(); // Paper - nuke IOWorker
|
||||
this.level.asyncChunkTaskManager.flush(); // Paper - flush to preserve behavior compat with pre-async behaviour
|
||||
} else {
|
||||
- this.visibleChunkMap.values().forEach(this::saveChunkIfNeeded);
|
||||
+ this.updatingChunks.getVisibleValuesCopy().forEach(this::saveChunkIfNeeded); // Paper
|
||||
}
|
||||
|
||||
}
|
||||
@@ -891,14 +898,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public boolean hasWork() {
|
||||
- return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() || !this.unloadQueue.isEmpty() || this.queueSorter.hasWork() || this.distanceManager.hasTickets();
|
||||
+ return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() || !this.updatingChunks.getUpdatingValuesCopy().isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() || !this.unloadQueue.isEmpty() || this.queueSorter.hasWork() || this.distanceManager.hasTickets(); // Paper
|
||||
}
|
||||
|
||||
private void processUnloads(BooleanSupplier shouldKeepTicking) {
|
||||
LongIterator longiterator = this.toDrop.iterator();
|
||||
for (int i = 0; longiterator.hasNext() && (shouldKeepTicking.getAsBoolean() || i < 200 || this.toDrop.size() > 2000); longiterator.remove()) {
|
||||
long j = longiterator.nextLong();
|
||||
- ChunkHolder playerchunk = (ChunkHolder) this.updatingChunkMap.remove(j);
|
||||
+ ChunkHolder playerchunk = this.updatingChunks.queueRemove(j); // Paper - Don't copy
|
||||
|
||||
if (playerchunk != null) {
|
||||
playerchunk.onChunkRemove(); // Paper
|
||||
@@ -993,7 +1000,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
if (!this.modified) {
|
||||
return false;
|
||||
} else {
|
||||
- this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
+ // Paper start - Don't copy
|
||||
+ synchronized (this.updatingChunks) {
|
||||
+ this.updatingChunks.performUpdates();
|
||||
+ }
|
||||
+ // Paper end - Don't copy
|
||||
+
|
||||
this.modified = false;
|
||||
return true;
|
||||
}
|
||||
@@ -1493,7 +1505,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
|
||||
this.viewDistance = j;
|
||||
this.distanceManager.updatePlayerTickets(this.viewDistance + 1);
|
||||
- ObjectIterator objectiterator = this.updatingChunkMap.values().iterator();
|
||||
+ Iterator objectiterator = this.updatingChunks.getVisibleValuesCopy().iterator(); // Paper
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
ChunkHolder playerchunk = (ChunkHolder) objectiterator.next();
|
||||
@@ -1536,7 +1548,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
public int size() {
|
||||
- return this.visibleChunkMap.size();
|
||||
+ return this.updatingChunks.getVisibleMap().size(); // Paper - Don't copy
|
||||
}
|
||||
|
||||
public DistanceManager getDistanceManager() {
|
||||
@@ -1544,13 +1556,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
}
|
||||
|
||||
protected Iterable<ChunkHolder> getChunks() {
|
||||
- return Iterables.unmodifiableIterable(this.visibleChunkMap.values());
|
||||
+ return Iterables.unmodifiableIterable(this.updatingChunks.getVisibleValuesCopy()); // Paper
|
||||
}
|
||||
|
||||
void dumpChunks(Writer writer) throws IOException {
|
||||
CsvOutput csvwriter = CsvOutput.builder().addColumn("x").addColumn("z").addColumn("level").addColumn("in_memory").addColumn("status").addColumn("full_status").addColumn("accessible_ready").addColumn("ticking_ready").addColumn("entity_ticking_ready").addColumn("ticket").addColumn("spawning").addColumn("block_entity_count").addColumn("ticking_ticket").addColumn("ticking_level").addColumn("block_ticks").addColumn("fluid_ticks").build(writer);
|
||||
TickingTracker tickingtracker = this.distanceManager.tickingTracker();
|
||||
- ObjectBidirectionalIterator objectbidirectionaliterator = this.visibleChunkMap.long2ObjectEntrySet().iterator();
|
||||
+ ObjectBidirectionalIterator objectbidirectionaliterator = this.updatingChunks.getVisibleMap().clone().long2ObjectEntrySet().fastIterator(); // Paper
|
||||
|
||||
while (objectbidirectionaliterator.hasNext()) {
|
||||
Entry<ChunkHolder> entry = (Entry) objectbidirectionaliterator.next();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 21bf39ef5b20ecc989881b07c4e6b90c68540afd..beee040abf846492cefabe985c5286b00fc6bc63 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -167,7 +167,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
@Override
|
||||
public int getTileEntityCount() {
|
||||
// We don't use the full world tile entity list, so we must iterate chunks
|
||||
- Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkSource().chunkMap.visibleChunkMap;
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map
|
||||
int size = 0;
|
||||
for (ChunkHolder playerchunk : chunks.values()) {
|
||||
net.minecraft.world.level.chunk.LevelChunk chunk = playerchunk.getTickingChunk();
|
||||
@@ -188,7 +188,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
public int getChunkCount() {
|
||||
int ret = 0;
|
||||
|
||||
- for (ChunkHolder chunkHolder : world.getChunkSource().chunkMap.visibleChunkMap.values()) {
|
||||
+ for (ChunkHolder chunkHolder : world.getChunkSource().chunkMap.updatingChunks.getVisibleMap().values()) { // Paper - change updating chunks map
|
||||
if (chunkHolder.getTickingChunk() != null) {
|
||||
++ret;
|
||||
}
|
||||
@@ -345,7 +345,18 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public Chunk[] getLoadedChunks() {
|
||||
- Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = this.world.getChunkSource().chunkMap.visibleChunkMap;
|
||||
+ // Paper start
|
||||
+ if (Thread.currentThread() != world.getLevel().thread) {
|
||||
+ // Paper start - change updating chunks map
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks;
|
||||
+ synchronized (world.getChunkSource().chunkMap.updatingChunks) {
|
||||
+ chunks = world.getChunkSource().chunkMap.updatingChunks.getVisibleMap().clone();
|
||||
+ }
|
||||
+ return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new);
|
||||
+ // Paper end - change updating chunks map
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = this.world.getChunkSource().chunkMap.updatingChunks.getVisibleMap(); // Paper - change updating chunks map
|
||||
return chunks.values().stream().map(ChunkHolder::getFullChunkNow).filter(Objects::nonNull).map(net.minecraft.world.level.chunk.LevelChunk::getBukkitChunk).toArray(Chunk[]::new);
|
||||
}
|
||||
|
||||
@@ -421,7 +432,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
|
||||
@Override
|
||||
public boolean refreshChunk(int x, int z) {
|
||||
- ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.visibleChunkMap.get(ChunkPos.asLong(x, z));
|
||||
+ ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.updatingChunks.getVisibleMap().get(ChunkPos.asLong(x, z));
|
||||
if (playerChunk == null) return false;
|
||||
|
||||
playerChunk.getTickingChunkFuture().thenAccept(either -> {
|
|
@ -0,0 +1,766 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 2 Feb 2020 02:25:10 -0800
|
||||
Subject: [PATCH] Attempt to recalculate regionfile header if it is corrupt
|
||||
|
||||
Instead of trying to relocate the chunk, which is seems to never
|
||||
be the correct choice, so we end up duplicating or swapping chunks,
|
||||
we instead drop the current regionfile header and recalculate -
|
||||
hoping that at least then we don't swap chunks, and maybe recover
|
||||
them all.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
index 12e3831324abdc1112cbe65cab0f0c75ce77a9ef..be9c15fe141ede1132dbe07ba4bfcf22036ab194 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
@@ -68,6 +68,18 @@ import net.minecraft.world.ticks.ProtoChunkTicks;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class ChunkSerializer {
|
||||
+ // Paper start
|
||||
+ // TODO: Check on update
|
||||
+ public static long getLastWorldSaveTime(CompoundTag chunkData) {
|
||||
+ final int dataVersion = ChunkStorage.getVersion(chunkData);
|
||||
+ if (dataVersion < 2842) { // Level tag is removed after this version
|
||||
+ final CompoundTag levelData = chunkData.getCompound("Level");
|
||||
+ return levelData.getLong("LastUpdate");
|
||||
+ } else {
|
||||
+ return chunkData.getLong("LastUpdate");
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null); // Paper - Anti-Xray - Add preset block states
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -473,7 +485,7 @@ public class ChunkSerializer {
|
||||
nbttagcompound.putInt("xPos", chunkcoordintpair.x);
|
||||
nbttagcompound.putInt("yPos", chunk.getMinSection());
|
||||
nbttagcompound.putInt("zPos", chunkcoordintpair.z);
|
||||
- nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading
|
||||
+ nbttagcompound.putLong("LastUpdate", asyncsavedata != null ? asyncsavedata.worldTime : world.getGameTime()); // Paper - async chunk unloading // Paper - diff on change
|
||||
nbttagcompound.putLong("InhabitedTime", chunk.getInhabitedTime());
|
||||
nbttagcompound.putString("Status", chunk.getStatus().getName());
|
||||
BlendingData blendingdata = chunk.getBlendingData();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
index 315be30daf0be84efbb4d634dc01e1bf9e6e696e..3010e092bd1337e5a6b99636bbd312d90e470acf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -41,7 +41,7 @@ public class ChunkStorage implements AutoCloseable {
|
||||
this.fixerUpper = dataFixer;
|
||||
// Paper start - async chunk io
|
||||
// remove IO worker
|
||||
- this.regionFileCache = new RegionFileStorage(directory, dsync); // Paper - nuke IOWorker
|
||||
+ this.regionFileCache = new RegionFileStorage(directory, dsync, true); // Paper - nuke IOWorker // Paper
|
||||
// Paper end - async chunk io
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionBitmap.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionBitmap.java
|
||||
index c8298a597818227de33a4afce4698ec0666cf758..6baceb6ce9021c489be6e79d338a9704285afa26 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionBitmap.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionBitmap.java
|
||||
@@ -9,6 +9,27 @@ import java.util.BitSet;
|
||||
public class RegionBitmap {
|
||||
private final BitSet used = new BitSet();
|
||||
|
||||
+ // Paper start
|
||||
+ public final void copyFrom(RegionBitmap other) {
|
||||
+ BitSet thisBitset = this.used;
|
||||
+ BitSet otherBitset = other.used;
|
||||
+
|
||||
+ for (int i = 0; i < Math.max(thisBitset.size(), otherBitset.size()); ++i) {
|
||||
+ thisBitset.set(i, otherBitset.get(i));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public final boolean tryAllocate(int from, int length) {
|
||||
+ BitSet bitset = this.used;
|
||||
+ int firstSet = bitset.nextSetBit(from);
|
||||
+ if (firstSet > 0 && firstSet < (from + length)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ bitset.set(from, from + length);
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void force(int start, int size) {
|
||||
this.used.set(start, start + size);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index 861a25a15f1aab20e3245b6d5cdad5d23bdfd6d0..8ff8855c5267379b3a5f5d8baa4a275ffee2c4bf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -51,6 +51,355 @@ public class RegionFile implements AutoCloseable {
|
||||
public final java.util.concurrent.locks.ReentrantLock fileLock = new java.util.concurrent.locks.ReentrantLock(true); // Paper
|
||||
public final Path regionFile; // Paper
|
||||
|
||||
+ // Paper start - try to recover from RegionFile header corruption
|
||||
+ private static long roundToSectors(long bytes) {
|
||||
+ long sectors = bytes >>> 12; // 4096 = 2^12
|
||||
+ long remainingBytes = bytes & 4095;
|
||||
+ long sign = -remainingBytes; // sign is 1 if nonzero
|
||||
+ return sectors + (sign >>> 63);
|
||||
+ }
|
||||
+
|
||||
+ private static final CompoundTag OVERSIZED_COMPOUND = new CompoundTag();
|
||||
+
|
||||
+ private CompoundTag attemptRead(long sector, int chunkDataLength, long fileLength) throws IOException {
|
||||
+ try {
|
||||
+ if (chunkDataLength < 0) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ long offset = sector * 4096L + 4L; // offset for chunk data
|
||||
+
|
||||
+ if ((offset + chunkDataLength) > fileLength) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ ByteBuffer chunkData = ByteBuffer.allocate(chunkDataLength);
|
||||
+ if (chunkDataLength != this.file.read(chunkData, offset)) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ ((java.nio.Buffer)chunkData).flip();
|
||||
+
|
||||
+ byte compressionType = chunkData.get();
|
||||
+ if (compressionType < 0) { // compressionType & 128 != 0
|
||||
+ // oversized chunk
|
||||
+ return OVERSIZED_COMPOUND;
|
||||
+ }
|
||||
+
|
||||
+ RegionFileVersion compression = RegionFileVersion.fromId(compressionType);
|
||||
+ if (compression == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ InputStream input = compression.wrap(new ByteArrayInputStream(chunkData.array(), chunkData.position(), chunkDataLength - chunkData.position()));
|
||||
+
|
||||
+ return NbtIo.read(new DataInputStream(input));
|
||||
+ } catch (Exception ex) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private int getLength(long sector) throws IOException {
|
||||
+ ByteBuffer length = ByteBuffer.allocate(4);
|
||||
+ if (4 != this.file.read(length, sector * 4096L)) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return length.getInt(0);
|
||||
+ }
|
||||
+
|
||||
+ private void backupRegionFile() {
|
||||
+ Path backup = this.regionFile.getParent().resolve(this.regionFile.getFileName() + "." + new java.util.Random().nextLong() + ".backup");
|
||||
+ this.backupRegionFile(backup);
|
||||
+ }
|
||||
+
|
||||
+ private void backupRegionFile(Path to) {
|
||||
+ try {
|
||||
+ this.file.force(true);
|
||||
+ LOGGER.warn("Backing up regionfile \"" + this.regionFile.toAbsolutePath() + "\" to " + to.toAbsolutePath());
|
||||
+ java.nio.file.Files.copy(this.regionFile, to, java.nio.file.StandardCopyOption.COPY_ATTRIBUTES);
|
||||
+ LOGGER.warn("Backed up the regionfile to " + to.toAbsolutePath());
|
||||
+ } catch (IOException ex) {
|
||||
+ LOGGER.error("Failed to backup to " + to.toAbsolutePath(), ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static boolean inSameRegionfile(ChunkPos first, ChunkPos second) {
|
||||
+ return (first.x & ~31) == (second.x & ~31) && (first.z & ~31) == (second.z & ~31);
|
||||
+ }
|
||||
+
|
||||
+ // note: only call for CHUNK regionfiles
|
||||
+ boolean recalculateHeader() throws IOException {
|
||||
+ if (!this.canRecalcHeader) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ ChunkPos ourLowerLeftPosition = RegionFileStorage.getRegionFileCoordinates(this.regionFile);
|
||||
+ if (ourLowerLeftPosition == null) {
|
||||
+ LOGGER.error("Unable to get chunk location of regionfile " + this.regionFile.toAbsolutePath() + ", cannot recover header");
|
||||
+ return false;
|
||||
+ }
|
||||
+ synchronized (this) {
|
||||
+ LOGGER.warn("Corrupt regionfile header detected! Attempting to re-calculate header offsets for regionfile " + this.regionFile.toAbsolutePath(), new Throwable());
|
||||
+
|
||||
+ // try to backup file so maybe it could be sent to us for further investigation
|
||||
+
|
||||
+ this.backupRegionFile();
|
||||
+ CompoundTag[] compounds = new CompoundTag[32 * 32]; // only in the regionfile (i.e exclude mojang/aikar oversized data)
|
||||
+ int[] rawLengths = new int[32 * 32]; // length of chunk data including 4 byte length field, bytes
|
||||
+ int[] sectorOffsets = new int[32 * 32]; // in sectors
|
||||
+ boolean[] hasAikarOversized = new boolean[32 * 32];
|
||||
+
|
||||
+ long fileLength = this.file.size();
|
||||
+ long totalSectors = roundToSectors(fileLength);
|
||||
+
|
||||
+ // search the regionfile from start to finish for the most up-to-date chunk data
|
||||
+
|
||||
+ for (long i = 2, maxSector = Math.min((long)(Integer.MAX_VALUE >>> 8), totalSectors); i < maxSector; ++i) { // first two sectors are header, skip
|
||||
+ int chunkDataLength = this.getLength(i);
|
||||
+ CompoundTag compound = this.attemptRead(i, chunkDataLength, fileLength);
|
||||
+ if (compound == null || compound == OVERSIZED_COMPOUND) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(compound);
|
||||
+ if (!inSameRegionfile(ourLowerLeftPosition, chunkPos)) {
|
||||
+ LOGGER.error("Ignoring absolute chunk " + chunkPos + " in regionfile as it is not contained in the bounds of the regionfile '" + this.regionFile.toAbsolutePath() + "'. It should be in regionfile (" + (chunkPos.x >> 5) + "," + (chunkPos.z >> 5) + ")");
|
||||
+ continue;
|
||||
+ }
|
||||
+ int location = (chunkPos.x & 31) | ((chunkPos.z & 31) << 5);
|
||||
+
|
||||
+ CompoundTag otherCompound = compounds[location];
|
||||
+
|
||||
+ if (otherCompound != null && ChunkSerializer.getLastWorldSaveTime(otherCompound) > ChunkSerializer.getLastWorldSaveTime(compound)) {
|
||||
+ continue; // don't overwrite newer data.
|
||||
+ }
|
||||
+
|
||||
+ // aikar oversized?
|
||||
+ Path aikarOversizedFile = this.getOversizedFile(chunkPos.x, chunkPos.z);
|
||||
+ boolean isAikarOversized = false;
|
||||
+ if (Files.exists(aikarOversizedFile)) {
|
||||
+ try {
|
||||
+ CompoundTag aikarOversizedCompound = this.getOversizedData(chunkPos.x, chunkPos.z);
|
||||
+ if (ChunkSerializer.getLastWorldSaveTime(compound) == ChunkSerializer.getLastWorldSaveTime(aikarOversizedCompound)) {
|
||||
+ // best we got for an id. hope it's good enough
|
||||
+ isAikarOversized = true;
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ LOGGER.error("Failed to read aikar oversized data for absolute chunk (" + chunkPos.x + "," + chunkPos.z + ") in regionfile " + this.regionFile.toAbsolutePath() + ", oversized data for this chunk will be lost", ex);
|
||||
+ // fall through, if we can't read aikar oversized we can't risk corrupting chunk data
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ hasAikarOversized[location] = isAikarOversized;
|
||||
+ compounds[location] = compound;
|
||||
+ rawLengths[location] = chunkDataLength + 4;
|
||||
+ sectorOffsets[location] = (int)i;
|
||||
+
|
||||
+ int chunkSectorLength = (int)roundToSectors(rawLengths[location]);
|
||||
+ i += chunkSectorLength;
|
||||
+ --i; // gets incremented next iteration
|
||||
+ }
|
||||
+
|
||||
+ // forge style oversized data is already handled by the local search, and aikar data we just hope
|
||||
+ // we get it right as aikar data has no identifiers we could use to try and find its corresponding
|
||||
+ // local data compound
|
||||
+
|
||||
+ java.nio.file.Path containingFolder = this.externalFileDir;
|
||||
+ Path[] regionFiles = Files.list(containingFolder).toArray(Path[]::new);
|
||||
+ boolean[] oversized = new boolean[32 * 32];
|
||||
+ RegionFileVersion[] oversizedCompressionTypes = new RegionFileVersion[32 * 32];
|
||||
+
|
||||
+ if (regionFiles != null) {
|
||||
+ int lowerXBound = ourLowerLeftPosition.x; // inclusive
|
||||
+ int lowerZBound = ourLowerLeftPosition.z; // inclusive
|
||||
+ int upperXBound = lowerXBound + 32 - 1; // inclusive
|
||||
+ int upperZBound = lowerZBound + 32 - 1; // inclusive
|
||||
+
|
||||
+ // read mojang oversized data
|
||||
+ for (Path regionFile : regionFiles) {
|
||||
+ ChunkPos oversizedCoords = getOversizedChunkPair(regionFile);
|
||||
+ if (oversizedCoords == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if ((oversizedCoords.x < lowerXBound || oversizedCoords.x > upperXBound) || (oversizedCoords.z < lowerZBound || oversizedCoords.z > upperZBound)) {
|
||||
+ continue; // not in our regionfile
|
||||
+ }
|
||||
+
|
||||
+ // ensure oversized data is valid & is newer than data in the regionfile
|
||||
+
|
||||
+ int location = (oversizedCoords.x & 31) | ((oversizedCoords.z & 31) << 5);
|
||||
+
|
||||
+ byte[] chunkData;
|
||||
+ try {
|
||||
+ chunkData = Files.readAllBytes(regionFile);
|
||||
+ } catch (Exception ex) {
|
||||
+ LOGGER.error("Failed to read oversized chunk data in file " + regionFile.toAbsolutePath() + ", data will be lost", ex);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ CompoundTag compound = null;
|
||||
+
|
||||
+ // We do not know the compression type, as it's stored in the regionfile. So we need to try all of them
|
||||
+ RegionFileVersion compression = null;
|
||||
+ for (RegionFileVersion compressionType : RegionFileVersion.VERSIONS.values()) {
|
||||
+ try {
|
||||
+ DataInputStream in = new DataInputStream(compressionType.wrap(new ByteArrayInputStream(chunkData))); // typical java
|
||||
+ compound = NbtIo.read((java.io.DataInput)in);
|
||||
+ compression = compressionType;
|
||||
+ break; // reaches here iff readNBT does not throw
|
||||
+ } catch (Exception ex) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (compound == null) {
|
||||
+ LOGGER.error("Failed to read oversized chunk data in file " + regionFile.toAbsolutePath() + ", it's corrupt. Its data will be lost");
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!ChunkSerializer.getChunkCoordinate(compound).equals(oversizedCoords)) {
|
||||
+ LOGGER.error("Can't use oversized chunk stored in " + regionFile.toAbsolutePath() + ", got absolute chunkpos: " + ChunkSerializer.getChunkCoordinate(compound) + ", expected " + oversizedCoords);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (compounds[location] == null || ChunkSerializer.getLastWorldSaveTime(compound) > ChunkSerializer.getLastWorldSaveTime(compounds[location])) {
|
||||
+ oversized[location] = true;
|
||||
+ oversizedCompressionTypes[location] = compression;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // now we need to calculate a new offset header
|
||||
+
|
||||
+ int[] calculatedOffsets = new int[32 * 32];
|
||||
+ RegionBitmap newSectorAllocations = new RegionBitmap();
|
||||
+ newSectorAllocations.force(0, 2); // make space for header
|
||||
+
|
||||
+ // allocate sectors for normal chunks
|
||||
+
|
||||
+ for (int chunkX = 0; chunkX < 32; ++chunkX) {
|
||||
+ for (int chunkZ = 0; chunkZ < 32; ++chunkZ) {
|
||||
+ int location = chunkX | (chunkZ << 5);
|
||||
+
|
||||
+ if (oversized[location]) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ int rawLength = rawLengths[location]; // bytes
|
||||
+ int sectorOffset = sectorOffsets[location]; // sectors
|
||||
+ int sectorLength = (int)roundToSectors(rawLength);
|
||||
+
|
||||
+ if (newSectorAllocations.tryAllocate(sectorOffset, sectorLength)) {
|
||||
+ calculatedOffsets[location] = sectorOffset << 8 | (sectorLength > 255 ? 255 : sectorLength); // support forge style oversized
|
||||
+ } else {
|
||||
+ LOGGER.error("Failed to allocate space for local chunk (overlapping data??) at (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath() + ", chunk will be regenerated");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // allocate sectors for oversized chunks
|
||||
+
|
||||
+ for (int chunkX = 0; chunkX < 32; ++chunkX) {
|
||||
+ for (int chunkZ = 0; chunkZ < 32; ++chunkZ) {
|
||||
+ int location = chunkX | (chunkZ << 5);
|
||||
+
|
||||
+ if (!oversized[location]) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ int sectorOffset = newSectorAllocations.allocate(1);
|
||||
+ int sectorLength = 1;
|
||||
+
|
||||
+ try {
|
||||
+ this.file.write(this.createExternalStub(oversizedCompressionTypes[location]), sectorOffset * 4096);
|
||||
+ // only allocate in the new offsets if the write succeeds
|
||||
+ calculatedOffsets[location] = sectorOffset << 8 | (sectorLength > 255 ? 255 : sectorLength); // support forge style oversized
|
||||
+ } catch (IOException ex) {
|
||||
+ newSectorAllocations.free(sectorOffset, sectorLength);
|
||||
+ LOGGER.error("Failed to write new oversized chunk data holder, local chunk at (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath() + " will be regenerated");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // rewrite aikar oversized data
|
||||
+
|
||||
+ this.oversizedCount = 0;
|
||||
+ for (int chunkX = 0; chunkX < 32; ++chunkX) {
|
||||
+ for (int chunkZ = 0; chunkZ < 32; ++chunkZ) {
|
||||
+ int location = chunkX | (chunkZ << 5);
|
||||
+ int isAikarOversized = hasAikarOversized[location] ? 1 : 0;
|
||||
+
|
||||
+ this.oversizedCount += isAikarOversized;
|
||||
+ this.oversized[location] = (byte)isAikarOversized;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (this.oversizedCount > 0) {
|
||||
+ try {
|
||||
+ this.writeOversizedMeta();
|
||||
+ } catch (Exception ex) {
|
||||
+ LOGGER.error("Failed to write aikar oversized chunk meta, all aikar style oversized chunk data will be lost for regionfile " + this.regionFile.toAbsolutePath(), ex);
|
||||
+ Files.deleteIfExists(this.getOversizedMetaFile());
|
||||
+ }
|
||||
+ } else {
|
||||
+ Files.deleteIfExists(this.getOversizedMetaFile());
|
||||
+ }
|
||||
+
|
||||
+ this.usedSectors.copyFrom(newSectorAllocations);
|
||||
+
|
||||
+ // before we overwrite the old sectors, print a summary of the chunks that got changed.
|
||||
+
|
||||
+ LOGGER.info("Starting summary of changes for regionfile " + this.regionFile.toAbsolutePath());
|
||||
+
|
||||
+ for (int chunkX = 0; chunkX < 32; ++chunkX) {
|
||||
+ for (int chunkZ = 0; chunkZ < 32; ++chunkZ) {
|
||||
+ int location = chunkX | (chunkZ << 5);
|
||||
+
|
||||
+ int oldOffset = this.offsets.get(location);
|
||||
+ int newOffset = calculatedOffsets[location];
|
||||
+
|
||||
+ if (oldOffset == newOffset) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.offsets.put(location, newOffset); // overwrite incorrect offset
|
||||
+
|
||||
+ if (oldOffset == 0) {
|
||||
+ // found lost data
|
||||
+ LOGGER.info("Found missing data for local chunk (" + chunkX + "," + chunkZ + ") in regionfile " + this.regionFile.toAbsolutePath());
|
||||
+ } else if (newOffset == 0) {
|
||||
+ LOGGER.warn("Data for local chunk (" + chunkX + "," + chunkZ + ") could not be recovered in regionfile " + this.regionFile.toAbsolutePath() + ", it will be regenerated");
|
||||
+ } else {
|
||||
+ LOGGER.info("Local chunk (" + chunkX + "," + chunkZ + ") changed to point to newer data or correct chunk in regionfile " + this.regionFile.toAbsolutePath());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ LOGGER.info("End of change summary for regionfile " + this.regionFile.toAbsolutePath());
|
||||
+
|
||||
+ // simply destroy the timestamp header, it's not used
|
||||
+
|
||||
+ for (int i = 0; i < 32 * 32; ++i) {
|
||||
+ this.timestamps.put(i, calculatedOffsets[i] != 0 ? (int)System.currentTimeMillis() : 0); // write a valid timestamp for valid chunks, I do not want to find out whatever dumb program actually checks this
|
||||
+ }
|
||||
+
|
||||
+ // write new header
|
||||
+ try {
|
||||
+ this.flush();
|
||||
+ this.file.force(true); // try to ensure it goes through...
|
||||
+ LOGGER.info("Successfully wrote new header to disk for regionfile " + this.regionFile.toAbsolutePath());
|
||||
+ } catch (IOException ex) {
|
||||
+ LOGGER.error("Failed to write new header to disk for regionfile " + this.regionFile.toAbsolutePath(), ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ final boolean canRecalcHeader; // final forces compile fail on new constructor
|
||||
+ // Paper end
|
||||
+
|
||||
// Paper start - Cache chunk status
|
||||
private final net.minecraft.world.level.chunk.ChunkStatus[] statuses = new net.minecraft.world.level.chunk.ChunkStatus[32 * 32];
|
||||
|
||||
@@ -78,8 +427,19 @@ public class RegionFile implements AutoCloseable {
|
||||
public RegionFile(Path file, Path directory, boolean dsync) throws IOException {
|
||||
this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync);
|
||||
}
|
||||
+ // Paper start - add can recalc flag
|
||||
+ public RegionFile(Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader);
|
||||
+ }
|
||||
+ // Paper end - add can recalc flag
|
||||
|
||||
public RegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync) throws IOException {
|
||||
+ // Paper start - add can recalc flag
|
||||
+ this(file, directory, outputChunkStreamVersion, dsync, false);
|
||||
+ }
|
||||
+ public RegionFile(Path file, Path directory, RegionFileVersion outputChunkStreamVersion, boolean dsync, boolean canRecalcHeader) throws IOException {
|
||||
+ this.canRecalcHeader = canRecalcHeader;
|
||||
+ // Paper end - add can recalc flag
|
||||
this.header = ByteBuffer.allocateDirect(8192);
|
||||
this.regionFile = file; // Paper
|
||||
initOversizedState(); // Paper
|
||||
@@ -108,14 +468,16 @@ public class RegionFile implements AutoCloseable {
|
||||
RegionFile.LOGGER.warn("Region file {} has truncated header: {}", file, i);
|
||||
}
|
||||
|
||||
- long j = Files.size(file);
|
||||
+ final long j = Files.size(file); final long regionFileSize = j; // Paper - recalculate header on header corruption
|
||||
|
||||
- for (int k = 0; k < 1024; ++k) {
|
||||
- int l = this.offsets.get(k);
|
||||
+ boolean needsHeaderRecalc = false; // Paper - recalculate header on header corruption
|
||||
+ boolean hasBackedUp = false; // Paper - recalculate header on header corruption
|
||||
+ for (int k = 0; k < 1024; ++k) { final int headerLocation = k; // Paper - we expect this to be the header location
|
||||
+ final int l = this.offsets.get(k);
|
||||
|
||||
if (l != 0) {
|
||||
- int i1 = RegionFile.getSectorNumber(l);
|
||||
- int j1 = RegionFile.getNumSectors(l);
|
||||
+ final int i1 = RegionFile.getSectorNumber(l); final int offset = i1; // Paper - we expect this to be offset in file in sectors
|
||||
+ int j1 = RegionFile.getNumSectors(l); final int sectorLength; // Paper - diff on change, we expect this to be sector length of region - watch out for reassignments
|
||||
// Spigot start
|
||||
if (j1 == 255) {
|
||||
// We're maxed out, so we need to read the proper length from the section
|
||||
@@ -124,32 +486,102 @@ public class RegionFile implements AutoCloseable {
|
||||
j1 = (realLen.getInt(0) + 4) / 4096 + 1;
|
||||
}
|
||||
// Spigot end
|
||||
+ sectorLength = j1; // Paper - diff on change, we expect this to be sector length of region
|
||||
|
||||
if (i1 < 2) {
|
||||
RegionFile.LOGGER.warn("Region file {} has invalid sector at index: {}; sector {} overlaps with header", new Object[]{file, k, i1});
|
||||
- this.offsets.put(k, 0);
|
||||
+ //this.offsets.put(k, 0); // Paper - we catch this, but need it in the header for the summary change
|
||||
} else if (j1 == 0) {
|
||||
RegionFile.LOGGER.warn("Region file {} has an invalid sector at index: {}; size has to be > 0", file, k);
|
||||
- this.offsets.put(k, 0);
|
||||
+ //this.offsets.put(k, 0); // Paper - we catch this, but need it in the header for the summary change
|
||||
} else if ((long) i1 * 4096L > j) {
|
||||
RegionFile.LOGGER.warn("Region file {} has an invalid sector at index: {}; sector {} is out of bounds", new Object[]{file, k, i1});
|
||||
- this.offsets.put(k, 0);
|
||||
+ //this.offsets.put(k, 0); // Paper - we catch this, but need it in the header for the summary change
|
||||
} else {
|
||||
- this.usedSectors.force(i1, j1);
|
||||
+ //this.usedSectors.force(i1, j1); // Paper - move this down so we can check if it fails to allocate
|
||||
+ }
|
||||
+ // Paper start - recalculate header on header corruption
|
||||
+ if (offset < 2 || sectorLength <= 0 || ((long)offset * 4096L) > regionFileSize) {
|
||||
+ if (canRecalcHeader) {
|
||||
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() + "! Recalculating header...");
|
||||
+ needsHeaderRecalc = true;
|
||||
+ break;
|
||||
+ } else {
|
||||
+ // location = chunkX | (chunkZ << 5);
|
||||
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() +
|
||||
+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header");
|
||||
+ if (!hasBackedUp) {
|
||||
+ hasBackedUp = true;
|
||||
+ this.backupRegionFile();
|
||||
+ }
|
||||
+ this.timestamps.put(headerLocation, 0); // be consistent, delete the timestamp too
|
||||
+ this.offsets.put(headerLocation, 0); // delete the entry from header
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+ boolean failedToAllocate = !this.usedSectors.tryAllocate(offset, sectorLength);
|
||||
+ if (failedToAllocate) {
|
||||
+ LOGGER.error("Overlapping allocation by local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") in regionfile " + this.regionFile.toAbsolutePath());
|
||||
}
|
||||
+ if (failedToAllocate & !canRecalcHeader) {
|
||||
+ // location = chunkX | (chunkZ << 5);
|
||||
+ LOGGER.error("Detected invalid header for regionfile " + this.regionFile.toAbsolutePath() +
|
||||
+ "! Cannot recalculate, removing local chunk (" + (headerLocation & 31) + "," + (headerLocation >>> 5) + ") from header");
|
||||
+ if (!hasBackedUp) {
|
||||
+ hasBackedUp = true;
|
||||
+ this.backupRegionFile();
|
||||
+ }
|
||||
+ this.timestamps.put(headerLocation, 0); // be consistent, delete the timestamp too
|
||||
+ this.offsets.put(headerLocation, 0); // delete the entry from header
|
||||
+ continue;
|
||||
+ }
|
||||
+ needsHeaderRecalc |= failedToAllocate;
|
||||
+ // Paper end - recalculate header on header corruption
|
||||
}
|
||||
}
|
||||
+ // Paper start - recalculate header on header corruption
|
||||
+ // we move the recalc here so comparison to old header is correct when logging to console
|
||||
+ if (needsHeaderRecalc) { // true if header gave us overlapping allocations or had other issues
|
||||
+ LOGGER.error("Recalculating regionfile " + this.regionFile.toAbsolutePath() + ", header gave erroneous offsets & locations");
|
||||
+ this.recalculateHeader();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Path getExternalChunkPath(ChunkPos chunkPos) {
|
||||
- String s = "c." + chunkPos.x + "." + chunkPos.z + ".mcc";
|
||||
+ String s = "c." + chunkPos.x + "." + chunkPos.z + ".mcc"; // Paper - diff on change
|
||||
|
||||
return this.externalFileDir.resolve(s);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private static ChunkPos getOversizedChunkPair(Path file) {
|
||||
+ String fileName = file.getFileName().toString();
|
||||
+
|
||||
+ if (!fileName.startsWith("c.") || !fileName.endsWith(".mcc")) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ String[] split = fileName.split("\\.");
|
||||
+
|
||||
+ if (split.length != 4) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ int x = Integer.parseInt(split[1]);
|
||||
+ int z = Integer.parseInt(split[2]);
|
||||
+
|
||||
+ return new ChunkPos(x, z);
|
||||
+ } catch (NumberFormatException ex) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Nullable
|
||||
public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException {
|
||||
int i = this.getOffset(pos);
|
||||
@@ -173,6 +605,11 @@ public class RegionFile implements AutoCloseable {
|
||||
((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error
|
||||
if (bytebuffer.remaining() < 5) {
|
||||
RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", new Object[]{pos, l, bytebuffer.remaining()});
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ if (this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
return null;
|
||||
} else {
|
||||
int i1 = bytebuffer.getInt();
|
||||
@@ -180,6 +617,11 @@ public class RegionFile implements AutoCloseable {
|
||||
|
||||
if (i1 == 0) {
|
||||
RegionFile.LOGGER.warn("Chunk {} is allocated, but stream is missing", pos);
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ if (this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
return null;
|
||||
} else {
|
||||
int j1 = i1 - 1;
|
||||
@@ -187,17 +629,44 @@ public class RegionFile implements AutoCloseable {
|
||||
if (RegionFile.isExternalStreamChunk(b0)) {
|
||||
if (j1 != 0) {
|
||||
RegionFile.LOGGER.warn("Chunk has both internal and external streams");
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ if (this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
}
|
||||
|
||||
- return this.createExternalChunkInputStream(pos, RegionFile.getExternalChunkVersion(b0));
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ final DataInputStream ret = this.createExternalChunkInputStream(pos, RegionFile.getExternalChunkVersion(b0));
|
||||
+ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ return ret;
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
} else if (j1 > bytebuffer.remaining()) {
|
||||
RegionFile.LOGGER.error("Chunk {} stream is truncated: expected {} but read {}", new Object[]{pos, j1, bytebuffer.remaining()});
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ if (this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
return null;
|
||||
} else if (j1 < 0) {
|
||||
RegionFile.LOGGER.error("Declared size {} of chunk {} is negative", i1, pos);
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ if (this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
return null;
|
||||
} else {
|
||||
- return this.createChunkInputStream(pos, b0, RegionFile.createStream(bytebuffer, j1));
|
||||
+ // Paper start - recalculate header on regionfile corruption
|
||||
+ final DataInputStream ret = this.createChunkInputStream(pos, b0, RegionFile.createStream(bytebuffer, j1));
|
||||
+ if (ret == null && this.canRecalcHeader && this.recalculateHeader()) {
|
||||
+ return this.getChunkDataInputStream(pos);
|
||||
+ }
|
||||
+ return ret;
|
||||
+ // Paper end - recalculate header on regionfile corruption
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -372,10 +841,15 @@ public class RegionFile implements AutoCloseable {
|
||||
}
|
||||
|
||||
private ByteBuffer createExternalStub() {
|
||||
+ // Paper start - add version param
|
||||
+ return this.createExternalStub(this.version);
|
||||
+ }
|
||||
+ private ByteBuffer createExternalStub(RegionFileVersion version) {
|
||||
+ // Paper end - add version param
|
||||
ByteBuffer bytebuffer = ByteBuffer.allocate(5);
|
||||
|
||||
bytebuffer.putInt(1);
|
||||
- bytebuffer.put((byte) (this.version.getId() | 128));
|
||||
+ bytebuffer.put((byte) (version.getId() | 128)); // Paper - replace with version param
|
||||
((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error
|
||||
return bytebuffer;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 0d96d1c0b66c57c680759f3567ef1b0c326d8cfa..6986a170f37f70e8eb89d79d5d2615a06a5e0f0c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -26,7 +26,15 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
private final Path folder;
|
||||
private final boolean sync;
|
||||
|
||||
+ private final boolean isChunkData; // Paper
|
||||
+
|
||||
RegionFileStorage(Path directory, boolean dsync) {
|
||||
+ // Paper start - add isChunkData param
|
||||
+ this(directory, dsync, false);
|
||||
+ }
|
||||
+ RegionFileStorage(Path directory, boolean dsync, boolean isChunkData) {
|
||||
+ this.isChunkData = isChunkData;
|
||||
+ // Paper end - add isChunkData param
|
||||
this.folder = directory;
|
||||
this.sync = dsync;
|
||||
}
|
||||
@@ -88,9 +96,9 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
Files.createDirectories(this.folder);
|
||||
Path path = this.folder;
|
||||
int j = chunkcoordintpair.getRegionX();
|
||||
- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change
|
||||
if (existingOnly && !Files.exists(path1)) return null; // CraftBukkit
|
||||
- RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync);
|
||||
+ RegionFile regionfile1 = new RegionFile(path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header
|
||||
|
||||
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||
// Paper start
|
||||
@@ -175,6 +183,13 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
if (regionfile == null) {
|
||||
return null;
|
||||
}
|
||||
+ // Paper start - Add regionfile parameter
|
||||
+ return this.read(pos, regionfile);
|
||||
+ }
|
||||
+ public CompoundTag read(ChunkPos pos, RegionFile regionfile) throws IOException {
|
||||
+ // We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile
|
||||
+ // if we decide to re-read
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
try { // Paper
|
||||
DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos);
|
||||
@@ -191,6 +206,20 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
try {
|
||||
if (datainputstream != null) {
|
||||
nbttagcompound = NbtIo.read((DataInput) datainputstream);
|
||||
+ // Paper start - recover from corrupt regionfile header
|
||||
+ if (this.isChunkData) {
|
||||
+ ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound);
|
||||
+ if (!chunkPos.equals(pos)) {
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.regionFile.toAbsolutePath());
|
||||
+ if (regionfile.recalculateHeader()) {
|
||||
+ regionfile.fileLock.lock(); // otherwise we will unlock twice and only lock once.
|
||||
+ return this.read(pos, regionfile);
|
||||
+ }
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.regionFile.toAbsolutePath());
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - recover from corrupt regionfile header
|
||||
break label43;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java
|
||||
index 95070af5e5bb7013ce7126ba9f725b43e3c4c749..97d4ae5619dcc0922e0381b1bb45a135f514e3af 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java
|
||||
@@ -14,7 +14,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.util.FastBufferedInputStream;
|
||||
|
||||
public class RegionFileVersion {
|
||||
- private static final Int2ObjectMap<RegionFileVersion> VERSIONS = new Int2ObjectOpenHashMap<>();
|
||||
+ public static final Int2ObjectMap<RegionFileVersion> VERSIONS = new Int2ObjectOpenHashMap<>(); // Paper - public
|
||||
public static final RegionFileVersion VERSION_GZIP = register(new RegionFileVersion(1, (inputStream) -> {
|
||||
return new FastBufferedInputStream(new GZIPInputStream(inputStream));
|
||||
}, (outputStream) -> {
|
|
@ -0,0 +1,343 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Thu, 11 Mar 2021 20:05:44 -0800
|
||||
Subject: [PATCH] Custom table implementation for blockstate state lookups
|
||||
|
||||
Testing some redstone intensive machines showed to bring about a 10%
|
||||
improvement.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..57d0cd3ad6f972e986c72a57f1a6e36003f190c2
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java
|
||||
@@ -0,0 +1,160 @@
|
||||
+package io.papermc.paper.util.table;
|
||||
+
|
||||
+import com.google.common.collect.Table;
|
||||
+import net.minecraft.world.level.block.state.StateHolder;
|
||||
+import net.minecraft.world.level.block.state.properties.Property;
|
||||
+import java.util.Collection;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+
|
||||
+public final class ZeroCollidingReferenceStateTable {
|
||||
+
|
||||
+ // upper 32 bits: starting index
|
||||
+ // lower 32 bits: bitset for contained ids
|
||||
+ protected final long[] this_index_table;
|
||||
+ protected final Comparable<?>[] this_table;
|
||||
+ protected final StateHolder<?, ?> this_state;
|
||||
+
|
||||
+ protected long[] index_table;
|
||||
+ protected StateHolder<?, ?>[][] value_table;
|
||||
+
|
||||
+ public ZeroCollidingReferenceStateTable(final StateHolder<?, ?> state, final Map<Property<?>, Comparable<?>> this_map) {
|
||||
+ this.this_state = state;
|
||||
+ this.this_index_table = this.create_table(this_map.keySet());
|
||||
+
|
||||
+ int max_id = -1;
|
||||
+ for (final Property<?> property : this_map.keySet()) {
|
||||
+ final int id = lookup_vindex(property, this.this_index_table);
|
||||
+ if (id > max_id) {
|
||||
+ max_id = id;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.this_table = new Comparable[max_id + 1];
|
||||
+ for (final Map.Entry<Property<?>, Comparable<?>> entry : this_map.entrySet()) {
|
||||
+ this.this_table[lookup_vindex(entry.getKey(), this.this_index_table)] = entry.getValue();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void loadInTable(final Table<Property<?>, Comparable<?>, StateHolder<?, ?>> table,
|
||||
+ final Map<Property<?>, Comparable<?>> this_map) {
|
||||
+ final Set<Property<?>> combined = new HashSet<>(table.rowKeySet());
|
||||
+ combined.addAll(this_map.keySet());
|
||||
+
|
||||
+ this.index_table = this.create_table(combined);
|
||||
+
|
||||
+ int max_id = -1;
|
||||
+ for (final Property<?> property : combined) {
|
||||
+ final int id = lookup_vindex(property, this.index_table);
|
||||
+ if (id > max_id) {
|
||||
+ max_id = id;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.value_table = new StateHolder[max_id + 1][];
|
||||
+
|
||||
+ final Map<Property<?>, Map<Comparable<?>, StateHolder<?, ?>>> map = table.rowMap();
|
||||
+ for (final Property<?> property : map.keySet()) {
|
||||
+ final Map<Comparable<?>, StateHolder<?, ?>> propertyMap = map.get(property);
|
||||
+
|
||||
+ final int id = lookup_vindex(property, this.index_table);
|
||||
+ final StateHolder<?, ?>[] states = this.value_table[id] = new StateHolder[property.getPossibleValues().size()];
|
||||
+
|
||||
+ for (final Map.Entry<Comparable<?>, StateHolder<?, ?>> entry : propertyMap.entrySet()) {
|
||||
+ if (entry.getValue() == null) {
|
||||
+ // TODO what
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ states[((Property)property).getIdFor(entry.getKey())] = entry.getValue();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ for (final Map.Entry<Property<?>, Comparable<?>> entry : this_map.entrySet()) {
|
||||
+ final Property<?> property = entry.getKey();
|
||||
+ final int index = lookup_vindex(property, this.index_table);
|
||||
+
|
||||
+ if (this.value_table[index] == null) {
|
||||
+ this.value_table[index] = new StateHolder[property.getPossibleValues().size()];
|
||||
+ }
|
||||
+
|
||||
+ this.value_table[index][((Property)property).getIdFor(entry.getValue())] = this.this_state;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ protected long[] create_table(final Collection<Property<?>> collection) {
|
||||
+ int max_id = -1;
|
||||
+ for (final Property<?> property : collection) {
|
||||
+ final int id = property.getId();
|
||||
+ if (id > max_id) {
|
||||
+ max_id = id;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ final long[] ret = new long[((max_id + 1) + 31) >>> 5]; // ceil((max_id + 1) / 32)
|
||||
+
|
||||
+ for (final Property<?> property : collection) {
|
||||
+ final int id = property.getId();
|
||||
+
|
||||
+ ret[id >>> 5] |= (1L << (id & 31));
|
||||
+ }
|
||||
+
|
||||
+ int total = 0;
|
||||
+ for (int i = 1, len = ret.length; i < len; ++i) {
|
||||
+ ret[i] |= (long)(total += Long.bitCount(ret[i - 1] & 0xFFFFFFFFL)) << 32;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ public Comparable<?> get(final Property<?> state) {
|
||||
+ final Comparable<?>[] table = this.this_table;
|
||||
+ final int index = lookup_vindex(state, this.this_index_table);
|
||||
+
|
||||
+ if (index < 0 || index >= table.length) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return table[index];
|
||||
+ }
|
||||
+
|
||||
+ public StateHolder<?, ?> get(final Property<?> property, final Comparable<?> with) {
|
||||
+ final int withId = ((Property)property).getIdFor(with);
|
||||
+ if (withId < 0) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ final int index = lookup_vindex(property, this.index_table);
|
||||
+ final StateHolder<?, ?>[][] table = this.value_table;
|
||||
+ if (index < 0 || index >= table.length) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ final StateHolder<?, ?>[] values = table[index];
|
||||
+
|
||||
+ if (withId >= values.length) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return values[withId];
|
||||
+ }
|
||||
+
|
||||
+ protected static int lookup_vindex(final Property<?> property, final long[] index_table) {
|
||||
+ final int id = property.getId();
|
||||
+ final long bitset_mask = (1L << (id & 31));
|
||||
+ final long lower_mask = bitset_mask - 1;
|
||||
+ final int index = id >>> 5;
|
||||
+ if (index >= index_table.length) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ final long index_value = index_table[index];
|
||||
+ final long contains_check = ((index_value & bitset_mask) - 1) >> (Long.SIZE - 1); // -1L if doesn't contain
|
||||
+
|
||||
+ // index = total bits set in lower table values (upper 32 bits of index_value) plus total bits set in lower indices below id
|
||||
+ // contains_check is 0 if the bitset had id set, else it's -1: so index is unaffected if contains_check == 0,
|
||||
+ // otherwise it comes out as -1.
|
||||
+ return (int)(((index_value >>> 32) + Long.bitCount(index_value & lower_mask)) | contains_check);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
||||
index ab712fd29b316e1235645bacaa79aa0a64d0bc00..340d0648fcf9b9749c4daa1c25a226b947707c3d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java
|
||||
@@ -39,11 +39,13 @@ public abstract class StateHolder<O, S> {
|
||||
private final ImmutableMap<Property<?>, Comparable<?>> values;
|
||||
private Table<Property<?>, Comparable<?>, S> neighbours;
|
||||
protected final MapCodec<S> propertiesCodec;
|
||||
+ protected final io.papermc.paper.util.table.ZeroCollidingReferenceStateTable optimisedTable; // Paper - optimise state lookup
|
||||
|
||||
protected StateHolder(O owner, ImmutableMap<Property<?>, Comparable<?>> entries, MapCodec<S> codec) {
|
||||
this.owner = owner;
|
||||
this.values = entries;
|
||||
this.propertiesCodec = codec;
|
||||
+ this.optimisedTable = new io.papermc.paper.util.table.ZeroCollidingReferenceStateTable(this, entries); // Paper - optimise state lookup
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> S cycle(Property<T> property) {
|
||||
@@ -84,11 +86,11 @@ public abstract class StateHolder<O, S> {
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> boolean hasProperty(Property<T> property) {
|
||||
- return this.values.containsKey(property);
|
||||
+ return this.optimisedTable.get(property) != null; // Paper - optimise state lookup
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> T getValue(Property<T> property) {
|
||||
- Comparable<?> comparable = this.values.get(property);
|
||||
+ Comparable<?> comparable = this.optimisedTable.get(property); // Paper - optimise state lookup
|
||||
if (comparable == null) {
|
||||
throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner);
|
||||
} else {
|
||||
@@ -97,24 +99,18 @@ public abstract class StateHolder<O, S> {
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>> Optional<T> getOptionalValue(Property<T> property) {
|
||||
- Comparable<?> comparable = this.values.get(property);
|
||||
+ Comparable<?> comparable = this.optimisedTable.get(property); // Paper - optimise state lookup
|
||||
return comparable == null ? Optional.empty() : Optional.of(property.getValueClass().cast(comparable));
|
||||
}
|
||||
|
||||
public <T extends Comparable<T>, V extends T> S setValue(Property<T> property, V value) {
|
||||
- Comparable<?> comparable = this.values.get(property);
|
||||
- if (comparable == null) {
|
||||
- throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + this.owner);
|
||||
- } else if (comparable == value) {
|
||||
- return (S)this;
|
||||
- } else {
|
||||
- S object = this.neighbours.get(property, value);
|
||||
- if (object == null) {
|
||||
- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
|
||||
- } else {
|
||||
- return object;
|
||||
- }
|
||||
+ // Paper start - optimise state lookup
|
||||
+ final S ret = (S)this.optimisedTable.get(property, value);
|
||||
+ if (ret == null) {
|
||||
+ throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value");
|
||||
}
|
||||
+ return ret;
|
||||
+ // Paper end - optimise state lookup
|
||||
}
|
||||
|
||||
public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> states) {
|
||||
@@ -133,7 +129,7 @@ public abstract class StateHolder<O, S> {
|
||||
}
|
||||
}
|
||||
|
||||
- this.neighbours = (Table<Property<?>, Comparable<?>, S>)(table.isEmpty() ? table : ArrayTable.create(table));
|
||||
+ this.neighbours = (Table<Property<?>, Comparable<?>, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
|
||||
index ff1a0d125edd2ea10c870cbb62ae9aa23644b6dc..233215280f8494dbc33a2fd0b14e37e59f1cb643 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/BooleanProperty.java
|
||||
@@ -7,6 +7,13 @@ import java.util.Optional;
|
||||
public class BooleanProperty extends Property<Boolean> {
|
||||
private final ImmutableSet<Boolean> values = ImmutableSet.of(true, false);
|
||||
|
||||
+ // Paper start - optimise iblockdata state lookup
|
||||
+ @Override
|
||||
+ public final int getIdFor(final Boolean value) {
|
||||
+ return value.booleanValue() ? 1 : 0;
|
||||
+ }
|
||||
+ // Paper end - optimise iblockdata state lookup
|
||||
+
|
||||
protected BooleanProperty(String name) {
|
||||
super(name, Boolean.class);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
|
||||
index 0bca0f971dac994bd8b6ecd87e8b33e26c0f18f9..edd3c745efb40ee79a1393199c7a27ddaa2f8026 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/EnumProperty.java
|
||||
@@ -15,6 +15,15 @@ public class EnumProperty<T extends Enum<T> & StringRepresentable> extends Prope
|
||||
private final ImmutableSet<T> values;
|
||||
private final Map<String, T> names = Maps.newHashMap();
|
||||
|
||||
+ // Paper start - optimise iblockdata state lookup
|
||||
+ private int[] idLookupTable;
|
||||
+
|
||||
+ @Override
|
||||
+ public final int getIdFor(final T value) {
|
||||
+ return this.idLookupTable[value.ordinal()];
|
||||
+ }
|
||||
+ // Paper end - optimise iblockdata state lookup
|
||||
+
|
||||
protected EnumProperty(String name, Class<T> type, Collection<T> values) {
|
||||
super(name, type);
|
||||
this.values = ImmutableSet.copyOf(values);
|
||||
@@ -28,6 +37,14 @@ public class EnumProperty<T extends Enum<T> & StringRepresentable> extends Prope
|
||||
this.names.put(string, enum_);
|
||||
}
|
||||
|
||||
+ // Paper start - optimise iblockdata state lookup
|
||||
+ int id = 0;
|
||||
+ this.idLookupTable = new int[type.getEnumConstants().length];
|
||||
+ java.util.Arrays.fill(this.idLookupTable, -1);
|
||||
+ for (final T value : this.getPossibleValues()) {
|
||||
+ this.idLookupTable[value.ordinal()] = id++;
|
||||
+ }
|
||||
+ // Paper end - optimise iblockdata state lookup
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
|
||||
index bdbe0362e49e73c05237f9f3143230e0b03e494e..8eb20ea852a8e89c431fea55a7b60833a6c8104f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/IntegerProperty.java
|
||||
@@ -11,6 +11,16 @@ public class IntegerProperty extends Property<Integer> {
|
||||
public final int min;
|
||||
public final int max;
|
||||
|
||||
+ // Paper start - optimise iblockdata state lookup
|
||||
+ @Override
|
||||
+ public final int getIdFor(final Integer value) {
|
||||
+ final int val = value.intValue();
|
||||
+ final int ret = val - this.min;
|
||||
+
|
||||
+ return ret | ((this.max - ret) >> 31);
|
||||
+ }
|
||||
+ // Paper end - optimise iblockdata state lookup
|
||||
+
|
||||
protected IntegerProperty(String name, int min, int max) {
|
||||
super(name, Integer.class);
|
||||
if (min < 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
|
||||
index a37424bbc6bee02354abaa793aa0865c556c6bbe..f923593bd336dd1a950ba61603d53edb3c9703eb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/properties/Property.java
|
||||
@@ -22,6 +22,17 @@ public abstract class Property<T extends Comparable<T>> {
|
||||
}, this::getName);
|
||||
private final Codec<Property.Value<T>> valueCodec = this.codec.xmap(this::value, Property.Value::value);
|
||||
|
||||
+ // Paper start - optimise iblockdata state lookup
|
||||
+ private static final java.util.concurrent.atomic.AtomicInteger ID_GENERATOR = new java.util.concurrent.atomic.AtomicInteger();
|
||||
+ private final int id = ID_GENERATOR.getAndIncrement();
|
||||
+
|
||||
+ public final int getId() {
|
||||
+ return this.id;
|
||||
+ }
|
||||
+
|
||||
+ public abstract int getIdFor(final T value);
|
||||
+ // Paper end - optimise state lookup
|
||||
+
|
||||
protected Property(String name, Class<T> type) {
|
||||
this.clazz = type;
|
||||
this.name = name;
|
|
@ -0,0 +1,297 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Thu, 26 Mar 2020 21:59:32 -0700
|
||||
Subject: [PATCH] Detail more information in watchdog dumps
|
||||
|
||||
- Dump position, world, velocity, and uuid for currently ticking entities
|
||||
- Dump player name, player uuid, position, and world for packet handling
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index 2195024a7b2626f4e6844db56071130226cf1364..92b36499c7b655b1b7d866fe116486962aef1803 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -475,9 +475,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
PacketListener packetlistener = this.packetListener;
|
||||
|
||||
if (packetlistener instanceof TickablePacketListener) {
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener);
|
||||
+ try { // Paper end - detailed watchdog information
|
||||
TickablePacketListener tickablepacketlistener = (TickablePacketListener) packetlistener;
|
||||
|
||||
tickablepacketlistener.tick();
|
||||
+ } finally { // Paper start - detailed watchdog information
|
||||
+ net.minecraft.network.protocol.PacketUtils.packetProcessing.pop();
|
||||
+ } // Paper start - detailed watchdog information
|
||||
}
|
||||
|
||||
if (!this.isConnected() && !this.disconnectionHandled) {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
index a34f22cadc09e53ea4de787b04d050b99dddbcac..c8012de68b997d6270ba4a5d79bc93c09ff4354f 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java
|
||||
@@ -15,6 +15,24 @@ public class PacketUtils {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ public static final java.util.concurrent.ConcurrentLinkedDeque<PacketListener> packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>();
|
||||
+ static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong();
|
||||
+
|
||||
+ public static long getTotalProcessedPackets() {
|
||||
+ return totalMainThreadPacketsProcessed.get();
|
||||
+ }
|
||||
+
|
||||
+ public static java.util.List<PacketListener> getCurrentPacketProcessors() {
|
||||
+ java.util.List<PacketListener> ret = new java.util.ArrayList<>(4);
|
||||
+ for (PacketListener listener : packetProcessing) {
|
||||
+ ret.add(listener);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
+
|
||||
public PacketUtils() {}
|
||||
|
||||
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, ServerLevel world) throws RunningOnDifferentThreadException {
|
||||
@@ -24,6 +42,8 @@ public class PacketUtils {
|
||||
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, BlockableEventLoop<?> engine) throws RunningOnDifferentThreadException {
|
||||
if (!engine.isSameThread()) {
|
||||
engine.executeIfPossible(() -> {
|
||||
+ packetProcessing.push(listener); // Paper - detailed watchdog information
|
||||
+ try { // Paper - detailed watchdog information
|
||||
if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590
|
||||
if (listener.getConnection().isConnected()) {
|
||||
co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings
|
||||
@@ -45,6 +65,12 @@ public class PacketUtils {
|
||||
} else {
|
||||
PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet);
|
||||
}
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ } finally {
|
||||
+ totalMainThreadPacketsProcessed.getAndIncrement();
|
||||
+ packetProcessing.pop();
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
|
||||
});
|
||||
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 53105ca96f5056adbba6a97ac428587e7c3b683a..a9b23308c89aef277394821cb883540a0c9e7056 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1002,7 +1002,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
}
|
||||
|
||||
+ // Paper start - log detailed entity tick information
|
||||
+ // TODO replace with varhandle
|
||||
+ static final java.util.concurrent.atomic.AtomicReference<Entity> currentlyTickingEntity = new java.util.concurrent.atomic.AtomicReference<>();
|
||||
+
|
||||
+ public static List<Entity> getCurrentlyTickingEntities() {
|
||||
+ Entity ticking = currentlyTickingEntity.get();
|
||||
+ List<Entity> ret = java.util.Arrays.asList(ticking == null ? new Entity[0] : new Entity[] { ticking });
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+ // Paper end - log detailed entity tick information
|
||||
+
|
||||
public void tickNonPassenger(Entity entity) {
|
||||
+ // Paper start - log detailed entity tick information
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
|
||||
+ try {
|
||||
+ if (currentlyTickingEntity.get() == null) {
|
||||
+ currentlyTickingEntity.lazySet(entity);
|
||||
+ }
|
||||
+ // Paper end - log detailed entity tick information
|
||||
++TimingHistory.entityTicks; // Paper - timings
|
||||
// Spigot start
|
||||
co.aikar.timings.Timing timer; // Paper
|
||||
@@ -1042,7 +1061,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.tickPassenger(entity, entity1);
|
||||
}
|
||||
// } finally { timer.stopTiming(); } // Paper - timings - move up
|
||||
-
|
||||
+ // Paper start - log detailed entity tick information
|
||||
+ } finally {
|
||||
+ if (currentlyTickingEntity.get() == entity) {
|
||||
+ currentlyTickingEntity.lazySet(null);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - log detailed entity tick information
|
||||
}
|
||||
|
||||
private void tickPassenger(Entity vehicle, Entity passenger) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 9567822f314cd3978ed63bb867e57b610d76228e..37123198bdf0188f59f289a31570663938fdc3c1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -971,7 +971,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.onGround;
|
||||
}
|
||||
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ public final Object posLock = new Object(); // Paper - log detailed entity tick information
|
||||
+
|
||||
+ private Vec3 moveVector;
|
||||
+ private double moveStartX;
|
||||
+ private double moveStartY;
|
||||
+ private double moveStartZ;
|
||||
+
|
||||
+ public final Vec3 getMoveVector() {
|
||||
+ return this.moveVector;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartX() {
|
||||
+ return this.moveStartX;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartY() {
|
||||
+ return this.moveStartY;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartZ() {
|
||||
+ return this.moveStartZ;
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
+
|
||||
public void move(MoverType movementType, Vec3 movement) {
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
+ synchronized (this.posLock) {
|
||||
+ this.moveStartX = this.getX();
|
||||
+ this.moveStartY = this.getY();
|
||||
+ this.moveStartZ = this.getZ();
|
||||
+ this.moveVector = movement;
|
||||
+ }
|
||||
+ try {
|
||||
+ // Paper end - detailed watchdog information
|
||||
if (this.noPhysics) {
|
||||
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
||||
} else {
|
||||
@@ -1144,6 +1179,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.level.getProfiler().pop();
|
||||
}
|
||||
}
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ } finally {
|
||||
+ synchronized (this.posLock) { // Paper
|
||||
+ this.moveVector = null;
|
||||
+ } // Paper
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
}
|
||||
|
||||
protected boolean isHorizontalCollisionMinor(Vec3 adjustedMovement) {
|
||||
@@ -3948,7 +3990,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void setDeltaMovement(Vec3 velocity) {
|
||||
+ synchronized (this.posLock) { // Paper
|
||||
this.deltaMovement = velocity;
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
public void setDeltaMovement(double x, double y, double z) {
|
||||
@@ -4024,7 +4068,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
// Paper end - fix MC-4
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
+ synchronized (this.posLock) { // Paper
|
||||
this.position = new Vec3(x, y, z);
|
||||
+ } // Paper
|
||||
int i = Mth.floor(x);
|
||||
int j = Mth.floor(y);
|
||||
int k = Mth.floor(z);
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index 7823e97add506d42161fd86f830e4d988b2113d8..d568fc92d03c313a782796cc720a1ebb1a5ad8be 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -22,6 +22,78 @@ public class WatchdogThread extends Thread
|
||||
private volatile long lastTick;
|
||||
private volatile boolean stopping;
|
||||
|
||||
+ // Paper start - log detailed tick information
|
||||
+ private void dumpEntity(net.minecraft.world.entity.Entity entity) {
|
||||
+ Logger log = Bukkit.getServer().getLogger();
|
||||
+ double posX, posY, posZ;
|
||||
+ net.minecraft.world.phys.Vec3 mot;
|
||||
+ double moveStartX, moveStartY, moveStartZ;
|
||||
+ net.minecraft.world.phys.Vec3 moveVec;
|
||||
+ synchronized (entity.posLock) {
|
||||
+ posX = entity.getX();
|
||||
+ posY = entity.getY();
|
||||
+ posZ = entity.getZ();
|
||||
+ mot = entity.getDeltaMovement();
|
||||
+ moveStartX = entity.getMoveStartX();
|
||||
+ moveStartY = entity.getMoveStartY();
|
||||
+ moveStartZ = entity.getMoveStartZ();
|
||||
+ moveVec = entity.getMoveVector();
|
||||
+ }
|
||||
+
|
||||
+ String entityType = net.minecraft.world.entity.EntityType.getKey(entity.getType()).toString();
|
||||
+ java.util.UUID entityUUID = entity.getUUID();
|
||||
+ net.minecraft.world.level.Level world = entity.level;
|
||||
+
|
||||
+ log.log(Level.SEVERE, "Ticking entity: " + entityType + ", entity class: " + entity.getClass().getName());
|
||||
+ log.log(Level.SEVERE, "Entity status: removed: " + entity.isRemoved() + ", valid: " + entity.valid + ", alive: " + entity.isAlive() + ", is passenger: " + entity.isPassenger());
|
||||
+ log.log(Level.SEVERE, "Entity UUID: " + entityUUID);
|
||||
+ log.log(Level.SEVERE, "Position: world: '" + (world == null ? "unknown world?" : world.getWorld().getName()) + "' at location (" + posX + ", " + posY + ", " + posZ + ")");
|
||||
+ log.log(Level.SEVERE, "Velocity: " + (mot == null ? "unknown velocity" : mot.toString()) + " (in blocks per tick)");
|
||||
+ log.log(Level.SEVERE, "Entity AABB: " + entity.getBoundingBox());
|
||||
+ if (moveVec != null) {
|
||||
+ log.log(Level.SEVERE, "Move call information: ");
|
||||
+ log.log(Level.SEVERE, "Start position: (" + moveStartX + ", " + moveStartY + ", " + moveStartZ + ")");
|
||||
+ log.log(Level.SEVERE, "Move vector: " + moveVec.toString());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void dumpTickingInfo() {
|
||||
+ Logger log = Bukkit.getServer().getLogger();
|
||||
+
|
||||
+ // ticking entities
|
||||
+ for (net.minecraft.world.entity.Entity entity : net.minecraft.server.level.ServerLevel.getCurrentlyTickingEntities()) {
|
||||
+ this.dumpEntity(entity);
|
||||
+ net.minecraft.world.entity.Entity vehicle = entity.getVehicle();
|
||||
+ if (vehicle != null) {
|
||||
+ log.log(Level.SEVERE, "Detailing vehicle for above entity:");
|
||||
+ this.dumpEntity(vehicle);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // packet processors
|
||||
+ for (net.minecraft.network.PacketListener packetListener : net.minecraft.network.protocol.PacketUtils.getCurrentPacketProcessors()) {
|
||||
+ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) {
|
||||
+ net.minecraft.server.level.ServerPlayer player = ((net.minecraft.server.network.ServerGamePacketListenerImpl)packetListener).player;
|
||||
+ long totalPackets = net.minecraft.network.protocol.PacketUtils.getTotalProcessedPackets();
|
||||
+ if (player == null) {
|
||||
+ log.log(Level.SEVERE, "Handling packet for player connection or ticking player connection (null player): " + packetListener);
|
||||
+ log.log(Level.SEVERE, "Total packets processed on the main thread for all players: " + totalPackets);
|
||||
+ } else {
|
||||
+ this.dumpEntity(player);
|
||||
+ net.minecraft.world.entity.Entity vehicle = player.getVehicle();
|
||||
+ if (vehicle != null) {
|
||||
+ log.log(Level.SEVERE, "Detailing vehicle for above entity:");
|
||||
+ this.dumpEntity(vehicle);
|
||||
+ }
|
||||
+ log.log(Level.SEVERE, "Total packets processed on the main thread for all players: " + totalPackets);
|
||||
+ }
|
||||
+ } else {
|
||||
+ log.log(Level.SEVERE, "Handling packet for connection: " + packetListener);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - log detailed tick information
|
||||
+
|
||||
private WatchdogThread(long timeoutTime, boolean restart)
|
||||
{
|
||||
super( "Paper Watchdog Thread" );
|
||||
@@ -120,6 +192,7 @@ public class WatchdogThread extends Thread
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
||||
com.destroystokyo.paper.io.chunk.ChunkTaskManager.dumpAllChunkLoadInfo(); // Paper
|
||||
+ this.dumpTickingInfo(); // Paper - log detailed tick information
|
||||
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( server.serverThread.getId(), Integer.MAX_VALUE ), log );
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
//
|
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 6 Jul 2020 22:48:48 -0700
|
||||
Subject: [PATCH] Manually inline methods in BlockPosition
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index e68cd32a7db88f29d3224b0908119232ab3cf71a..153451ecd5b3c8e8ecb2d5ec91ccd582d4300899 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -484,9 +484,9 @@ public class BlockPos extends Vec3i {
|
||||
}
|
||||
|
||||
public BlockPos.MutableBlockPos set(int x, int y, int z) {
|
||||
- this.setX(x);
|
||||
- this.setY(y);
|
||||
- this.setZ(z);
|
||||
+ this.x = x; // Paper - force inline
|
||||
+ this.y = y; // Paper - force inline
|
||||
+ this.z = z; // Paper - force inline
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -550,19 +550,19 @@ public class BlockPos extends Vec3i {
|
||||
// Paper start - comment out useless overrides @Override - TODO figure out why this is suddenly important to keep
|
||||
@Override
|
||||
public BlockPos.MutableBlockPos setX(int i) {
|
||||
- super.setX(i);
|
||||
+ this.x = i; // Paper
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos.MutableBlockPos setY(int i) {
|
||||
- super.setY(i);
|
||||
+ this.y = i; // Paper
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos.MutableBlockPos setZ(int i) {
|
||||
- super.setZ(i);
|
||||
+ this.z = i; // Paper
|
||||
return this;
|
||||
}
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
index 73b3c5f5c037fbe3f588f8f4b0113bef283632a4..c06c7da7de84bc764ea7b9612b3dc2303b49b22e 100644
|
||||
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
||||
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
@@ -19,9 +19,9 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
return IntStream.of(vec3i.getX(), vec3i.getY(), vec3i.getZ());
|
||||
});
|
||||
public static final Vec3i ZERO = new Vec3i(0, 0, 0);
|
||||
- private int x;
|
||||
- private int y;
|
||||
- private int z;
|
||||
+ protected int x; // Paper - protected
|
||||
+ protected int y; // Paper - protected
|
||||
+ protected int z; // Paper - protected
|
||||
|
||||
private static Function<Vec3i, DataResult<Vec3i>> checkOffsetAxes(int maxAbsValue) {
|
||||
return (vec) -> {
|
40
patches/server/0743-Distance-manager-tick-timings.patch
Normal file
40
patches/server/0743-Distance-manager-tick-timings.patch
Normal file
|
@ -0,0 +1,40 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sat, 18 Jul 2020 16:03:57 -0700
|
||||
Subject: [PATCH] Distance manager tick timings
|
||||
|
||||
Recently this has been taking up more time, so add a timings to
|
||||
really figure out how much.
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
index 5ec241d49ff5e3a161a39006f05823a5de847c5e..435b3b6d05e00803386d123c66f961c97da83d40 100644
|
||||
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -45,6 +45,7 @@ public final class MinecraftTimings {
|
||||
|
||||
public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
|
||||
public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
|
||||
+ public static final Timing distanceManagerTick = Timings.ofSafe("Distance Manager Tick"); // Paper - add timings for distance manager
|
||||
|
||||
public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks");
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 2de322ffc2eedae9efe39f9b771c447dd76f26fb..7524d9cf7184b345cbd7f0bd1d85601b75c29087 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -824,6 +824,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
public boolean runDistanceManagerUpdates() {
|
||||
if (distanceManager.delayDistanceManagerTick) return false; // Paper - Chunk priority
|
||||
if (this.chunkMap.unloadingPlayerChunk) { LOGGER.error("Cannot tick distance manager while unloading playerchunks", new Throwable()); throw new IllegalStateException("Cannot tick distance manager while unloading playerchunks"); } // Paper
|
||||
+ co.aikar.timings.MinecraftTimings.distanceManagerTick.startTiming(); try { // Paper - add timings for distance manager
|
||||
boolean flag = this.distanceManager.runAllUpdates(this.chunkMap);
|
||||
boolean flag1 = this.chunkMap.promoteChunkMap();
|
||||
|
||||
@@ -833,6 +834,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
this.clearCache();
|
||||
return true;
|
||||
}
|
||||
+ } finally { co.aikar.timings.MinecraftTimings.distanceManagerTick.stopTiming(); } // Paper - add timings for distance manager
|
||||
}
|
||||
|
||||
// Paper start
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Sun, 19 Jul 2020 15:17:01 -0700
|
||||
Subject: [PATCH] Name craft scheduler threads according to the plugin using
|
||||
them
|
||||
|
||||
Provides quick access to culprits running far more threads than
|
||||
they should be
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
|
||||
index 2f3e2a404f55f09ae4db8261e495275e31228034..6d66f83afbeb650b10669fd7eeb24a315951fa86 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java
|
||||
@@ -25,7 +25,10 @@ class CraftAsyncTask extends CraftTask {
|
||||
@Override
|
||||
public void run() {
|
||||
final Thread thread = Thread.currentThread();
|
||||
- synchronized (this.workers) {
|
||||
+ // Paper start - name threads according to running plugin
|
||||
+ final String nameBefore = thread.getName();
|
||||
+ thread.setName(nameBefore + " - " + this.getOwner().getName());
|
||||
+ try { synchronized (this.workers) { // Paper end - name threads according to running plugin
|
||||
if (getPeriod() == CraftTask.CANCEL) {
|
||||
// Never continue running after cancelled.
|
||||
// Checking this with the lock is important!
|
||||
@@ -92,6 +95,7 @@ class CraftAsyncTask extends CraftTask {
|
||||
}
|
||||
}
|
||||
}
|
||||
+ } finally { thread.setName(nameBefore); } // Paper - name worker thread according
|
||||
}
|
||||
|
||||
LinkedList<BukkitWorker> getWorkers() {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue