Skip to content

Commit

Permalink
Fix compile/run for 1.20.4
Browse files Browse the repository at this point in the history
Currently, /tick is disabled but is planned to be re-added.
It's unlikely that support for sprinting can be implemented
precisely due to the fact that Folia ticks many regions
independently. However, a best-effort approach will be used.
  • Loading branch information
Spottedleaf committed Dec 18, 2023
1 parent de6a87e commit cd713b8
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 80 deletions.
3 changes: 3 additions & 0 deletions build-data/dev-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
minecraft net.minecraft.world.TickRateManager
minecraft net.minecraft.server.ServerTickRateManager
minecraft net.minecraft.server.commands.TickCommand
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=dev.folia

version=1.20.4-R0.1-SNAPSHOT
mcVersion=1.20.4
paperRef=f1820dc80a02009980e6466ea5847933861b911a
paperRef=e3140fb70e818b9e3fd7becbb9842e7f24847bb5

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ the schedulers depending on the result of the ownership
check.

diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 4863d9f21f0a0f11974be85360edc587ffd7eab3..56548d416cb116b0f130a18a3c0ee8aed51a7be0 100644
index 48fab492609e0bae459d20cc2eae78b87e37ab75..00ed780f190fa1bf3c33fc093a46b4e914131e5f 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2827,6 +2827,14 @@ public final class Bukkit {
@@ -2837,6 +2837,14 @@ public final class Bukkit {
return server.isOwnedByCurrentRegion(entity);
}
// Paper end - Folia region threading API
Expand All @@ -30,10 +30,10 @@ index 4863d9f21f0a0f11974be85360edc587ffd7eab3..56548d416cb116b0f130a18a3c0ee8ae
@NotNull
public static Server.Spigot spigot() {
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index f1fa97d12f97baf97beb92ca0719cf3cf906b225..e25f86fb8d4bda9284744c0b8ae7db4f4f9f93a0 100644
index 9af4bc16da09e59009c47911219e99450cdf2aa5..8d51301e1a0a2a528353b90e2e2d0e4c69c6a4f5 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2473,4 +2473,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2481,4 +2481,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean isOwnedByCurrentRegion(@NotNull Entity entity);
// Paper end - Folia region threading API
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0001-Build-changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes


diff --git a/build.gradle.kts b/build.gradle.kts
index 170a915098f09ace226648da342a04c5c7583d11..512496d086b21bd0d5c5cc070a41185eedc6c2f1 100644
index b12b5a1e82a5ebf47135a3863a390a45a9d8d8ec..03abea227c555decd559dd58b33913127f3549a4 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -27,8 +27,12 @@ repositories {
Expand Down Expand Up @@ -106,10 +106,10 @@ index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..5ed6c8710b78458031ed6b0273fb2f6a

public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 782bb8ca67517dde5dba8f0a133eb8699353dd01..f4ba1b9adbd0e526421a755fd6c536fe20ffa716 100644
index e011cfcdda2e0a609d4158b0454bdf046b04c9d9..3e7b9561dd69b634149181be7a537d0546ceb233 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -270,7 +270,7 @@ import javax.annotation.Nullable; // Paper
@@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper

public final class CraftServer implements Server {
Expand Down
166 changes: 119 additions & 47 deletions patches/server/0003-Threaded-Regions.patch

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion patches/server/0004-Max-pending-logins.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Max pending logins
Should help the floodgates on launch

diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index d0f7434164f6241ec81c990c7a127f504e019291..8586df59afd0af51721a0950c7bf4582092417fc 100644
index 54aa8ac790f7d23d6404d037105642ddddb7839b..c18fc39db6480f0942128a5512970fdce074b7c6 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -89,7 +89,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,10 @@ index d657fd2c507a5b215aeab0a5f3e9c2ee892a27c8..9fc90b162aab15a9cd60b02aba563181
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index cd29fa29fa65060c21c715bd756c5a35429eeb96..c46d00843f4a1a1c482f18856a846c09eff30293 100644
index 9a4a7bae17dd554aeeffb0ec4cb0876ef797e097..a47939461fcf3ba9aabcf66d1db9738b9785314a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -845,7 +845,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -490,7 +490,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {

@Override
public UUID getUniqueId() {
Expand All @@ -909,7 +909,7 @@ index cd29fa29fa65060c21c715bd756c5a35429eeb96..c46d00843f4a1a1c482f18856a846c09
}

@Override
@@ -860,6 +860,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -505,6 +505,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}

public Entity getHandle() {
Expand Down Expand Up @@ -1359,10 +1359,10 @@ index 8746f80d08df5501b32958eb123aa7d814573ddf..c6c6eb55f4649e18beef9832c2ea7b9d
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index 8a1e765363aeb61078fd23980d3856dc680cb05e..98f2be104eb2882f8c841a637ba821d96e0bf6bd 100644
index c3dbcb317b7d366feb31f707ad1199c60169f07f..8f32a00e65254acb4752ae55fee86bc05964c13e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -292,8 +292,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@@ -291,8 +291,16 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
this.mode = mode;
}

Expand Down Expand Up @@ -1590,10 +1590,10 @@ index 70b377c03346cb8573827aeb493f3b6eb8efb1f8..b2e8c26162dd5782a0447cd03ca00fb4
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index ba2cd9c4cdbd5ddab1300320d7e0ede4d4b7a31a..66edfd724275c06b58d0a4a5fb5e484257850e36 100644
index 25ffc92c3d6055285a64d9fe36c0054228fe81dd..f2360767907480b64fd51ac3156932b9bf8ee609 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -418,6 +418,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -417,6 +417,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
this.getHandle().invulnerableTime = ticks;
}

Expand All @@ -1607,7 +1607,7 @@ index ba2cd9c4cdbd5ddab1300320d7e0ede4d4b7a31a..66edfd724275c06b58d0a4a5fb5e4842
@Override
public int getNoActionTicks() {
return this.getHandle().getNoActionTime();
@@ -431,6 +438,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@@ -430,6 +437,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {

@Override
public net.minecraft.world.entity.LivingEntity getHandle() {
Expand Down Expand Up @@ -2130,10 +2130,10 @@ index 2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf..0f5c2d31a2dea13a46ba81e353393633
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 374a845acc6b12eb82af4282d52e22f1291f77f7..7a8762a35cb47f86c64be00c220a997c8f9f5108 100644
index 0566674223e16e34eaa4ab1d21e0e060bd0aeee5..fca4f9a50e57a2b40c7bca92d975b72da1075fa3 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -619,7 +619,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -616,7 +616,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

@Override
public void kick(net.kyori.adventure.text.Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
Expand All @@ -2142,7 +2142,7 @@ index 374a845acc6b12eb82af4282d52e22f1291f77f7..7a8762a35cb47f86c64be00c220a997c
final ServerGamePacketListenerImpl connection = this.getHandle().connection;
if (connection != null) {
connection.disconnect(message == null ? net.kyori.adventure.text.Component.empty() : message, cause);
@@ -2162,9 +2162,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2159,9 +2159,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this;
}

Expand All @@ -2160,7 +2160,7 @@ index 374a845acc6b12eb82af4282d52e22f1291f77f7..7a8762a35cb47f86c64be00c220a997c
}

public void setHandle(final ServerPlayer entity) {
@@ -3162,7 +3169,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -3172,7 +3179,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
{
if ( CraftPlayer.this.getHealth() <= 0 && CraftPlayer.this.isOnline() )
{
Expand Down Expand Up @@ -2234,10 +2234,10 @@ index 35a8219734633529325430810e88755b2dd23125..85ebd34ed143304c603078f2e949179a
}

diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java
index eb7e2902dc134847711284dd2af8abda7627c7ab..9fd64b06e973527e6fb808cc836490f75dfb9bea 100644
index 519ef701a7d6534f7cb516f6296b95ee521f661d..effbc1a3ef8c6c9cd424f49b8bfce05d40e0772a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java
@@ -11,8 +11,16 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
@@ -10,8 +10,16 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
super(server, entity);
}

Expand Down
2 changes: 1 addition & 1 deletion patches/server/0007-Disable-mid-tick-task-execution.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ the impact from scaling the region threads, but is not a fix
to the underlying issue.

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 99a086ed2c0d5615a55539a31b8cd8483569e9c0..844424e7488eb42753f50e0e998aebf93c912877 100644
index ec1c5bf4b2e4a54e9df085331416bac0b42c601d..027d95e0763c6e18380b706fcd7f48c09a7cc17a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1469,6 +1469,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ Subject: [PATCH] Throw UnsupportedOperationException() for broken APIs


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d2c8ad04c59035449dc798a637acc6e809d35fc4..7cbf625384f02e3c8c40a57cd5582ecaca4bd15c 100644
index 6e2bbd699d9b168ee9eb89461d588701c0511a24..bea388ced64da6192166f6f8461abdc0921ed7b0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1263,6 +1263,7 @@ public final class CraftServer implements Server {
@@ -1264,6 +1264,7 @@ public final class CraftServer implements Server {

@Override
public World createWorld(WorldCreator creator) {
+ if (true) throw new UnsupportedOperationException(); // Folia - not implemented properly yet
Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP");
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
@@ -1442,6 +1443,7 @@ public final class CraftServer implements Server {
@@ -1443,6 +1444,7 @@ public final class CraftServer implements Server {

@Override
public boolean unloadWorld(World world, boolean save) {
Expand All @@ -25,7 +25,7 @@ index d2c8ad04c59035449dc798a637acc6e809d35fc4..7cbf625384f02e3c8c40a57cd5582eca
if (world == null) {
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
index 81889e30a634ac84d996f688d0a2466e9efa19ca..f2ad3247b512ed5115dea475035736eddc038c7e 100644
index bd8a5bb2b84daf013750aec9887dcb4b02b382ad..299e7290fea260d739687be70a796c5a4add325b 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboard.java
@@ -45,6 +45,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0018-Region-profiler.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ index 98fb69a9adeb6eaab199aec127692acb07f56808..7cc624505931dcb6696c3ef3ee3bbea7
label25:
{
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 844424e7488eb42753f50e0e998aebf93c912877..d04862c5f06bafb67b055959ddfe8334914cf5c7 100644
index 027d95e0763c6e18380b706fcd7f48c09a7cc17a..9ea861c1531c5f9d8a87e45512336eba3bddf06a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1585,6 +1585,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand Down Expand Up @@ -1436,15 +1436,15 @@ index 844424e7488eb42753f50e0e998aebf93c912877..d04862c5f06bafb67b055959ddfe8334
this.profiler.pop();
// Paper end
io.papermc.paper.util.CachedLists.reset(); // Paper
@@ -1748,6 +1762,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1730,6 +1744,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}

public void tickChildren(BooleanSupplier shouldKeepTicking, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - region threading
+ final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler
final io.papermc.paper.threadedregions.RegionizedWorldData regionizedWorldData = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegionizedWorldData(); // Folia - regionised ticking
if (region == null) this.getPlayerList().getPlayers().forEach((entityplayer) -> { // Folia - region threading
entityplayer.connection.suspendFlushing();
@@ -1814,12 +1829,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1796,12 +1811,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

try {
worldserver.timings.doTick.startTiming(); // Spigot
Expand Down
4 changes: 2 additions & 2 deletions update.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
- Fix compile
- Tick rate manager - what to do with you (also: check tickChunks [specifically inhabited time] with respect to how this works now)
- Tick rate manager - what to do with you (also: check tickChunks [specifically inhabited time] with respect to how this works now)
- Change chunk system autosave to use nanoTime instead of ticks to account for variable tick rate

0 comments on commit cd713b8

Please sign in to comment.