This commit is contained in:
Owen1212055 2023-06-08 03:20:03 -04:00
parent 6d118492b6
commit 91b45c49ce
No known key found for this signature in database
GPG Key ID: 2133292072886A30
59 changed files with 251 additions and 615 deletions

View File

@ -7,6 +7,8 @@ Subject: [PATCH] Always parse protochunk light sources unless it is marked as
Chunks not marked as lit will always go through the light engine,
so they should always have their block sources parsed.
Protochunks no longer serialize light sources like this.
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 34a1976699571608ae19e20dc1b6020759dad909..0ec80b83a99bfdb1f985045d98a81905a8a5a3ac 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java

View File

@ -19,10 +19,10 @@ index efbf77024d235d8af9f7efc938c17afd76a51b0c..670dcfa32d003870091b75937f1603a5
public static final Timing midTickChunkTasks = Timings.ofSafe("Mid Tick Chunk Tasks");
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
index 748cc48c6c42c694d1c9b685e96fbe6d8337d3f3..ad3560284ae79b9c6bbc8752be7d9d14b18e226e 100644
index 718c1dd7b52fb9a501d552fdbcb3f9ff79d127d8..3ea7a4b8de338610399d5fe4ff6cf07251916448 100644
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
@@ -922,7 +922,9 @@ public final class ChunkHolderManager {
@@ -1080,7 +1080,9 @@ public final class ChunkHolderManager {
}
public boolean processTicketUpdates() {

View File

@ -13,10 +13,10 @@ Paper recently reverted this optimisation, so it's been reintroduced
here.
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a0fc6c0dd9754e443a634917d66ac46e170d9dc6..54f3d4504929b90dc500207ed74e17ec1967ba48 100644
index 873a375946949a8f48109d5da925933f3956600b..2ed14a26084150fc67b031a7ab6b76fd8f0b075a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -372,6 +372,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -369,6 +369,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@Override
public final LevelChunk getChunk(int chunkX, int chunkZ) { // Paper - final to help inline

View File

@ -24,13 +24,13 @@ and an action can be defined: DROP or KICK
If interval or rate are less-than 0, the limit is ignored
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index b967c24e9ace2b6539e94bcc63b69e0c934a72be..ed27a0eb28b39f045064432107a86efc3b5927cd 100644
index b7b8ac7f0e93c183e0e7f39cb753f28daace843f..fde67116dde5dee59789de0e2ee70334db429559 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -156,6 +156,22 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
}
// Paper end - allow controlled flushing
@@ -120,6 +120,23 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
private static boolean enableExplicitFlush = Boolean.getBoolean("paper.explicit-flush");
// Paper end
+ // Paper start - packet limiter
+ protected final Object PACKET_LIMIT_LOCK = new Object();
+ protected final @Nullable io.papermc.paper.util.IntervalledCounter allPacketCounts = io.papermc.paper.configuration.GlobalConfiguration.get().packetLimiter.allPackets.isEnabled() ? new io.papermc.paper.util.IntervalledCounter(
@ -47,10 +47,11 @@ index b967c24e9ace2b6539e94bcc63b69e0c934a72be..ed27a0eb28b39f045064432107a86efc
+ this.stopReadingPackets = true;
+ }
+ // Paper end - packet limiter
+
public Connection(PacketFlow side) {
this.receiving = side;
@@ -240,6 +256,45 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
@@ -213,6 +230,45 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
if (this.channel.isOpen()) {

View File

@ -8,7 +8,7 @@ Lighting is purged on update anyways, so let's not add more
into the conversion process
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 2b7c41a176f354001bc9f2e1a08a4e3d1dc547b3..f89e31da562bb272b345b1446894ff64dcc3a079 100644
index 2d93251abb1018381cf00dbbb120c8ea036710c6..6916255b55a31ddd5bc32ec47f0d5ebb417be738 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
@@ -51,6 +51,7 @@ public class ChunkStorage implements AutoCloseable {

View File

@ -22,10 +22,10 @@ With this change I could get all 200 on at 0ms ping.
So in general this patch should reduce Netty I/O thread load.
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index ebd0da4f87c74f12d702e1ae4f3206885272e4f7..ca84eddbdb1e198b899750e5f6b3eafd25ce970f 100644
index 371f7e71610ddfbdb32dcd493f15d6ff9b90326e..42526088af333f818b02c80a3f8aa890ab78f6fb 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -805,7 +805,24 @@ public class ServerChunkCache extends ChunkSource {
@@ -807,7 +807,24 @@ public class ServerChunkCache extends ChunkSource {
this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
gameprofilerfiller.pop();
// Paper end - use set of chunks requiring updates, rather than iterating every single one loaded

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Don't lookup fluid state when raytracing
Just use the iblockdata already retrieved, removes a getType call.
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index 5ed0dbed49db210e54cf2ece3e8605feb956bc69..77386f6c4932df80f91fc01358014239ffea43ba 100644
index 89aadd30c1973cf45c5c05fd12462e04b0b05c97..04194b5d5560e3620131c2f5cdea84ff814a4c25 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -84,7 +84,7 @@ public interface BlockGetter extends LevelHeightAccessor {
@@ -79,7 +79,7 @@ public interface BlockGetter extends LevelHeightAccessor {
return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
}
// Paper end

View File

@ -9,15 +9,15 @@ Configurable under
`send-full-pos-for-hard-colliding-entities`
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index f9fc646811a3952065d1b9fc74ff7a10ae495c32..6dddd4eb8de9a08461245e35e65d4106f4e8e729 100644
index c41f06c82d2db758d8a91317ef21eb2f5eb76a49..09f6948a52721b27ccd7c761a7efd09bfd7a183c 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -184,7 +184,7 @@ public class ServerEntity {
@@ -180,7 +180,7 @@ public class ServerEntity {
long i1 = this.positionCodec.encodeZ(vec3d);
boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
- if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) {
+ if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround() && !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
- if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) {
+ if (!flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()&& !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) {
if (flag2) {
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.isOnGround());
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.onGround());

View File

@ -9,10 +9,10 @@ easy win. The remaining problems with this function
are mostly with the block getting itself.
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index 77386f6c4932df80f91fc01358014239ffea43ba..2ee9e8e3c1a28c1823de8e1fe421cc1f3e72f384 100644
index 04194b5d5560e3620131c2f5cdea84ff814a4c25..0e8746759752b692668886370181aa5db1fd0bb0 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -84,6 +84,7 @@ public interface BlockGetter extends LevelHeightAccessor {
@@ -79,6 +79,7 @@ public interface BlockGetter extends LevelHeightAccessor {
return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
}
// Paper end

View File

@ -7,10 +7,10 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index b0cfdead8a345eaab7747ed6b84271e8e09d1713..d9358311fde6a0d9040d55cab907e8833d219c3a 100644
index 03b802f9f6e31b1ab23af0ff7b235f64c72ec462..84dfa7efa4be86558c38ee9e6f70f87b5638173a 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1408,7 +1408,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1343,7 +1343,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity;
private final int range;
SectionPos lastSectionPos;

View File

@ -7,10 +7,10 @@ Apparently the abstract block iteration was taking about
75% of the method call.
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index e0aa9a57d6a5993d7333b7685b6fa1b50bc11ea0..34d744837e599633a3c2c0b72f253bb0e157f226 100644
index b78a65ed6f632093eb34872e07d0835e766101e2..552d8c8f3f56bfccd25d11488ed7ec1644a92f47 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -143,19 +143,27 @@ public class FarmBlock extends Block {
@@ -142,19 +142,27 @@ public class FarmBlock extends Block {
}
private static boolean isNearWater(LevelReader world, BlockPos pos) {

View File

@ -90,10 +90,10 @@ index 0000000000000000000000000000000000000000..7d93652c1abbb6aee6eb7c26cf35d4d0
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b40b452bf1 100644
index f8bcf1239c18a6334936cec483f2ae316429a894..b1cc896a3f5d7e59a15969308d78d2ef036b0cb1 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -704,6 +704,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -764,6 +764,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
entityplayer.stopSleepInBed(false, false);
});
}
@ -104,7 +104,7 @@ index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b4
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
ChunkPos chunkcoordintpair = chunk.getPos();
@@ -713,10 +717,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -773,10 +777,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
ProfilerFiller gameprofilerfiller = this.getProfiler();
gameprofilerfiller.push("thunder");
@ -117,8 +117,8 @@ index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b4
if (this.isRainingAt(blockposition)) {
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01D) && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper
@@ -746,17 +750,25 @@ public class ServerLevel extends Level implements WorldGenLevel {
int l;
@@ -807,16 +811,25 @@ public class ServerLevel extends Level implements WorldGenLevel {
int i1;
if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow
- blockposition = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.getBlockRandomPos(j, 0, k, 15));
@ -141,13 +141,13 @@ index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b4
}
if (flag) {
int i1 = this.getGameRules().getInt(GameRules.RULE_SNOW_ACCUMULATION_HEIGHT);
l = this.getGameRules().getInt(GameRules.RULE_SNOW_ACCUMULATION_HEIGHT);
+
+ blockposition.setY(normalY); // Paper
if (i1 > 0 && biomebase.shouldSnow(this, blockposition)) {
if (l > 0 && biomebase.shouldSnow(this, blockposition)) {
BlockState iblockdata = this.getBlockState(blockposition);
@@ -772,51 +784,54 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -832,51 +845,54 @@ public class ServerLevel extends Level implements WorldGenLevel {
org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
}
}
@ -172,19 +172,19 @@ index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b4
timings.chunkTicksBlocks.startTiming(); // Paper
if (randomTickSpeed > 0) {
- LevelChunkSection[] achunksection = chunk.getSections();
- int j1 = achunksection.length;
-
- for (int k1 = 0; k1 < j1; ++k1) {
- LevelChunkSection chunksection = achunksection[k1];
- for (int j1 = 0; j1 < achunksection.length; ++j1) {
- LevelChunkSection chunksection = achunksection[j1];
-
- if (chunksection.isRandomlyTicking()) {
- int l1 = chunksection.bottomBlockY();
- l = chunk.getSectionYFromSectionIndex(j1);
- int k1 = SectionPos.sectionToBlockCoord(l);
-
- for (l = 0; l < randomTickSpeed; ++l) {
- BlockPos blockposition2 = this.getBlockRandomPos(j, l1, k, 15);
- for (i1 = 0; i1 < randomTickSpeed; ++i1) {
- BlockPos blockposition2 = this.getBlockRandomPos(j, k1, k, 15);
-
- gameprofilerfiller.push("randomTick");
- BlockState iblockdata3 = chunksection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - l1, blockposition2.getZ() - k);
- BlockState iblockdata3 = chunksection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - k1, blockposition2.getZ() - k);
+ LevelChunkSection[] sections = chunk.getSections();
+ int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this);
+ for (int sectionIndex = 0; sectionIndex < sections.length; ++sectionIndex) {
@ -231,11 +231,11 @@ index 1f683d734b9e272c8f4c48d922f3dcd12d0ffd1a..9523f6acd2c86892b390e14aaab628b4
gameprofilerfiller.pop();
}
diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java
index 62251727788d48a461ea6f7945771d7d6bdc7282..106610ccc74b70b557b01c61262d56c4f1147acf 100644
index 68648c5a5e3ff079f832092af0f2f801c42d1ede..8bafd5fd7499ba4a04bf706cfd1e156073716e21 100644
--- a/src/main/java/net/minecraft/util/BitStorage.java
+++ b/src/main/java/net/minecraft/util/BitStorage.java
@@ -20,4 +20,15 @@ public interface BitStorage {
void unpack(int[] is);
void unpack(int[] out);
BitStorage copy();
+
@ -251,7 +251,7 @@ index 62251727788d48a461ea6f7945771d7d6bdc7282..106610ccc74b70b557b01c61262d56c4
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
index 9b81ce9d85cba07e9752c29fb5a842c4b00aa873..36e33923bf48e56c743ed043bcbc66bc32f0422f 100644
index 2b3fd62dca2d1475075b5dcde56cea85b749cb44..e4d0d7e8fc58b8f9f614d74a141e452166e0364c 100644
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
@@ -124,6 +124,28 @@ public class SimpleBitStorage implements BitStorage {
@ -284,7 +284,7 @@ index 9b81ce9d85cba07e9752c29fb5a842c4b00aa873..36e33923bf48e56c743ed043bcbc66bc
public void getAll(IntConsumer action) {
int i = 0;
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
index 9686ce7536c9924b1b2aced4f013f46759cbc72e..5d8e9bdf5538b19681f21949368d862fab8a89ad 100644
index f0f764f36fb92c64ab2dc8a0a50c3f48321c3c9a..311625277a26c9c187025a1036978229241b965f 100644
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
@@ -46,6 +46,15 @@ public class ZeroBitStorage implements BitStorage {
@ -304,7 +304,7 @@ index 9686ce7536c9924b1b2aced4f013f46759cbc72e..5d8e9bdf5538b19681f21949368d862f
public void getAll(IntConsumer action) {
for(int i = 0; i < this.size; ++i) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
index b03c919edc33f308409ceeea0dd1064d1c6d7906..1c2f927974aab4d9751088449edbc777677d6cd0 100644
index 99fc97051c61ac8d08afdc0ea4845e96705e243b..c48bf4ca76f70d878378fc43c8270de5c3332824 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
@@ -84,7 +84,7 @@ public class Turtle extends Animal {
@ -317,10 +317,10 @@ index b03c919edc33f308409ceeea0dd1064d1c6d7906..1c2f927974aab4d9751088449edbc777
public BlockPos getHomePos() {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 54f3d4504929b90dc500207ed74e17ec1967ba48..b8c097c52cdc2af9bc05cfb5cfd646bb3bfb664e 100644
index 2ed14a26084150fc67b031a7ab6b76fd8f0b075a..4847b6358e823bd53ecfaf7d82ed9e36d45b1233 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1371,10 +1371,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1293,10 +1293,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract RecipeManager getRecipeManager();
public BlockPos getBlockRandomPos(int x, int y, int z, int l) {
@ -341,18 +341,18 @@ index 54f3d4504929b90dc500207ed74e17ec1967ba48..b8c097c52cdc2af9bc05cfb5cfd646bb
public boolean noSave() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index 8c8445af8a2fe684fdbb468f8d8605d44a803758..c7e2796e136ee8fb7d7e438a7fc59826c05b761b 100644
index 789664d53584c7d958572c63db22f904fb411a58..5d53b09e19b664fad337ea5098bf9cf41a7168f8 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -27,6 +27,7 @@ public class LevelChunkSection {
@@ -25,6 +25,7 @@ public class LevelChunkSection {
public final PalettedContainer<BlockState> states;
// CraftBukkit start - read/write
private PalettedContainer<Holder<Biome>> biomes;
+ public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
public LevelChunkSection(int i, PalettedContainer<BlockState> datapaletteblock, PalettedContainer<Holder<Biome>> palettedcontainerro) {
public LevelChunkSection(PalettedContainer<BlockState> datapaletteblock, PalettedContainer<Holder<Biome>> palettedcontainerro) {
// CraftBukkit end
@@ -85,6 +86,9 @@ public class LevelChunkSection {
@@ -74,6 +75,9 @@ public class LevelChunkSection {
--this.nonEmptyBlockCount;
if (iblockdata1.isRandomlyTicking()) {
--this.tickingBlockCount;
@ -362,7 +362,7 @@ index 8c8445af8a2fe684fdbb468f8d8605d44a803758..c7e2796e136ee8fb7d7e438a7fc59826
}
}
@@ -96,6 +100,9 @@ public class LevelChunkSection {
@@ -85,6 +89,9 @@ public class LevelChunkSection {
++this.nonEmptyBlockCount;
if (state.isRandomlyTicking()) {
++this.tickingBlockCount;
@ -372,7 +372,7 @@ index 8c8445af8a2fe684fdbb468f8d8605d44a803758..c7e2796e136ee8fb7d7e438a7fc59826
}
}
@@ -127,40 +134,31 @@ public class LevelChunkSection {
@@ -112,40 +119,31 @@ public class LevelChunkSection {
}
public void recalcBlockCounts() {
@ -421,9 +421,9 @@ index 8c8445af8a2fe684fdbb468f8d8605d44a803758..c7e2796e136ee8fb7d7e438a7fc59826
-
}
- }
- a a0 = new a();
-
- a a0 = new a();
- this.states.count(a0);
- this.nonEmptyBlockCount = (short) a0.nonEmptyBlockCount;
- this.tickingBlockCount = (short) a0.tickingBlockCount;
@ -434,10 +434,10 @@ index 8c8445af8a2fe684fdbb468f8d8605d44a803758..c7e2796e136ee8fb7d7e438a7fc59826
public PalettedContainer<BlockState> getStates() {
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 4cbceb1c18dbee75ac5154ff0c15a4e79bd31575..7c770d131d39da6900fdd22df36707d5f43e8cd0 100644
index a8dc502fffdce89c44ec16cb158b04c30fb1a9cf..f4658eea741bed1c80f8aca7dc365b897b698cd4 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -387,6 +387,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
@@ -315,6 +315,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
}
}

View File

@ -9,10 +9,10 @@ since the penalty of a map lookup could outweigh the benefits of
searching less players (as it basically did in the outside range patch).
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 0f2590501d742b1f5a410d45c7781bd18b4a4525..904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e 100644
index 3914fae62d3e0c0a9aeb8fd2bd48e76889c25a3a..25f983442b844465bde333131972d15df8e14415 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -93,6 +93,12 @@ public class ChunkHolder {
@@ -96,6 +96,12 @@ public class ChunkHolder {
this.chunkMap.needsChangeBroadcasting.add(this);
}
// Paper end - optimise chunk tick iteration
@ -25,7 +25,7 @@ index 0f2590501d742b1f5a410d45c7781bd18b4a4525..904fcdeb7937d36208cc9a8d5eca9ef3
}
public void onChunkRemove() {
@@ -105,6 +111,12 @@ public class ChunkHolder {
@@ -108,6 +114,12 @@ public class ChunkHolder {
this.chunkMap.needsChangeBroadcasting.remove(this);
}
// Paper end - optimise chunk tick iteration
@ -39,10 +39,10 @@ index 0f2590501d742b1f5a410d45c7781bd18b4a4525..904fcdeb7937d36208cc9a8d5eca9ef3
// Paper end
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index d9358311fde6a0d9040d55cab907e8833d219c3a..95c50a36dc1e03ae8ab8ca89a96d1ea56da8d94c 100644
index 84dfa7efa4be86558c38ee9e6f70f87b5638173a..c2dec99102fa4c64c3c874f725cdc65845cd98d2 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -159,6 +159,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -157,6 +157,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new ReferenceOpenHashSet<>();
// Paper - rewrite chunk system
@ -55,15 +55,15 @@ index d9358311fde6a0d9040d55cab907e8833d219c3a..95c50a36dc1e03ae8ab8ca89a96d1ea5
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@@ -211,6 +217,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
@@ -184,6 +190,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
}
// Paper end - use distance map to optimise entity tracker
// Paper end - per player mob spawning
+ this.playerGeneralAreaMap.add(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
}
void removePlayerFromDistanceMaps(ServerPlayer player) {
@@ -220,6 +227,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -193,6 +200,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player);
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -71,15 +71,15 @@ index d9358311fde6a0d9040d55cab907e8833d219c3a..95c50a36dc1e03ae8ab8ca89a96d1ea5
// Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.remove(player);
@@ -251,6 +259,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
@@ -211,6 +219,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
}
// Paper end - use distance map to optimise entity tracker
// Paper end - per player mob spawning
+ this.playerGeneralAreaMap.update(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
}
// Paper end
// Paper start
@@ -408,6 +417,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -329,6 +338,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
});
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -104,10 +104,10 @@ index d9358311fde6a0d9040d55cab907e8833d219c3a..95c50a36dc1e03ae8ab8ca89a96d1ea5
protected ChunkGenerator generator() {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 9523f6acd2c86892b390e14aaab628b40b452bf1..a3e8765e00ca816781441448d8bd4ac3a8364b6d 100644
index b1cc896a3f5d7e59a15969308d78d2ef036b0cb1..4bec4a6955d6c38c8bd8fb9a10d153209d693a01 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -442,6 +442,84 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -481,6 +481,84 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
// Paper end
@ -190,9 +190,9 @@ index 9523f6acd2c86892b390e14aaab628b40b452bf1..a3e8765e00ca816781441448d8bd4ac3
+ // Paper end - optimise get nearest players for entity AI
+
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
@@ -546,6 +624,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -606,6 +684,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
public void tick(BooleanSupplier shouldKeepTicking) {
@ -208,28 +208,28 @@ index 9523f6acd2c86892b390e14aaab628b40b452bf1..a3e8765e00ca816781441448d8bd4ac3
this.handlingTick = true;
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 83b1bed5bb6588ad009727e473337eebaf385cfa..02cb6b8c1d59855ff4a8aad3024fe12007eca0ee 100644
index b6e48531a2a1316eef786e0476574eb1c3c29a9e..e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -855,7 +855,12 @@ public abstract class Mob extends LivingEntity implements Targeting {
if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
@@ -858,7 +858,12 @@ public abstract class Mob extends LivingEntity implements Targeting {
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
this.discard();
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
- Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper
- Player entityhuman = this.level().findNearbyPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper
+ // Paper start - optimise checkDespawn
+ Player entityhuman = this.level.findNearbyPlayer(this, level.paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).hard() + 1, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper
+ Player entityhuman = this.level().findNearbyPlayer(this, level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).hard() + 1, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper
+ if (entityhuman == null) {
+ entityhuman = ((ServerLevel)this.level).playersAffectingSpawning.isEmpty() ? null : ((ServerLevel)this.level).playersAffectingSpawning.get(0);
+ entityhuman = ((ServerLevel)this.level()).playersAffectingSpawning.isEmpty() ? null : ((ServerLevel)this.level()).playersAffectingSpawning.get(0);
+ }
+ // Paper end - optimise checkDespawn
if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index b8c097c52cdc2af9bc05cfb5cfd646bb3bfb664e..a84f039390afe11d96b24a5c82312e1888311ec9 100644
index 4847b6358e823bd53ecfaf7d82ed9e36d45b1233..799d31874be8a7498e71e7e01f84aa81a7f1eed4 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -208,6 +208,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -206,6 +206,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.getChunkIfLoaded(chunkX, chunkZ) != null;
}
// Paper end
@ -300,7 +300,7 @@ index b8c097c52cdc2af9bc05cfb5cfd646bb3bfb664e..a84f039390afe11d96b24a5c82312e18
public abstract ResourceKey<LevelStem> getTypeKey();
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index 906def91bba96bab7c7aea9b87d9ec56374e6588..15d266fc97eb73338f4f6fb2cfe25d6861e79810 100644
index d4f99f4592a86e2d8344bc2c44711fef1543acdf..089dd93d4cd4c1f72e63c4944b3b82c1e2ba732d 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -260,7 +260,7 @@ public final class NaturalSpawner {
@ -322,10 +322,10 @@ index 906def91bba96bab7c7aea9b87d9ec56374e6588..15d266fc97eb73338f4f6fb2cfe25d68
private static Boolean isValidSpawnPostitionForType(ServerLevel world, MobCategory group, StructureManager structureAccessor, ChunkGenerator chunkGenerator, MobSpawnSettings.SpawnerData spawnEntry, BlockPos.MutableBlockPos pos, double squaredDistance) { // Paper
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 73a3f9eae86df8e9afd08ee9da4c1b8e16dededd..d190bad5d287766ed4165ed827d9901a9d878687 100644
index 72da008040147bc080a3e61b926a9afaaca390dd..7568baab4bec3ded6456332ed0f6a20e2721b03f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -262,6 +262,98 @@ public class LevelChunk extends ChunkAccess {
@@ -221,6 +221,98 @@ public class LevelChunk extends ChunkAccess {
}
}
// Paper end

View File

@ -5,12 +5,12 @@ Subject: [PATCH] Use Velocity compression and cipher natives
diff --git a/build.gradle.kts b/build.gradle.kts
index 719f4b4bff2ab651156f17e27412ae8b0e9e5d02..6d429252023f84d0d512e68a6a3112fa4e27a83f 100644
index bc71323234b69a07ac84703c04734711ca0dd113..e1e8f7c42f5e68da25b11c4cfadd67425395e558 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -31,6 +31,11 @@ dependencies {
runtimeOnly("org.xerial:sqlite-jdbc:3.41.2.2")
runtimeOnly("com.mysql:mysql-connector-j:8.0.32")
runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.0")
runtimeOnly("com.mysql:mysql-connector-j:8.0.33")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
+ // Paper start - Use Velocity cipher
+ implementation("com.velocitypowered:velocity-native:3.1.2-SNAPSHOT") {
@ -18,8 +18,8 @@ index 719f4b4bff2ab651156f17e27412ae8b0e9e5d02..6d429252023f84d0d512e68a6a3112fa
+ }
+ // Paper end
runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.5")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.2")
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.10")
diff --git a/src/main/java/net/minecraft/network/CipherDecoder.java b/src/main/java/net/minecraft/network/CipherDecoder.java
index 778beb445eac5769b9e4e07b4d1294c50ae2602b..c712fb8193115e1ab71b5e40fb0ccb9413062b03 100644
--- a/src/main/java/net/minecraft/network/CipherDecoder.java
@ -268,10 +268,10 @@ index 792883afe53d2b7989c25a81c2f9a639d5e21d20..c04379ca8a4db0f4de46ad2b3b338431
return this.threshold;
}
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 9b46c1068b7b52f735423fc255ae6e949dd5cb0b..f9e10bf048929886db3c414038d2c7e9f84226a6 100644
index fde67116dde5dee59789de0e2ee70334db429559..f1d4d8001b44ded431ecfccafd7cefee6a552709 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -710,11 +710,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -513,11 +513,28 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
return networkmanager;
}
@ -304,7 +304,7 @@ index 9b46c1068b7b52f735423fc255ae6e949dd5cb0b..f9e10bf048929886db3c414038d2c7e9
public boolean isEncrypted() {
return this.encrypted;
@@ -743,16 +760,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -549,16 +566,17 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) {
if (compressionThreshold >= 0) {
@ -325,10 +325,10 @@ index 9b46c1068b7b52f735423fc255ae6e949dd5cb0b..f9e10bf048929886db3c414038d2c7e9
this.channel.pipeline().fireUserEventTriggered(io.papermc.paper.network.ConnectionEvent.COMPRESSION_THRESHOLD_SET); // Paper
} else {
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
index 838244e3680ea6020701e10bafbde7f52976eaa1..e5e2f763d9b4b955df79ea0c4c79565be1fe59f0 100644
index d86830ea180bebb409fc20ed43dd25cd0856f623..14f037e721ac8ba885536cab43d3d398b011a397 100644
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -103,6 +103,11 @@ public class ServerConnectionListener {
@@ -101,6 +101,11 @@ public class ServerConnectionListener {
ServerConnectionListener.LOGGER.info("Using default channel type");
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Reduce worldgen thread worker count for low core count CPUs
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index f4935f7fc3cbd6ba8f079def43bd735364a2ce87..0d61682b91b38500e755ded2226cd30f3a16af5a 100644
index 5579dad0ba8f2e4ce43883e7d36059c2a2bd1b83..fcade0a121f155dbf4f5f8af66240923d8da460d 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -146,7 +146,19 @@ public class Util {
@@ -147,7 +147,19 @@ public class Util {
private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
// Paper start - use simpler thread pool that allows 1 thread

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Fix Bukkit NamespacedKey shenanigans
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
index 88e32ed64f90bfd277dac84ba4bd84f0d943f5f8..d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb 100644
index 9ca389ca789dc54bba3542cac0aac2e1dc66c870..15173e715fa36546820d930a46e0f0c493d07cfc 100644
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fix merchant inventory not closing on entity removal
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a3e8765e00ca816781441448d8bd4ac3a8364b6d..66b1ef69fe48340b5ccebd845b39f898515ff117 100644
index 4bec4a6955d6c38c8bd8fb9a10d153209d693a01..b89544fdfceee67fb452c37294131efca007e2fe 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2587,6 +2587,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2656,6 +2656,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Spigot end
// Spigot Start
if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Don't respond to ServerboundCommandSuggestionPacket when
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index f41c376b0f6d858fabe46834fff5049da48c732e..a980f5aacba4dbf64b75663b75e69a88528876f1 100644
index ee5f58ae4c276b4529d7dd35aa5cfa515e058d77..2b6e315d275cf5e303663c175745a5fe2e35969f 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -839,6 +839,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -847,6 +847,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
// Paper end
// CraftBukkit end

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Ensure valid vehicle status
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index e9e30baefc1feec81fbe866cf5b6e5133c848112..a3f6a5477b264ec13d9f8ab863798b20faace226 100644
index c9b07d321a22060086a8608c6ff5f8f0608d988f..768f9ef872ed1bb3157c6fa122e1e3d76417a4b6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -527,7 +527,7 @@ public class ServerPlayer extends Player {
@@ -568,7 +568,7 @@ public class ServerPlayer extends Player {
}
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Prevent softlocked end exit portal generation
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
index abd13cefd3d8409e1ef8ea70d92877f76f89da6c..230de1c71b0a6d6370df2fedb337cf0e332a7596 100644
index eab54838ba540f41cc59a359dd00ba80d82c771e..17b5386d147dc007c487da3561ea5a5d3cd6db22 100644
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
@@ -419,6 +419,11 @@ public class EndDragonFight {
@@ -412,6 +412,11 @@ public class EndDragonFight {
}
}

View File

@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Mon, 21 Jun 2021 23:21:58 -0400
Subject: [PATCH] Preserve overstacked loot
Preserves overstacked items in loot tables, such as shulker box drops, to prevent the items
from being deleted (as they'd overflow past the bounds of the container)-- or worse, causing
chunk bans via the large amount of NBT created by unstacking the items.
Fixes GH-5140 and GH-4748.
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
index d123bd7095355dff84b9859657e24258c5a204e3..e46a0afa45ee771a0114703acc314d7cf8e8ffed 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
@@ -62,9 +62,10 @@ public class LootTable {
}
public static Consumer<ItemStack> createStackSplitter(ServerLevel world, Consumer<ItemStack> consumer) {
+ boolean skipSplitter = world != null && !world.paperConfig().fixes.splitOverstackedLoot; // Paper - preserve overstacked items
return (itemstack) -> {
if (itemstack.isItemEnabled(world.enabledFeatures())) {
- if (itemstack.getCount() < itemstack.getMaxStackSize()) {
+ if (skipSplitter || itemstack.getCount() < itemstack.getMaxStackSize()) { // Paper - preserve overstacked items
consumer.accept(itemstack);
} else {
int i = itemstack.getCount();

View File

@ -8,10 +8,10 @@ This is because bukkit uses a separate head rotation field for yaw.
This issue only applies to players.
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6da3b1d6e09f5c8c09234b4da0aeaba5ab632dd7..1a71fe0113a1109da7b0f11a879b33a7e694b783 100644
index eb9f56de921edfefc0655be47449ffbc97145e07..d776c95e7c0752cdfcc44fb17509d5dc8605d8a8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1784,6 +1784,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1870,6 +1870,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setXRot(Mth.clamp(pitch, -90.0F, 90.0F) % 360.0F);
this.yRotO = this.getYRot();
this.xRotO = this.getXRot();
@ -19,7 +19,7 @@ index 6da3b1d6e09f5c8c09234b4da0aeaba5ab632dd7..1a71fe0113a1109da7b0f11a879b33a7
}
public void absMoveTo(double x, double y, double z) {
@@ -1822,6 +1823,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1908,6 +1909,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setXRot(pitch);
this.setOldPosAndRot();
this.reapplyPosition();

View File

@ -13,10 +13,10 @@ the material type of the block at that location.
public net.minecraft.world.level.block.entity.BlockEntityType validBlocks
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index 5768ff2c3e15c038d132c7ad391332fb36251871..52a5b7c20dda9ad18cdeb70952e7385b0966b161 100644
index d156f7cc71050f13b2feca00c52ca6b64572b60e..e3557f4c8cee7c88b3e352cd246078da7762effc 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -248,7 +248,7 @@ public abstract class BlockEntity {
@@ -247,7 +247,7 @@ public abstract class BlockEntity {
// Paper end
if (this.level == null) return null;
org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ());
@ -39,7 +39,7 @@ index 87c25170fbe8b0591d452612496ee1a627138de7..a2894f02ceb7c58f6eafe055e1ff47b1
private final T tileEntity;
private final T snapshot;
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e4f2724c8 100644
index 17e1131c79ad140c0803a914621ce7924f0f2a6d..d7663b902b768030008b28f9a8f6dd324a30e38f 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
@@ -19,6 +19,7 @@ import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
@ -48,9 +48,9 @@ index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e
import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.block.entity.BlockEntityType; // Paper
import net.minecraft.world.level.block.entity.BrewingStandBlockEntity;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
@@ -112,223 +113,61 @@ public final class CraftBlockStates {
import net.minecraft.world.level.block.entity.BrushableBlockEntity;
import net.minecraft.world.level.block.entity.CalibratedSculkSensorBlockEntity;
@@ -113,225 +114,61 @@ public final class CraftBlockStates {
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
@Override
public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) {
@ -271,12 +271,14 @@ index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e
- register(Material.LECTERN, CraftLectern.class, CraftLectern::new, LecternBlockEntity::new);
- register(Material.MOVING_PISTON, CraftMovingPiston.class, CraftMovingPiston::new, PistonMovingBlockEntity::new);
- register(Material.SCULK_CATALYST, CraftSculkCatalyst.class, CraftSculkCatalyst::new, SculkCatalystBlockEntity::new);
- register(Material.CALIBRATED_SCULK_SENSOR, CraftCalibratedSculkSensor.class, CraftCalibratedSculkSensor::new, CalibratedSculkSensorBlockEntity::new);
- register(Material.SCULK_SENSOR, CraftSculkSensor.class, CraftSculkSensor::new, SculkSensorBlockEntity::new);
- register(Material.SCULK_SHRIEKER, CraftSculkShrieker.class, CraftSculkShrieker::new, SculkShriekerBlockEntity::new);
- register(Material.SMOKER, CraftSmoker.class, CraftSmoker::new, SmokerBlockEntity::new);
- register(Material.SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new, SpawnerBlockEntity::new);
- register(Material.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new, StructureBlockEntity::new);
- register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, SuspiciousSandBlockEntity::new);
- register(Material.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new, BrushableBlockEntity::new);
- register(Material.SUSPICIOUS_GRAVEL, CraftBrushableBlock.class, CraftBrushableBlock::new, BrushableBlockEntity::new);
- register(Material.TRAPPED_CHEST, CraftChest.class, CraftChest::new, TrappedChestBlockEntity::new);
+ // Paper start - simplify
+ register(BlockEntityType.SIGN, CraftSign.class, CraftSign::new);
@ -317,13 +319,13 @@ index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e
+ register(BlockEntityType.SMOKER, CraftSmoker.class, CraftSmoker::new);
+ register(BlockEntityType.MOB_SPAWNER, CraftCreatureSpawner.class, CraftCreatureSpawner::new);
+ register(BlockEntityType.STRUCTURE_BLOCK, CraftStructureBlock.class, CraftStructureBlock::new);
+ register(BlockEntityType.SUSPICIOUS_SAND, CraftSuspiciousSand.class, CraftSuspiciousSand::new);
+ register(BlockEntityType.BRUSHABLE_BLOCK, CraftBrushableBlock.class, CraftBrushableBlock::new); // TODO: HANDLE DIFFERENT MATERIALS....
+ register(BlockEntityType.TRAPPED_CHEST, CraftChest.class, CraftChest::new);
+ // Paper end
}
private static void register(Material blockType, BlockStateFactory<?> factory) {
@@ -336,30 +175,33 @@ public final class CraftBlockStates {
@@ -339,30 +176,33 @@ public final class CraftBlockStates {
}
private static <T extends BlockEntity, B extends CraftBlockEntityState<T>> void register(
@ -372,7 +374,7 @@ index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e
public static Class<? extends CraftBlockState> getBlockStateType(Material material) {
Preconditions.checkNotNull(material, "material is null");
return CraftBlockStates.getFactory(material).blockStateType;
@@ -375,6 +217,13 @@ public final class CraftBlockStates {
@@ -378,6 +218,13 @@ public final class CraftBlockStates {
return null;
}
@ -386,7 +388,7 @@ index cf76ca2ebead64d194ce03ee024085d32d02077a..1caa329567b50a962c54bb00c79cc98e
public static BlockState getBlockState(Block block) {
// Paper start
return CraftBlockStates.getBlockState(block, true);
@@ -432,7 +281,7 @@ public final class CraftBlockStates {
@@ -435,7 +282,7 @@ public final class CraftBlockStates {
if (world != null && tileEntity == null && CraftBlockStates.isTileEntityOptional(material)) {
factory = CraftBlockStates.DEFAULT_FACTORY;
} else {

View File

@ -18,10 +18,10 @@ index 21393ad40095a4049e5b6871169b2db7aa92d13c..e6553b936dac1eb25a310d1a33acb0b1
InetSocketAddress virtualHost = com.destroystokyo.paper.network.PaperNetworkClient.prepareVirtualHost(host, port);
com.destroystokyo.paper.event.server.PaperServerListPingEvent event = com.destroystokyo.paper.network.PaperLegacyStatusClient.processRequest(
diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
index e5e2f763d9b4b955df79ea0c4c79565be1fe59f0..2beddfc0532c3835d50724551e3d46cb0d7d2290 100644
index 14f037e721ac8ba885536cab43d3d398b011a397..17f42a4097d9c91bae2ccb02365498a0f7c7f8f8 100644
--- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
+++ b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java
@@ -207,7 +207,7 @@ public class ServerConnectionListener {
@@ -204,7 +204,7 @@ public class ServerConnectionListener {
throw new ReportedException(CrashReport.forThrowable(exception, "Ticking memory connection"));
}
@ -47,10 +47,10 @@ index 595779cfd0ee1c405d7936f00a7cae1706125e7f..ed3af916dfa875dd0a5f1e730d20d11e
@Override
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 9386d0836ed6dad232aa24219bdbbaeafffc49c0..feed51dba189ab35d5c7e6cc458cc865cf65c87f 100644
index 348265d5686072d625d694a5a3cdbe3060c950f7..5f957a28e9d30144f724ebdc581d5f0b80bf6dc1 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -248,7 +248,7 @@ public abstract class PlayerList {
@@ -255,7 +255,7 @@ public abstract class PlayerList {
String s1 = "local";
if (connection.getRemoteAddress() != null) {

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Configurable feature seeds
Co-authored-by: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index 43380d5e3a40b64bebdf3c0e7c48eca8998c8ac0..c07eb451a576811a39021f6f97103c77488fd001 100644
index 1080e1f67afe5574baca0df50cdb1d029a7a586a..a2f71a6d1a9e98133dff6cd0f625da9435a8af14 100644
--- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -288,7 +288,7 @@ public class TimingsExport extends Thread {

View File

@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..6bd0afddbcc461149dfe9a5c7a86fff6
+ }
+}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 7dcffb49a982a8db00d66441a03e2951b1d29ff9..5b46cabf4f2e2a1f7feaad378dd98d64aeef8671 100644
index 4757d6432631f0c5379597b40fda169ac7cd8621..9951e999b1440ef623f14bdd46b5e42a90387f1e 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -179,6 +179,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface

View File

@ -5,15 +5,15 @@ Subject: [PATCH] Always allow item changing in Fireball
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Fireball.java b/src/main/java/net/minecraft/world/entity/projectile/Fireball.java
index 838ba52969550f783d26e626267c556ab09b5f3e..7f4e3dfab421591151fda7ec39d9c00b464d62de 100644
index 307f545b79f01e22b1ffa9e41a0d353b3fa6a21d..58ea1fdc8dd5eb48d9642edecbbba1751e7037b6 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Fireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Fireball.java
@@ -28,7 +28,7 @@ public abstract class Fireball extends AbstractHurtingProjectile implements Item
@@ -27,7 +27,7 @@ public abstract class Fireball extends AbstractHurtingProjectile implements Item
}
public void setItem(ItemStack stack) {
- if (!stack.is(Items.FIRE_CHARGE) || stack.hasTag()) {
+ if (true || !stack.is(Items.FIRE_CHARGE) || stack.hasTag()) { // Paper - always allow item changing
this.getEntityData().set(Fireball.DATA_ITEM_STACK, (ItemStack) Util.make(stack.copy(), (itemstack1) -> {
itemstack1.setCount(1);
}));
this.getEntityData().set(Fireball.DATA_ITEM_STACK, stack.copyWithCount(1));
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] don't attempt to teleport dead entities
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1a71fe0113a1109da7b0f11a879b33a7e694b783..10ef56a2847450c3294802e2f84e105fccdc4721 100644
index d776c95e7c0752cdfcc44fb17509d5dc8605d8a8..6068d70f5eb566396d8c6bf6137e2c6cf21e33cf 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -781,7 +781,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -754,7 +754,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// CraftBukkit start
public void postTick() {
// No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle

View File

@ -5,16 +5,15 @@ Subject: [PATCH] Prevent excessive velocity through repeated crits
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 7d100539ffd1c52c4bf514907a0cb1d848eb0236..af9a16469df62b0ea9f1d35bcc30407f5e000646 100644
index dffce1de1254f0194db2f28b797155846d3beeb0..8b01e2fb891339867256ae45a5178af0beadc8cb 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2614,14 +2614,27 @@ public abstract class LivingEntity extends Entity implements Attackable {
return this.hasEffect(MobEffects.JUMP) ? (double) (0.1F * (float) (this.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D;
@@ -2655,13 +2655,26 @@ public abstract class LivingEntity extends Entity implements Attackable {
return this.hasEffect(MobEffects.JUMP) ? 0.1F * ((float) this.getEffect(MobEffects.JUMP).getAmplifier() + 1.0F) : 0.0F;
}
+ protected long lastJumpTime = 0L; // Paper
protected void jumpFromGround() {
double d0 = (double) this.getJumpPower() + this.getJumpBoostPower();
Vec3 vec3d = this.getDeltaMovement();
+ // Paper start
+ long time = System.nanoTime();
@ -28,7 +27,7 @@ index 7d100539ffd1c52c4bf514907a0cb1d848eb0236..af9a16469df62b0ea9f1d35bcc30407f
+ }
+ // Paper end
this.setDeltaMovement(vec3d.x, d0, vec3d.z);
this.setDeltaMovement(vec3d.x, (double) this.getJumpPower(), vec3d.z);
if (this.isSprinting()) {
float f = this.getYRot() * 0.017453292F;

View File

@ -7,10 +7,10 @@ Subject: [PATCH] Remove client-side code using deprecated for removal
Fixes warnings on build
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 0d61682b91b38500e755ded2226cd30f3a16af5a..4c90a6ee734451fe404b2255d21090b669da1aa1 100644
index fcade0a121f155dbf4f5f8af66240923d8da460d..c60c73d9f998260f3abe6fe445255c6e7c38b0c3 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -888,17 +888,7 @@ public class Util {
@@ -909,17 +909,7 @@ public class Util {
}
public void openUrl(URL url) {

View File

@ -18,10 +18,10 @@ index 97da8896865ff0bdd4fe8f2155b0830b42051bb1..17d0519ce3c097a38f9867fff3e1c25e
@Override
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 6dddd4eb8de9a08461245e35e65d4106f4e8e729..3e8255898e8afdd1127eea79338d5cc54502be76 100644
index 09f6948a52721b27ccd7c761a7efd09bfd7a183c..71a8812365503d840f6702a21d504a37d67c7194 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -344,7 +344,10 @@ public class ServerEntity {
@@ -338,7 +338,10 @@ public class ServerEntity {
ItemStack itemstack = ((LivingEntity) this.entity).getItemBySlot(enumitemslot);
if (!itemstack.isEmpty()) {
@ -34,10 +34,10 @@ index 6dddd4eb8de9a08461245e35e65d4106f4e8e729..3e8255898e8afdd1127eea79338d5cc5
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index af9a16469df62b0ea9f1d35bcc30407f5e000646..3e8d283a8312ac299bf0e260d75154ba8208d023 100644
index 8b01e2fb891339867256ae45a5178af0beadc8cb..8e7fb632e5ab2c2d7c890fcab2133ea431ed0380 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3126,7 +3126,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3164,7 +3164,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
equipmentChanges.forEach((enumitemslot, itemstack) -> {
ItemStack itemstack1 = itemstack.copy();
@ -49,8 +49,8 @@ index af9a16469df62b0ea9f1d35bcc30407f5e000646..3e8d283a8312ac299bf0e260d75154ba
switch (enumitemslot.getType()) {
case HAND:
this.setLastHandItem(enumitemslot, itemstack1);
@@ -3139,6 +3142,34 @@ public abstract class LivingEntity extends Entity implements Attackable {
((ServerLevel) this.level).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
@@ -3177,6 +3180,34 @@ public abstract class LivingEntity extends Entity implements Attackable {
((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
}
+ // Paper start - prevent oversized data

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Hide unnecessary itemmeta from clients
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 3e8255898e8afdd1127eea79338d5cc54502be76..fc187be6b3fb7bc9fa97d1ebcbe92294aa840ecf 100644
index 71a8812365503d840f6702a21d504a37d67c7194..63561c0044375465fa0023b2b563a6516d7fa76c 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -346,7 +346,7 @@ public class ServerEntity {
@@ -340,7 +340,7 @@ public class ServerEntity {
if (!itemstack.isEmpty()) {
// Paper start - prevent oversized data
final ItemStack sanitized = LivingEntity.sanitizeItemStack(itemstack.copy(), false);
@ -18,10 +18,10 @@ index 3e8255898e8afdd1127eea79338d5cc54502be76..fc187be6b3fb7bc9fa97d1ebcbe92294
}
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 4711986fb38c4c941ce253df05ff7b70dbb0d47f..0ed72d306088f31cf891f1508fe00451b799f682 100644
index 2b6e315d275cf5e303663c175745a5fe2e35969f..13e73042653909f194cfc909a96370656cbcf1ca 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2706,8 +2706,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2705,8 +2705,8 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Refresh the current entity metadata
entity.getEntityData().refresh(player);
// SPIGOT-7136 - Allays
@ -33,10 +33,10 @@ index 4711986fb38c4c941ce253df05ff7b70dbb0d47f..0ed72d306088f31cf891f1508fe00451
}
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 3e8d283a8312ac299bf0e260d75154ba8208d023..b167d83abee37d64f8ef5865b9407bf1d2237ea1 100644
index 8e7fb632e5ab2c2d7c890fcab2133ea431ed0380..29a8b2bddf4257e74db27bf990c8aa1fd99c341b 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3128,7 +3128,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3166,7 +3166,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Paper start - prevent oversized data
ItemStack toSend = sanitizeItemStack(itemstack1, true);
@ -45,8 +45,8 @@ index 3e8d283a8312ac299bf0e260d75154ba8208d023..b167d83abee37d64f8ef5865b9407bf1
// Paper end
switch (enumitemslot.getType()) {
case HAND:
@@ -3142,6 +3142,70 @@ public abstract class LivingEntity extends Entity implements Attackable {
((ServerLevel) this.level).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
@@ -3180,6 +3180,70 @@ public abstract class LivingEntity extends Entity implements Attackable {
((ServerLevel) this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list));
}
+ // Paper start - hide unnecessary item meta

View File

@ -36,7 +36,7 @@ index 55f2fa02a36f0500b47f9ce377926719557106e5..18b5bce1138d50be32e5da013221be69
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(Items.GLOW_BERRIES);
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 519d02a2009c4f09c9e8be7196a701f0f042012d..a140fed067e7e6c1c42e111f47d3678863ef95ce 100644
index 448c958a7a40258132add92da74fa689cf2ac046..c463adf131c4ca6e38f18d4efd94f4629bcfafe9 100644
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
@@ -84,6 +84,10 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
@ -88,7 +88,7 @@ index 5d78348fc18b22ccb7ad109890f867e20efec047..44c78f0d56c3459c063c104e401a521e
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 102b038e2566cba4f259a61e502ff0808c47234c..ccbbc64b0ffaf055f98db71acaed9f51591f0594 100644
index b7d6197cb5f46bb020fff049ae2dd8fc3ee8ff2f..8c45f28450bc1079ee5d184591f1ac03babced4e 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -96,6 +96,7 @@ public class SpigotWorldConfig

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Add PlayerItemFrameChangeEvent
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index 70107774f12a996c0f64b46cb4c6af9c5f50aa61..bfe94f6607e35db4df75d6061a88bce2a80b86c8 100644
index dc999068891bfdfd4873ca939b4c4389d63f4415..a86472cce8e8fcde16d761842fe443a619f6e305 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -3,6 +3,7 @@ package net.minecraft.world.entity.decoration;
@ -30,7 +30,7 @@ index 70107774f12a996c0f64b46cb4c6af9c5f50aa61..bfe94f6607e35db4df75d6061a88bce2
this.dropItem(source.getEntity(), false);
this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
@@ -457,13 +465,26 @@ public class ItemFrame extends HangingEntity {
@@ -456,13 +464,26 @@ public class ItemFrame extends HangingEntity {
}
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add player health update API
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 88ec1bb0bea5aeb4a6e0ee628de58ac9f1f546cf..14f7fc4a6724ed4650117de2397052c54ae05df4 100644
index 7fedfc313be736255067d12d7524439d42575524..5f046c62a1764c13df3c11ecd4be0ecc9553e529 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2393,9 +2393,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2366,9 +2366,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().maxHealthCache = getMaxHealth();
}
@ -22,7 +22,7 @@ index 88ec1bb0bea5aeb4a6e0ee628de58ac9f1f546cf..14f7fc4a6724ed4650117de2397052c5
if (this.getHandle().queueHealthUpdatePacket) {
this.getHandle().queuedHealthUpdatePacket = packet;
} else {
@@ -2404,6 +2406,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2377,6 +2379,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end
}

View File

@ -5,11 +5,11 @@ Subject: [PATCH] Allow delegation to vanilla chunk gen
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 084e107e8714c59182d9b4ae73c0c0f01622b191..df357a207b52b677c5374865a5d19ba616ec605d 100644
index ecd6d91ca1ddee0d0d3b6d41fb96f432273deffc..9b2f05e6d1d8e52842abaa4c92b60f7558480c70 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2356,6 +2356,90 @@ public final class CraftServer implements Server {
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME), world); // Paper - Anti-Xray - Add parameters
@@ -2354,6 +2354,90 @@ public final class CraftServer implements Server {
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME));
}
+ // Paper start
@ -100,7 +100,7 @@ index 084e107e8714c59182d9b4ae73c0c0f01622b191..df357a207b52b677c5374865a5d19ba6
public BossBar createBossBar(String title, BarColor color, BarStyle style, BarFlag... flags) {
return new CraftBossBar(title, color, style, flags);
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
index 4a23d03757e1735b9ebb8c003adcc0374a7d672d..ce006e1d6c38e5b0bdb336c480fb9d291292f75c 100644
index c23ce88cb9693291fec81a99e3a5bcb2615bb897..189a584b4b81bbc28d4c47b901b5aa6f85fb7932 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java
@@ -23,7 +23,7 @@ import org.bukkit.material.MaterialData;
@ -112,7 +112,7 @@ index 4a23d03757e1735b9ebb8c003adcc0374a7d672d..ce006e1d6c38e5b0bdb336c480fb9d29
private final Registry<net.minecraft.world.level.biome.Biome> biomes;
private Set<BlockPos> tiles;
private final Set<BlockPos> lights = new HashSet<>();
@@ -194,7 +194,13 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
@@ -189,7 +189,13 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
return this.tiles;
}

View File

@ -1180,10 +1180,10 @@ index 0000000000000000000000000000000000000000..d67a40e7be030142443680c89e1763fc
+ }
+}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index a3f6a5477b264ec13d9f8ab863798b20faace226..88d5866b67fd4617eabf1333b22843e9d64fdb39 100644
index 768f9ef872ed1bb3157c6fa122e1e3d76417a4b6..fd93a4bda08882c098b10cb4abeb254a11814957 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -420,7 +420,7 @@ public class ServerPlayer extends Player {
@@ -461,7 +461,7 @@ public class ServerPlayer extends Player {
if (blockposition1 != null) {
this.moveTo(blockposition1, 0.0F, 0.0F);
@ -1192,7 +1192,7 @@ index a3f6a5477b264ec13d9f8ab863798b20faace226..88d5866b67fd4617eabf1333b22843e9
break;
}
}
@@ -428,7 +428,7 @@ public class ServerPlayer extends Player {
@@ -469,7 +469,7 @@ public class ServerPlayer extends Player {
} else {
this.moveTo(blockposition, 0.0F, 0.0F);
@ -1202,10 +1202,10 @@ index a3f6a5477b264ec13d9f8ab863798b20faace226..88d5866b67fd4617eabf1333b22843e9
}
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index feed51dba189ab35d5c7e6cc458cc865cf65c87f..6fa5d2552935e8e733cbbefb2db11239a26291dc 100644
index 5f957a28e9d30144f724ebdc581d5f0b80bf6dc1..23ab7960120c1e2a76880f634787a089857ebff4 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -888,7 +888,7 @@ public abstract class PlayerList {
@@ -895,7 +895,7 @@ public abstract class PlayerList {
// CraftBukkit end
worldserver1.getChunkSource().addRegionTicket(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(location.getBlockX() >> 4, location.getBlockZ() >> 4), 1, entityplayer.getId()); // Paper
@ -1214,198 +1214,11 @@ index feed51dba189ab35d5c7e6cc458cc865cf65c87f..6fa5d2552935e8e733cbbefb2db11239
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 10ef56a2847450c3294802e2f84e105fccdc4721..1a8b5b3250f8e047f35612a6762d47cf963b74fd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1162,9 +1162,44 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
float f2 = this.getBlockSpeedFactor();
this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2));
- if (this.level.getBlockStatesIfLoaded(this.getBoundingBox().deflate(1.0E-6D)).noneMatch((iblockdata1) -> {
- return iblockdata1.is(BlockTags.FIRE) || iblockdata1.is(Blocks.LAVA);
- })) {
+ // Paper start - remove expensive streams from here
+ boolean noneMatch = true;
+ AABB fireSearchBox = this.getBoundingBox().deflate(1.0E-6D);
+ {
+ int minX = Mth.floor(fireSearchBox.minX);
+ int minY = Mth.floor(fireSearchBox.minY);
+ int minZ = Mth.floor(fireSearchBox.minZ);
+ int maxX = Mth.floor(fireSearchBox.maxX);
+ int maxY = Mth.floor(fireSearchBox.maxY);
+ int maxZ = Mth.floor(fireSearchBox.maxZ);
+ fire_search_loop:
+ for (int fz = minZ; fz <= maxZ; ++fz) {
+ for (int fx = minX; fx <= maxX; ++fx) {
+ for (int fy = minY; fy <= maxY; ++fy) {
+ net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)this.level.getChunkIfLoadedImmediately(fx >> 4, fz >> 4);
+ if (chunk == null) {
+ // Vanilla rets an empty stream if all the chunks are not loaded, so noneMatch will be true
+ // even if we're in lava/fire
+ noneMatch = true;
+ break fire_search_loop;
+ }
+ if (!noneMatch) {
+ // don't do get type, we already know we're in fire - we just need to check the chunks
+ // loaded state
+ continue;
+ }
+
+ BlockState type = chunk.getBlockStateFinal(fx, fy, fz);
+ if (type.is(BlockTags.FIRE) || type.is(Blocks.LAVA)) {
+ noneMatch = false;
+ // can't break, we need to retain vanilla behavior by ensuring ALL chunks are loaded
+ }
+ }
+ }
+ }
+ }
+ if (noneMatch) {
+ // Paper end - remove expensive streams from here
if (this.remainingFireTicks <= 0) {
this.setRemainingFireTicks(-this.getFireImmuneTicks());
}
@@ -1316,32 +1351,78 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
private Vec3 collide(Vec3 movement) {
- AABB axisalignedbb = this.getBoundingBox();
- List<VoxelShape> list = this.level.getEntityCollisions(this, axisalignedbb.expandTowards(movement));
- Vec3 vec3d1 = movement.lengthSqr() == 0.0D ? movement : Entity.collideBoundingBox(this, movement, axisalignedbb, this.level, list);
- boolean flag = movement.x != vec3d1.x;
- boolean flag1 = movement.y != vec3d1.y;
- boolean flag2 = movement.z != vec3d1.z;
- boolean flag3 = this.onGround || flag1 && movement.y < 0.0D;
-
- if (this.maxUpStep() > 0.0F && flag3 && (flag || flag2)) {
- Vec3 vec3d2 = Entity.collideBoundingBox(this, new Vec3(movement.x, (double) this.maxUpStep(), movement.z), axisalignedbb, this.level, list);
- Vec3 vec3d3 = Entity.collideBoundingBox(this, new Vec3(0.0D, (double) this.maxUpStep(), 0.0D), axisalignedbb.expandTowards(movement.x, 0.0D, movement.z), this.level, list);
-
- if (vec3d3.y < (double) this.maxUpStep()) {
- Vec3 vec3d4 = Entity.collideBoundingBox(this, new Vec3(movement.x, 0.0D, movement.z), axisalignedbb.move(vec3d3), this.level, list).add(vec3d3);
-
- if (vec3d4.horizontalDistanceSqr() > vec3d2.horizontalDistanceSqr()) {
- vec3d2 = vec3d4;
+ // Paper start - optimise collisions
+ // This is a copy of vanilla's except that it uses strictly AABB math
+ if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) {
+ return movement;
+ }
+
+ final Level world = this.level;
+ final AABB currBoundingBox = this.getBoundingBox();
+
+ if (io.papermc.paper.util.CollisionUtil.isEmpty(currBoundingBox)) {
+ return movement;
+ }
+
+ final List<AABB> potentialCollisions = io.papermc.paper.util.CachedLists.getTempCollisionList();
+ try {
+ final double stepHeight = (double)this.maxUpStep();
+ final AABB collisionBox;
+
+ if (movement.x == 0.0 && movement.z == 0.0 && movement.y != 0.0) {
+ if (movement.y > 0.0) {
+ collisionBox = io.papermc.paper.util.CollisionUtil.cutUpwards(currBoundingBox, movement.y);
+ } else {
+ collisionBox = io.papermc.paper.util.CollisionUtil.cutDownwards(currBoundingBox, movement.y);
+ }
+ } else {
+ if (stepHeight > 0.0 && (this.onGround || (movement.y < 0.0)) && (movement.x != 0.0 || movement.z != 0.0)) {
+ // don't bother getting the collisions if we don't need them.
+ if (movement.y <= 0.0) {
+ collisionBox = io.papermc.paper.util.CollisionUtil.expandUpwards(currBoundingBox.expandTowards(movement.x, movement.y, movement.z), stepHeight);
+ } else {
+ collisionBox = currBoundingBox.expandTowards(movement.x, Math.max(stepHeight, movement.y), movement.z);
+ }
+ } else {
+ collisionBox = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
}
}
- if (vec3d2.horizontalDistanceSqr() > vec3d1.horizontalDistanceSqr()) {
- return vec3d2.add(Entity.collideBoundingBox(this, new Vec3(0.0D, -vec3d2.y + movement.y, 0.0D), axisalignedbb.move(vec3d2), this.level, list));
+ io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks,
+ false, false, null, null);
+
+ if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) {
+ io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions);
}
- }
- return vec3d1;
+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions);
+
+ if (stepHeight > 0.0
+ && (this.onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0))
+ && (limitedMoveVector.x != movement.x || limitedMoveVector.z != movement.z)) {
+ Vec3 vec3d2 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(movement.x, stepHeight, movement.z), currBoundingBox, potentialCollisions);
+ final Vec3 vec3d3 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(0.0, stepHeight, 0.0), currBoundingBox.expandTowards(movement.x, 0.0, movement.z), potentialCollisions);
+
+ if (vec3d3.y < stepHeight) {
+ final Vec3 vec3d4 = io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(movement.x, 0.0D, movement.z), currBoundingBox.move(vec3d3), potentialCollisions).add(vec3d3);
+
+ if (vec3d4.horizontalDistanceSqr() > vec3d2.horizontalDistanceSqr()) {
+ vec3d2 = vec3d4;
+ }
+ }
+
+ if (vec3d2.horizontalDistanceSqr() > limitedMoveVector.horizontalDistanceSqr()) {
+ return vec3d2.add(io.papermc.paper.util.CollisionUtil.performCollisions(new Vec3(0.0D, -vec3d2.y + movement.y, 0.0D), currBoundingBox.move(vec3d2), potentialCollisions));
+ }
+
+ return limitedMoveVector;
+ } else {
+ return limitedMoveVector;
+ }
+ } finally {
+ io.papermc.paper.util.CachedLists.returnTempCollisionList(potentialCollisions);
+ }
+ // Paper end - optimise collisions
}
public static Vec3 collideBoundingBox(@Nullable Entity entity, Vec3 movement, AABB entityBoundingBox, Level world, List<VoxelShape> collisions) {
@@ -2492,11 +2573,30 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
float f = this.dimensions.width * 0.8F;
AABB axisalignedbb = AABB.ofSize(this.getEyePosition(), (double) f, 1.0E-6D, (double) f);
- return BlockPos.betweenClosedStream(axisalignedbb).anyMatch((blockposition) -> {
- BlockState iblockdata = this.level.getBlockState(blockposition);
+ BlockPos.MutableBlockPos blockposition = new BlockPos.MutableBlockPos();
+ int minX = Mth.floor(axisalignedbb.minX);
+ int minY = Mth.floor(axisalignedbb.minY);
+ int minZ = Mth.floor(axisalignedbb.minZ);
+ int maxX = Mth.floor(axisalignedbb.maxX);
+ int maxY = Mth.floor(axisalignedbb.maxY);
+ int maxZ = Mth.floor(axisalignedbb.maxZ);
+ for (int fz = minZ; fz <= maxZ; ++fz) {
+ for (int fx = minX; fx <= maxX; ++fx) {
+ for (int fy = minY; fy <= maxY; ++fy) {
+ net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)this.level.getChunkIfLoadedImmediately(fx >> 4, fz >> 4);
+ if (chunk == null) {
+ continue;
+ }
- return !iblockdata.isAir() && iblockdata.isSuffocating(this.level, blockposition) && Shapes.joinIsNotEmpty(iblockdata.getCollisionShape(this.level, blockposition).move((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()), Shapes.create(axisalignedbb), BooleanOp.AND);
- });
+ BlockState iblockdata = chunk.getBlockStateFinal(fx, fy, fz);
+ blockposition.set(fx, fy, fz);
+ if (!iblockdata.isAir() && iblockdata.isSuffocating(this.level, blockposition) && Shapes.joinIsNotEmpty(iblockdata.getCollisionShape(this.level, blockposition).move((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()), Shapes.create(axisalignedbb), BooleanOp.AND)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
}
}
diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java
index be578f14146b0184d5419d5b961c5d681f9ba7a3..018cbf866bbe39b69a4afa039166e8d34ec3ab5f 100644
index a3eaf80b020c3bbc0306c5d17659ee661dfd275b..1b6f72932fbdd567a1534bcf15e8a610b00f974d 100644
--- a/src/main/java/net/minecraft/world/level/BlockCollisions.java
+++ b/src/main/java/net/minecraft/world/level/BlockCollisions.java
@@ -106,7 +106,7 @@ public class BlockCollisions extends AbstractIterator<VoxelShape> {
@@ -105,7 +105,7 @@ public class BlockCollisions<T> extends AbstractIterator<T> {
VoxelShape voxelShape = blockState.getCollisionShape(this.collisionGetter, this.pos, this.context);
if (voxelShape == Shapes.block()) {
@ -1415,7 +1228,7 @@ index be578f14146b0184d5419d5b961c5d681f9ba7a3..018cbf866bbe39b69a4afa039166e8d3
}
diff --git a/src/main/java/net/minecraft/world/level/CollisionGetter.java b/src/main/java/net/minecraft/world/level/CollisionGetter.java
index 56d94c94fb0d4dc468bb5d69be655ddd5c6b5360..d7d396ad73866a97cd9f63b34ad8c587f522e713 100644
index 06107d69dff9f0b52a5f188095cbd9a9efa5684c..c0dd933c8e64484c4ae0d4fa0f6e19969cf09b37 100644
--- a/src/main/java/net/minecraft/world/level/CollisionGetter.java
+++ b/src/main/java/net/minecraft/world/level/CollisionGetter.java
@@ -35,31 +35,33 @@ public interface CollisionGetter extends BlockGetter {
@ -1493,10 +1306,10 @@ index 66a5783e2a83c75ca46d1fd6f97d9de733c01a09..d860ddae508f53d06f74d8ae0efdfc50
return List.of();
} else {
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
index 61c814a8042d3d4be5ea86ce339c90100bdbe597..cd939384f022609c96b055c25db7e098e4256336 100644
index a9e8d9c65a809562d4768df348dcd79bec4d0e3c..a8fbb4094fb0ff4d0204b477764ca210afc6a7f8 100644
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -787,6 +787,12 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -863,6 +863,12 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.conditionallyFullOpaque;
}
// Paper end - starlight
@ -1509,158 +1322,11 @@ index 61c814a8042d3d4be5ea86ce339c90100bdbe597..cd939384f022609c96b055c25db7e098
public void initCache() {
this.fluidState = ((Block) this.owner).getFluidState(this.asState());
@@ -797,6 +803,35 @@ public abstract class BlockBehaviour implements FeatureElement {
this.shapeExceedsCube = this.cache == null || this.cache.largeCollisionShape; // Paper - moved from actual method to here
this.opacityIfCached = this.cache == null || this.isConditionallyFullOpaque() ? -1 : this.cache.lightBlock; // Paper - starlight - cache opacity for light
+ // Paper start
+ if (io.papermc.paper.util.CollisionUtil.isSpecialCollidingBlock(this)) {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_SPECIAL_BLOCK;
+ } else {
+ try {
+ // There is NOTHING HACKY ABOUT THIS AT ALLLLLLLLLLLLLLL
+ VoxelShape constantShape = this.getCollisionShape(null, null, null);
+ if (constantShape == null) {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_UNKNOWN_BLOCK;
+ } else {
+ constantShape = constantShape.optimize();
+ if (constantShape.isEmpty()) {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_EMPTY_BLOCK;
+ } else {
+ final List<net.minecraft.world.phys.AABB> boxes = constantShape.toAabbs();
+ if (constantShape == net.minecraft.world.phys.shapes.Shapes.getFullUnoptimisedCube() || (boxes.size() == 1 && boxes.get(0).equals(net.minecraft.world.phys.shapes.Shapes.BLOCK_OPTIMISED.aabb))) {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_FULL_BLOCK;
+ } else {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_UNKNOWN_BLOCK;
+ }
+ }
+ }
+ } catch (final Error error) {
+ throw error;
+ } catch (final Throwable throwable) {
+ this.blockCollisionBehavior = io.papermc.paper.util.CollisionUtil.KNOWN_UNKNOWN_BLOCK;
+ }
+ }
+ // Paper end
}
public Block getBlock() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index c7e2796e136ee8fb7d7e438a7fc59826c05b761b..1b80a91fa36c59a31b57ef7ef4a68eacbb0f17f5 100644
index 5d53b09e19b664fad337ea5098bf9cf41a7168f8..dd08c2682bdc122309ff710ff6c9a0b17be41c07 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -46,6 +46,110 @@ public class LevelChunkSection {
this.biomes = new PalettedContainer<>(biomeRegistry.asHolderIdMap(), biomeRegistry.getHolderOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null); // Paper - Anti-Xray - Add preset biomes
}
+ // Paper start
+ protected int specialCollidingBlocks;
+ // blockIndex = x | (z << 4) | (y << 8)
+ private long[] knownBlockCollisionData;
+
+ private long[] initKnownDataField() {
+ return this.knownBlockCollisionData = new long[16 * 16 * 16 * 2 / Long.SIZE];
+ }
+
+ public final boolean hasSpecialCollidingBlocks() {
+ return this.specialCollidingBlocks != 0;
+ }
+
+ public static long getKnownBlockInfo(final int blockIndex, final long value) {
+ final int valueShift = (blockIndex & (Long.SIZE / 2 - 1));
+
+ return (value >>> (valueShift << 1)) & 0b11L;
+ }
+
+ public final long getKnownBlockInfo(final int blockIndex) {
+ if (this.knownBlockCollisionData == null) {
+ return 0L;
+ }
+
+ final int arrayIndex = (blockIndex >>> (6 - 1)); // blockIndex / (64/2)
+ final int valueShift = (blockIndex & (Long.SIZE / 2 - 1));
+
+ final long value = this.knownBlockCollisionData[arrayIndex];
+
+ return (value >>> (valueShift << 1)) & 0b11L;
+ }
+
+ // important detail: this returns 32 values, one for localZ = localZ & (~1) and one for localZ = localZ | 1
+ // the even localZ is the lower 32 bits, the odd is the upper 32 bits
+ public final long getKnownBlockInfoHorizontalRaw(final int localY, final int localZ) {
+ if (this.knownBlockCollisionData == null) {
+ return 0L;
+ }
+
+ final int horizontalIndex = (localZ << 4) | (localY << 8);
+ return this.knownBlockCollisionData[horizontalIndex >>> (6 - 1)];
+ }
+
+ private void initBlockCollisionData() {
+ this.specialCollidingBlocks = 0;
+ // In 1.18 all sections will be initialised, whether or not they have blocks (fucking stupid btw)
+ // This means we can't aggressively initialise the backing long[], or else memory usage will just skyrocket.
+ // So only init if we contain non-empty blocks.
+ if (this.nonEmptyBlockCount == 0) {
+ this.knownBlockCollisionData = null;
+ return;
+ }
+ this.initKnownDataField();
+ for (int index = 0; index < (16 * 16 * 16); ++index) {
+ final BlockState state = this.states.get(index);
+ this.setKnownBlockInfo(index, state);
+ if (io.papermc.paper.util.CollisionUtil.isSpecialCollidingBlock(state)) {
+ ++this.specialCollidingBlocks;
+ }
+ }
+ }
+
+ // only use for initBlockCollisionData
+ private void setKnownBlockInfo(final int blockIndex, final BlockState blockState) {
+ final int arrayIndex = (blockIndex >>> (6 - 1)); // blockIndex / (64/2)
+ final int valueShift = (blockIndex & (Long.SIZE / 2 - 1)) << 1;
+
+ long value = this.knownBlockCollisionData[arrayIndex];
+
+ value &= ~(0b11L << valueShift);
+ value |= blockState.getBlockCollisionBehavior() << valueShift;
+
+ this.knownBlockCollisionData[arrayIndex] = value;
+ }
+
+ public void updateKnownBlockInfo(final int blockIndex, final BlockState from, final BlockState to) {
+ if (io.papermc.paper.util.CollisionUtil.isSpecialCollidingBlock(from)) {
+ --this.specialCollidingBlocks;
+ }
+ if (io.papermc.paper.util.CollisionUtil.isSpecialCollidingBlock(to)) {
+ ++this.specialCollidingBlocks;
+ }
+
+ if (this.nonEmptyBlockCount == 0) {
+ this.knownBlockCollisionData = null;
+ return;
+ }
+
+ if (this.knownBlockCollisionData == null) {
+ this.initKnownDataField();
+ }
+
+ final int arrayIndex = (blockIndex >>> (6 - 1)); // blockIndex / (64/2)
+ final int valueShift = (blockIndex & (Long.SIZE / 2 - 1)) << 1;
+
+ long value = this.knownBlockCollisionData[arrayIndex];
+
+ value &= ~(0b11L << valueShift);
+ value |= to.getBlockCollisionBehavior() << valueShift;
+
+ this.knownBlockCollisionData[arrayIndex] = value;
+ }
+ // Paper end
+
public static int getBottomBlockY(int chunkPos) {
return chunkPos << 4;
}
@@ -70,8 +174,8 @@ public class LevelChunkSection {
@@ -59,8 +59,8 @@ public class LevelChunkSection {
return this.setBlockState(x, y, z, state, true);
}
@ -1671,7 +1337,7 @@ index c7e2796e136ee8fb7d7e438a7fc59826c05b761b..1b80a91fa36c59a31b57ef7ef4a68eac
if (lock) {
iblockdata1 = (BlockState) this.states.getAndSet(x, y, z, state);
@@ -110,6 +214,7 @@ public class LevelChunkSection {
@@ -99,6 +99,7 @@ public class LevelChunkSection {
++this.tickingFluidCount;
}
@ -1679,7 +1345,7 @@ index c7e2796e136ee8fb7d7e438a7fc59826c05b761b..1b80a91fa36c59a31b57ef7ef4a68eac
return iblockdata1;
}
@@ -159,6 +264,7 @@ public class LevelChunkSection {
@@ -144,6 +145,7 @@ public class LevelChunkSection {
});
// Paper end

View File

@ -5,8 +5,10 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
CHECK ME
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627bd74dbb62 100644
index 13e73042653909f194cfc909a96370656cbcf1ca..be79308ac6d30afe7b626f325a44b607969477fe 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -647,7 +647,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@ -18,15 +20,15 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
d6 = d3 - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above
d7 = d4 - this.vehicleLastGoodY - 1.0E-6D; // Paper - diff on change, used for checking large move vectors above
@@ -655,6 +655,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
boolean flag1 = entity.verticalCollisionBelow;
@@ -663,6 +663,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
entity.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
+ boolean didCollide = toX != entity.getX() || toY != entity.getY() || toZ != entity.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
double d11 = d7;
d6 = d3 - entity.getX();
@@ -668,16 +669,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -676,16 +677,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
boolean flag2 = false;
if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot
@ -54,11 +56,11 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
entity.absMoveTo(d0, d1, d2, f, f1);
this.player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.connection.send(new ClientboundMoveVehiclePacket(entity));
@@ -763,7 +772,32 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -771,7 +780,32 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
private boolean noBlocksAround(Entity entity) {
- return entity.level.getBlockStates(entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::isAir);
- return entity.level().getBlockStates(entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D)).allMatch(BlockBehaviour.BlockStateBase::isAir);
+ // Paper start - stop using streams, this is already a known fixed problem in Entity#move
+ AABB box = entity.getBoundingBox().inflate(0.0625D).expandTowards(0.0D, -0.55D, 0.0D);
+ int minX = Mth.floor(box.minX);
@ -68,7 +70,7 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
+ int maxY = Mth.floor(box.maxY);
+ int maxZ = Mth.floor(box.maxZ);
+
+ Level world = entity.level;
+ Level world = entity.level();
+ BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
+
+ for (int y = minY; y <= maxY; ++y) {
@ -88,7 +90,7 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
}
@Override
@@ -1343,7 +1377,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1347,7 +1381,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
if (this.awaitingPositionFromClient != null) {
@ -97,34 +99,33 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@@ -1437,7 +1471,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1440,7 +1474,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
}
- AABB axisalignedbb = this.player.getBoundingBox();
+ AABB axisalignedbb = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB
d7 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
d8 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
@@ -1478,6 +1512,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
boolean flag1 = this.player.verticalCollisionBelow;
d6 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
d7 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
@@ -1482,6 +1516,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.player.move(MoverType.PLAYER, new Vec3(d7, d8, d9));
+ boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
+ boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be...
// Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) {
@@ -1497,12 +1532,23 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
return; // ... thanks Mojang for letting move calls teleport across dimensions.
@@ -1500,11 +1535,22 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
boolean flag2 = false;
if (!this.player.isChangingDimension() && d11 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot
if (!this.player.isChangingDimension() && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.gameMode.isCreative() && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { // Spigot
- flag2 = true;
+ flag2 = true; // Paper - diff on change, this should be moved wrongly
ServerGamePacketListenerImpl.LOGGER.warn("{} moved wrongly!", this.player.getName().getString());
}
this.player.absMoveTo(d0, d1, d2, f, f1);
- if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
- if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
+ // Paper start - optimise out extra getCubes
+ // Original for reference:
+ // boolean teleportBack = flag2 && worldserver.getCubes(this.player, axisalignedbb) || (didCollide && this.a((IWorldReader) worldserver, axisalignedbb));
@ -138,9 +139,9 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
+ }
+ if (!this.player.noPhysics && !this.player.isSleeping() && teleportBack) { // Paper end - optimise out extra getCubes
this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet()); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet.
this.player.doCheckFallDamage(this.player.getY() - d6, packet.isOnGround());
this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packet.isOnGround());
} else {
@@ -1589,6 +1635,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1587,6 +1633,26 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
}
@ -164,7 +165,6 @@ index ed7818150b0e3cfde1509081b7afcbd82826e09b..71cb4ba6c2b8eeccfe2472d33953627b
+ }
+ }
+ // Paper end - optimise out extra getCubes
+
private boolean isPlayerCollidingWithAnythingNew(LevelReader world, AABB box) {
Iterable<VoxelShape> iterable = world.getCollisions(this.player, this.player.getBoundingBox().deflate(9.999999747378752E-6D));
VoxelShape voxelshape = Shapes.create(box.deflate(9.999999747378752E-6D));
private boolean isPlayerCollidingWithAnythingNew(LevelReader world, AABB box, double newX, double newY, double newZ) {
AABB axisalignedbb1 = this.player.getBoundingBox().move(newX - this.player.getX(), newY - this.player.getY(), newZ - this.player.getZ());
Iterable<VoxelShape> iterable = world.getCollisions(this.player, axisalignedbb1.deflate(9.999999747378752E-6D));

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Fix ChunkSnapshot#isSectionEmpty(int) and optimize
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
index ef52dbf5009c7ba14cd0aa9c6c1f3b5534f7af06..79bbb4de18459caa2d7ca11f4f4b0d0b5df468a4 100644
index b738e1f7debac7d70910d5ac908ca9d4f60640d5..007fd353bd55056ecddba2e16c5fa8c479961402 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
@@ -289,13 +289,17 @@ public class CraftChunk implements Chunk {

View File

@ -8,7 +8,7 @@ This ensures at least a valid version of the chunk exists
on disk, even if outdated
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 9bae47f99336c377beb72c4b50b7f01cb4db15da..dcfe090c269d4cbcc2eb1b6f85392848bb34656c 100644
index 98c436d84e4aedbdb805129fcdb6b871a1b4e3d9..536892e60d4a834161963bb587dc10c37b081a0a 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
@@ -1004,6 +1004,9 @@ public class RegionFile implements AutoCloseable {
@ -47,10 +47,10 @@ index 9bae47f99336c377beb72c4b50b7f01cb4db15da..dcfe090c269d4cbcc2eb1b6f85392848
ByteBuffer bytebuffer = ByteBuffer.wrap(this.buf, 0, this.count);
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 d5b501bcb33a785ef0301bf6bb8d396b9d4fbb6a..bd502ca721de0cab438d995efa00ad0554c0d2fe 100644
index 5291bbe208397d73e6950e9f196bcd1da55c1fad..9bb8938fe3dff4cda2d1324c041f03299aa761e4 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
@@ -302,10 +302,17 @@ public class RegionFileStorage implements AutoCloseable {
@@ -344,10 +344,17 @@ public class RegionFileStorage implements AutoCloseable {
NbtIo.write(nbt, (DataOutput) dataoutputstream);
regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk
regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone
@ -69,7 +69,7 @@ index d5b501bcb33a785ef0301bf6bb8d396b9d4fbb6a..bd502ca721de0cab438d995efa00ad05
} catch (Throwable throwable1) {
throwable.addSuppressed(throwable1);
}
@@ -313,10 +320,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -355,10 +362,7 @@ public class RegionFileStorage implements AutoCloseable {
throw throwable;
}
@ -79,9 +79,9 @@ index d5b501bcb33a785ef0301bf6bb8d396b9d4fbb6a..bd502ca721de0cab438d995efa00ad05
- }
+ // Paper - move into try block to only write if successfully serialized
}
// Paper start
return;
@@ -362,4 +366,13 @@ public class RegionFileStorage implements AutoCloseable {
} finally { // Paper start
@@ -393,4 +397,13 @@ public class RegionFileStorage implements AutoCloseable {
}
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Forward CraftEntity in teleport command
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1a8b5b3250f8e047f35612a6762d47cf963b74fd..61f6e3196551b76d0300a60e3ad8e446b49dace3 100644
index 6068d70f5eb566396d8c6bf6137e2c6cf21e33cf..f4edaa4395a0ec0d6c507ad7231c3992ab812d1c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3331,6 +3331,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3321,6 +3321,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public void restoreFrom(Entity original) {
@ -22,7 +22,7 @@ index 1a8b5b3250f8e047f35612a6762d47cf963b74fd..61f6e3196551b76d0300a60e3ad8e446
CompoundTag nbttagcompound = original.saveWithoutId(new CompoundTag());
nbttagcompound.remove("Dimension");
@@ -3412,10 +3419,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3402,10 +3409,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
}

View File

@ -1,61 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lexikiq <noellekiq@gmail.com>
Date: Mon, 21 Jun 2021 23:21:58 -0400
Subject: [PATCH] Preserve overstacked loot
Preserves overstacked items in loot tables, such as shulker box drops, to prevent the items
from being deleted (as they'd overflow past the bounds of the container)-- or worse, causing
chunk bans via the large amount of NBT created by unstacking the items.
Fixes GH-5140 and GH-4748.
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
index 1326539c88aabfbe1bbaf2905268abfa729d8167..3bc13092873609af9c6f412190dd989d39f1df23 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootTable.java
@@ -56,14 +56,22 @@ public class LootTable {
this.compositeFunction = LootItemFunctions.compose(functions);
}
+ // Paper start - preserve overstacked items
+ @Deprecated
public static Consumer<ItemStack> createStackSplitter(LootContext context, Consumer<ItemStack> consumer) {
+ return createStackSplitter(context, consumer, null);
+ }
+ public static Consumer<ItemStack> createStackSplitter(LootContext context, Consumer<ItemStack> consumer, @org.jetbrains.annotations.Nullable net.minecraft.server.level.ServerLevel level) {
+ boolean skipSplitter = level != null && !level.paperConfig().fixes.splitOverstackedLoot;
+ // Paper end
return (itemstack) -> {
if (itemstack.isItemEnabled(context.getLevel().enabledFeatures())) {
- if (itemstack.getCount() < itemstack.getMaxStackSize()) {
+ if (skipSplitter || itemstack.getCount() < itemstack.getMaxStackSize()) { // Paper - preserve overstacked items
consumer.accept(itemstack);
} else {
int i = itemstack.getCount();
+
while (i > 0) {
ItemStack itemstack1 = itemstack.copy();
@@ -97,7 +105,7 @@ public class LootTable {
}
public void getRandomItems(LootContext context, Consumer<ItemStack> lootConsumer) {
- this.getRandomItemsRaw(context, LootTable.createStackSplitter(context, lootConsumer));
+ this.getRandomItemsRaw(context, LootTable.createStackSplitter(context, lootConsumer, context.getLevel())); // Paper - preserve overstacked items
}
public ObjectArrayList<ItemStack> getRandomItems(LootContext context) {
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
index 880a0686519dc033b3c3b2bf0126f49af6fb48de..eddad9593bccd9e91fbb6d79fa2bdd766b004690 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/SetContainerContents.java
@@ -46,7 +46,7 @@ public class SetContainerContents extends LootItemConditionalFunction {
NonNullList<ItemStack> nonNullList = NonNullList.create();
this.entries.forEach((entry) -> {
entry.expand(context, (choice) -> {
- choice.createItemStack(LootTable.createStackSplitter(context, nonNullList::add), context);
+ choice.createItemStack(LootTable.createStackSplitter(context, nonNullList::add, context.getLevel()), context); // Paper - preserve overstacked items
});
});
CompoundTag compoundTag = new CompoundTag();