Skip to content

Commit

Permalink
Patches!!! (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen1212055 committed Dec 6, 2023
1 parent 25dc4af commit 6bf2ebf
Show file tree
Hide file tree
Showing 70 changed files with 238 additions and 311 deletions.
16 changes: 9 additions & 7 deletions patches/server/0688-Optimise-random-block-ticking.patch
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ 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 81381a4b401046b2ea76627814c740dca73b9592..8144c2f519876a3e33150e4fbebea3aadaf5ce31 100644
index 81381a4b401046b2ea76627814c740dca73b9592..5d0ea7d1cd52469f9951b5b4db2daa0f9ab1b7d8 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -856,6 +856,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand Down Expand Up @@ -128,7 +128,7 @@ index 81381a4b401046b2ea76627814c740dca73b9592..8144c2f519876a3e33150e4fbebea3aa
}
}
} // Paper
@@ -906,54 +915,60 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -906,36 +915,37 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.popPush("tickBlocks");
timings.chunkTicksBlocks.startTiming(); // Paper
if (randomTickSpeed > 0) {
Expand Down Expand Up @@ -190,14 +190,16 @@ index 81381a4b401046b2ea76627814c740dca73b9592..8144c2f519876a3e33150e4fbebea3aa

timings.chunkTicksBlocks.stopTiming(); // Paper
gameprofilerfiller.pop();
}
@@ -943,17 +953,25 @@ public class ServerLevel extends Level implements WorldGenLevel {

@VisibleForTesting
- public void tickPrecipitation(BlockPos pos) {
public void tickPrecipitation(BlockPos pos) {
- BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
- BlockPos blockposition2 = blockposition1.below();
+ public void tickPrecipitation(BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) { // Paper - optimise chunk ticking
+ // Paper start - optimise chunk ticking
+ // Paper start - optimise chunk ticking
+ tickPrecipitation(pos.mutable(), this.getChunkAt(pos));
+ }
+ public void tickPrecipitation(BlockPos.MutableBlockPos blockposition1, final LevelChunk chunk) {
+ int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition1.getX() & 15, blockposition1.getZ() & 15) + 1;
+ int downY = normalY - 1;
+ blockposition1.setY(normalY);
Expand All @@ -218,7 +220,7 @@ index 81381a4b401046b2ea76627814c740dca73b9592..8144c2f519876a3e33150e4fbebea3aa
if (i > 0 && biomebase.shouldSnow(this, blockposition1)) {
BlockState iblockdata = this.getBlockState(blockposition1);

@@ -971,12 +986,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -971,12 +989,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ index 7de24c39b460e43d27839b3821e67213508ece81..7297bca9224c12d7ace0e1967340d994
});
throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD;
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8144c2f519876a3e33150e4fbebea3aadaf5ce31..844a708fa64fa023370f6a5ac386956f56b0545a 100644
index 5d0ea7d1cd52469f9951b5b4db2daa0f9ab1b7d8..baa70699c3f8960b39af38502f40d43c8580e9ab 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1237,7 +1237,26 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1240,7 +1240,26 @@ public class ServerLevel extends Level implements WorldGenLevel {

}

Expand All @@ -106,7 +106,7 @@ index 8144c2f519876a3e33150e4fbebea3aadaf5ce31..844a708fa64fa023370f6a5ac386956f
++TimingHistory.entityTicks; // Paper - timings
// Spigot start
co.aikar.timings.Timing timer; // Paper
@@ -1277,7 +1296,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1280,7 +1299,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
this.tickPassenger(entity, entity1);
}
// } finally { timer.stopTiming(); } // Paper - timings - move up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 844a708fa64fa023370f6a5ac386956f56b0545a..4df6572f2babbaeece0c62750cc913a78af9c282 100644
index baa70699c3f8960b39af38502f40d43c8580e9ab..b9b7896c2f850f9a02900932ea9255dc0aa07e26 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2680,6 +2680,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -2683,6 +2683,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable max block light for monster spawning


diff --git a/src/main/java/net/minecraft/world/entity/monster/Monster.java b/src/main/java/net/minecraft/world/entity/monster/Monster.java
index 6e0bd0eab0b06a4ac3042496bbb91292544e9f3c..e4218acaaf7d3aef0fb31f5597fb1af32aa2c8b5 100644
index 036d79baf372f4900681fee366bcd91c99474e5f..127a344f35e194fc7b1a0783c75291fab929fe19 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Monster.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Monster.java
@@ -93,7 +93,7 @@ public abstract class Monster extends PathfinderMob implements Enemy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Co-authored-by: Zach Brown <zach@zachbr.io>
Co-authored-by: Madeline Miller <mnmiller1@me.com>

diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index b9896fd8e96a908637ce1edf9413166192903ce7..cdcf11fb9e4690d74b30fe0ade842d6574464624 100644
index cda90023ad662e8875365eac98ec69f476dcb42d..b9025fcc6a4db9533cdc42034c9e77323d0785fa 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -146,15 +146,15 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -159,15 +159,15 @@ public class PistonBaseBlock extends DirectionalBlock {
}

// CraftBukkit start
Expand All @@ -55,7 +55,7 @@ index b9896fd8e96a908637ce1edf9413166192903ce7..cdcf11fb9e4690d74b30fe0ade842d65
// PAIL: checkME - what happened to setTypeAndData?
// CraftBukkit end
world.blockEvent(pos, this, b0, enumdirection.get3DDataValue());
@@ -237,6 +237,13 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -250,6 +250,13 @@ public class PistonBaseBlock extends DirectionalBlock {

BlockState iblockdata2 = (BlockState) ((BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(MovingPistonBlock.FACING, enumdirection)).setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT);

Expand All @@ -69,7 +69,7 @@ index b9896fd8e96a908637ce1edf9413166192903ce7..cdcf11fb9e4690d74b30fe0ade842d65
world.setBlock(pos, iblockdata2, 20);
world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata2, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true)); // Paper - diff on change
world.blockUpdated(pos, iblockdata2.getBlock());
@@ -263,6 +270,13 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -276,6 +283,13 @@ public class PistonBaseBlock extends DirectionalBlock {
if (type == 1 && !iblockdata3.isAir() && PistonBaseBlock.isPushable(iblockdata3, world, blockposition1, enumdirection.getOpposite(), false, enumdirection) && (iblockdata3.getPistonPushReaction() == PushReaction.NORMAL || iblockdata3.is(Blocks.PISTON) || iblockdata3.is(Blocks.STICKY_PISTON))) {
this.moveBlocks(world, pos, enumdirection, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Fixes bees incorrectly being aged up due to upstream's
resetting the ticks inside hive on a failed release

diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
index 9d4152f9fde93a832f263c793955d327f1e078f7..cf09525efd2d53bf884cd6ec3b0b9229715895eb 100644
index 8c4fba5369e5e25f144291c43e086b7417b013aa..dfd364ac4b7551a13c4c6c100b5e62c0dfb10595 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
@@ -328,7 +328,7 @@ public class BeehiveBlockEntity extends BlockEntity {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ Subject: [PATCH] Validate usernames


diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 2e73c94f74be95a7d6ba58d5151c3090253bb9c6..3a177569b9aa8d641252d0169bea8be739344318 100644
index 0c4fb4a7d4fcdc6d724beb13a16bd729a3c525cd..20ba13c06edf125ba216d1ca8794868abcd8f916 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -61,6 +61,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@@ -63,6 +63,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
public GameProfile authenticatedProfile; // Paper - public
private final String serverId;
private ServerPlayer player; // CraftBukkit
+ public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding

public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection) {
this.state = ServerLoginPacketListenerImpl.State.HELLO;
@@ -132,10 +133,38 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@@ -134,10 +135,38 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
return this.requestedUsername != null ? this.requestedUsername + " (" + s + ")" : s;
}

Expand All @@ -43,8 +43,8 @@ index 2e73c94f74be95a7d6ba58d5151c3090253bb9c6..3a177569b9aa8d641252d0169bea8be7
@Override
public void handleHello(ServerboundHelloPacket packet) {
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
+ // Paper start - validate usernames
Validate.validState(Player.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
+ // Paper start - validate usernames -- TODO: Do we need this?
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) {
+ if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) {
+ ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!");
Expand All @@ -56,10 +56,10 @@ index 2e73c94f74be95a7d6ba58d5151c3090253bb9c6..3a177569b9aa8d641252d0169bea8be7
GameProfile gameprofile = this.server.getSingleplayerProfile();

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 9010da755303a9c5bb9a2fbacaf6bcfd6db9e3af..7a305967fa532eb9eb4e6cfdb5d80f4192181d42 100644
index c92545e3cd199c7e123f65d42ca8976d2da27509..1e15c3576b6b506335c66a4ca0a47f3aa178c72a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -681,7 +681,7 @@ public abstract class PlayerList {
@@ -679,7 +679,7 @@ public abstract class PlayerList {

for (int i = 0; i < this.players.size(); ++i) {
entityplayer = (ServerPlayer) this.players.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Make water animal spawn height configurable


diff --git a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
index 36c4f9a8d3b56dd28f6291cc6958b00364f7a394..cd2ce5bcb8c30e4657cd0e340d80544c7e805905 100644
index 27624b080e025d943b9c99627568f7dd66165548..827912174ee08cd19249797d351887149b25c880 100644
--- a/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
+++ b/src/main/java/net/minecraft/world/entity/animal/WaterAnimal.java
@@ -78,6 +78,10 @@ public abstract class WaterAnimal extends PathfinderMob {
@@ -73,6 +73,10 @@ public abstract class WaterAnimal extends PathfinderMob {
public static boolean checkSurfaceWaterAnimalSpawnRules(EntityType<? extends WaterAnimal> type, LevelAccessor world, MobSpawnType reason, BlockPos pos, RandomSource random) {
int i = world.getSeaLevel();
int j = i - 13;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Expose vanilla BiomeProvider from WorldInfo


diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f7c1d07c95f7b67e32bd6679af88612aec74f54f..9d4c9368fcc3a44e452c1b71b5bdb43d097132d2 100644
index 0a23cfeaba071c2179de1931caa86bc46462c338..bc181f3f59eef3f2f3645e3facb37d5e4a605d34 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -550,7 +550,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -596,7 +596,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(iworlddataserver));
LevelStem worlddimension = (LevelStem) dimensions.get(dimensionKey);

Expand All @@ -18,10 +18,10 @@ index f7c1d07c95f7b67e32bd6679af88612aec74f54f..9d4c9368fcc3a44e452c1b71b5bdb43d
biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index dbddca7d3188c7729d276159f2fb05300fdd97ed..43877a44ff5c0af7ff4819b63d234af6d9c32b11 100644
index 77ca534fda8bf1a36e51e857dcbc1d4f5fe5c6de..92acff9a1079b7fa4d3781f423b17fe67b7fe495 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1225,7 +1225,7 @@ public final class CraftServer implements Server {
@@ -1257,7 +1257,7 @@ public final class CraftServer implements Server {
List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(worlddata));
LevelStem worlddimension = iregistry.get(actualDimension);

Expand All @@ -31,10 +31,10 @@ index dbddca7d3188c7729d276159f2fb05300fdd97ed..43877a44ff5c0af7ff4819b63d234af6
biomeProvider = generator.getDefaultBiomeProvider(worldInfo);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index e45d6bcf2d604b7412f8c19469ee6f0f9a5e727a..fec640da33879e09a8564e2c579dd0f0302d809d 100644
index 3a5843b50a5cc5110bf484f9697674e5bfc9699f..fe895166c0526ff30d6941f1bf4d419f30801320 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -205,6 +205,29 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -206,6 +206,29 @@ public class CraftWorld extends CraftRegionAccessor implements World {
public int getPlayerCount() {
return world.players().size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Multiple Entries with Scoreboards


diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
index ee37ec0de1ca969144824427ae42b0c81434a1b4..4ebe22ac20f1a98694cc3bec570ef5bbf06f00aa 100644
index e52644010dc2cf41bbf508b16b8ec2f0003e9d0b..b25f0e0a4ea12de2606d273e7c1ee534002c8d5a 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
@@ -42,6 +42,12 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
Expand All @@ -22,10 +22,10 @@ index ee37ec0de1ca969144824427ae42b0c81434a1b4..4ebe22ac20f1a98694cc3bec570ef5bb
this.name = buf.readUtf();
this.method = buf.readByte();
diff --git a/src/main/java/net/minecraft/server/ServerScoreboard.java b/src/main/java/net/minecraft/server/ServerScoreboard.java
index e84332b6f031e83283c1b6e90bb82a6053ff46d7..03d13c2425170a6513ea7442a4a12fc9aa6e211d 100644
index c4904b358fc2f493e6a9572a84b8110a927da208..5cc8173e845bf8d3414ac3347d25e1f6d0c65ce9 100644
--- a/src/main/java/net/minecraft/server/ServerScoreboard.java
+++ b/src/main/java/net/minecraft/server/ServerScoreboard.java
@@ -95,6 +95,25 @@ public class ServerScoreboard extends Scoreboard {
@@ -104,6 +104,25 @@ public class ServerScoreboard extends Scoreboard {
}
}

Expand All @@ -49,9 +49,9 @@ index e84332b6f031e83283c1b6e90bb82a6053ff46d7..03d13c2425170a6513ea7442a4a12fc9
+ // Paper end
+
@Override
public void removePlayerFromTeam(String playerName, PlayerTeam team) {
super.removePlayerFromTeam(playerName, team);
@@ -102,6 +121,17 @@ public class ServerScoreboard extends Scoreboard {
public void removePlayerFromTeam(String scoreHolderName, PlayerTeam team) {
super.removePlayerFromTeam(scoreHolderName, team);
@@ -111,6 +130,17 @@ public class ServerScoreboard extends Scoreboard {
this.setDirty();
}

Expand Down
Loading

0 comments on commit 6bf2ebf

Please sign in to comment.