diff --git a/build.gradle.kts b/build.gradle.kts index 4b1b61583..bb824e88e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent plugins { - id("io.papermc.paperweight.patcher") version "2.0.0-beta.17" + id("io.papermc.paperweight.patcher") version "2.0.0-beta.19" } paperweight { diff --git a/gradle.properties b/gradle.properties index a711ffeb1..6e91246d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,16 @@ -org.gradle.configuration-cache=true -org.gradle.caching=true -org.gradle.parallel=true -org.gradle.vfs.watch=true +group = gg.pufferfish.pufferfish +version = 1.21.11-R0.1-SNAPSHOT -org.gradle.jvmargs="-Xmx6G" +# This is the current API version for use in (paper-)plugin.yml files +# During snapshot cycles this should be the anticipated version of the release target +apiVersion = 1.21.11 +mcVersion = 1.21.11 -group=gg.pufferfish.pufferfish -version=1.21.8-R0.1-SNAPSHOT -mcVersion=1.21.8 -paperRef=ed31825a8d9d4016a1fcd4c10b24926b51ced4cc -paperweight.defaultMinFuzz=0.1 +paperRef = b36b49ac236c3ce5bf0a2c3991f3411733495bd5 + +paperweight.defaultMinFuzz = 0.1 +org.gradle.configuration-cache = true +org.gradle.caching = true +org.gradle.parallel = true +org.gradle.vfs.watch = false +org.gradle.jvmargs = -Xmx4G diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c7..f8e1ee312 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 407c905d9..23449a2b5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-rc-1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index ef07e0162..adff685a0 100755 --- a/gradlew +++ b/gradlew @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index 5eed7ee84..e509b2dd8 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/pufferfork-api/build.gradle.kts.patch b/pufferfork-api/build.gradle.kts.patch index 9607334f4..0ac879ae5 100644 --- a/pufferfork-api/build.gradle.kts.patch +++ b/pufferfork-api/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts -@@ -51,6 +_,7 @@ +@@ -52,6 +_,7 @@ api("org.apache.logging.log4j:log4j-api:$log4jVersion") api("org.slf4j:slf4j-api:$slf4jVersion") api("com.mojang:brigadier:1.3.10") @@ -8,7 +8,7 @@ // Deprecate bungeecord-chat in favor of adventure api("net.md-5:bungeecord-chat:$bungeeCordChatVersion") { -@@ -84,13 +_,13 @@ +@@ -85,13 +_,13 @@ testImplementation("org.apache.commons:commons-lang3:3.17.0") testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") testImplementation("org.hamcrest:hamcrest:2.2") @@ -24,7 +24,7 @@ idea { module { generatedSourceDirs.add(generatedDir.toFile()) -@@ -100,6 +_,18 @@ +@@ -101,6 +_,18 @@ main { java { srcDir(generatedDir) @@ -43,21 +43,7 @@ } } } -@@ -147,6 +_,13 @@ - } - } - -+// Pufferfish Start -+tasks.withType { -+ val compilerArgs = options.compilerArgs -+ compilerArgs.add("--add-modules=jdk.incubator.vector") -+} -+// Pufferfish End -+ - tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") -@@ -166,8 +_,9 @@ +@@ -183,8 +_,9 @@ tasks.withType().configureEach { val options = options as StandardJavadocDocletOptions @@ -68,7 +54,7 @@ options.isDocFilesSubDirs = true options.links( "https://guava.dev/releases/33.3.1-jre/api/docs/", -@@ -199,11 +_,11 @@ +@@ -216,11 +_,11 @@ } // workaround for https://github.com/gradle/gradle/issues/4046 @@ -82,7 +68,21 @@ include("**/doc-files/**") } into("build/docs/javadoc") -@@ -218,6 +_,7 @@ +@@ -228,6 +_,13 @@ + } + } + ++// Pufferfish Start ++tasks.withType { ++ val compilerArgs = options.compilerArgs ++ compilerArgs.add("--add-modules=jdk.incubator.vector") ++} ++// Pufferfish End ++ + tasks.test { + useJUnitPlatform() + +@@ -235,6 +_,7 @@ val provider = objects.newInstance() provider.fileCollection.from(mockitoAgent) jvmArgumentProviders.add(provider) diff --git a/pufferfork-api/paper-patches/features/0001-Add-Sentry.patch b/pufferfork-api/paper-patches/features/0001-Add-Sentry.patch index 58f72795f..74d61dca6 100644 --- a/pufferfork-api/paper-patches/features/0001-Add-Sentry.patch +++ b/pufferfork-api/paper-patches/features/0001-Add-Sentry.patch @@ -102,10 +102,10 @@ index 163e9a0e179dc88be93614ff66ee2be3eccc694f..78cdf669328fc1ec5e9943033a11d220 if (cloader instanceof PluginClassLoader) { diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java -index 0bc98377ac5533c9d6fe1b99c99d86201971a100..b419678018a9bf8649d3071c38bfa3d0b46f2036 100644 +index 135c77b05dfded979d6e23956d31c34893f0b7f6..77421563451f5c2a6dc344d284d3d5c36acd92f1 100644 --- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java +++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java -@@ -206,6 +206,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm +@@ -209,6 +209,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm throw new ClassNotFoundException(name); } diff --git a/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/map/MapPalette.java.patch b/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/map/MapPalette.java.patch index 92d92cb2b..2c0031cb0 100644 --- a/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/map/MapPalette.java.patch +++ b/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/map/MapPalette.java.patch @@ -1,6 +1,6 @@ --- a/src/main/java/org/bukkit/map/MapPalette.java +++ b/src/main/java/org/bukkit/map/MapPalette.java -@@ -395,9 +_,15 @@ +@@ -394,9 +_,15 @@ temp.getRGB(0, 0, temp.getWidth(), temp.getHeight(), pixels, 0, temp.getWidth()); byte[] result = new byte[temp.getWidth() * temp.getHeight()]; @@ -16,7 +16,7 @@ return result; } -@@ -500,4 +_,18 @@ +@@ -511,4 +_,18 @@ @org.jetbrains.annotations.ApiStatus.Internal // Paper byte matchColor(@NotNull Color color); } diff --git a/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java.patch b/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java.patch index 251268b54..8d7c0c76f 100644 --- a/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java.patch +++ b/pufferfork-api/paper-patches/files/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java.patch @@ -8,7 +8,7 @@ static { ClassLoader.registerAsParallelCapable(); -@@ -212,7 +_,7 @@ +@@ -215,7 +_,7 @@ } Class result = classes.get(name); @@ -17,7 +17,7 @@ String path = name.replace('.', '/').concat(".class"); // Add details to zip file errors - help debug classloading JarEntry entry; -@@ -268,6 +_,7 @@ +@@ -271,6 +_,7 @@ this.setClass(name, result); // Paper } @@ -25,7 +25,7 @@ return result; } -@@ -282,7 +_,8 @@ +@@ -285,7 +_,8 @@ // Paper end super.close(); } finally { diff --git a/pufferfork-server/build.gradle.kts.patch b/pufferfork-server/build.gradle.kts.patch index ff6f488fd..c352b0e2d 100644 --- a/pufferfork-server/build.gradle.kts.patch +++ b/pufferfork-server/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts -@@ -26,6 +_,17 @@ +@@ -22,6 +_,17 @@ minecraftVersion = providers.gradleProperty("mcVersion") gitFilePatches = false @@ -17,8 +17,8 @@ + spigot { enabled = true - buildDataRef = "436eac9815c211be1a2a6ca0702615f995e81c44" -@@ -107,7 +_,21 @@ + buildDataRef = "17f77cee7117ab9d6175f088ae8962bfd04e61a9" +@@ -104,7 +_,21 @@ } } @@ -41,16 +41,16 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { extendsFrom(configurations.compileClasspath.get()) } -@@ -129,7 +_,7 @@ +@@ -127,7 +_,7 @@ } dependencies { - implementation(project(":paper-api")) + implementation(project(":pufferfork-api")) // Pufferfork - implementation("ca.spottedleaf:concurrentutil:0.0.3") + implementation("ca.spottedleaf:concurrentutil:0.0.8") implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 -@@ -165,6 +_,13 @@ +@@ -162,6 +_,13 @@ isTransitive = false // includes junit } @@ -59,13 +59,13 @@ + exclude(group="org.yaml", module="snakeyaml") + } + // Pufferfish end -+ implementation("net.serlith:Flare:4.0.3") // Pufferfish - flare ++ implementation("net.serlith:Flare:4.0.9") // Pufferfish - flare + testImplementation("io.github.classgraph:classgraph:4.8.179") // For mob goal test + testRuntimeOnly("org.junit.platform:junit-platform-launcher") testImplementation("org.junit.jupiter:junit-jupiter:5.12.2") - testImplementation("org.junit.platform:junit-platform-suite-engine:1.12.2") -@@ -188,6 +_,13 @@ - implementation("me.lucko:spark-paper:1.10.133-20250413.112336-1") +@@ -186,6 +_,13 @@ + implementation("me.lucko:spark-paper:1.10.152") } +// Pufferfish Start - SIMD Optimizations @@ -78,7 +78,7 @@ tasks.jar { manifest { val git = Git(rootProject.layout.projectDirectory.path) -@@ -200,14 +_,14 @@ +@@ -198,14 +_,14 @@ val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", @@ -98,7 +98,7 @@ "Build-Number" to (build ?: ""), "Build-Time" to buildTime.toString(), "Git-Branch" to gitBranch, -@@ -266,7 +_,7 @@ +@@ -264,7 +_,7 @@ jvmArgumentProviders.add(provider) } diff --git a/pufferfork-server/minecraft-patches/features/0001-Dynamic-Activation-of-Brain.patch b/pufferfork-server/minecraft-patches/features/0001-Dynamic-Activation-of-Brain.patch index 292c56940..2922842ef 100644 --- a/pufferfork-server/minecraft-patches/features/0001-Dynamic-Activation-of-Brain.patch +++ b/pufferfork-server/minecraft-patches/features/0001-Dynamic-Activation-of-Brain.patch @@ -26,82 +26,99 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . -// note - reworked based on kennytv's pr to paper to apply to all entities that have brain; see https://github.com/PaperMC/Paper/pull/9712 - -Co-authored-by: Nassim Jahnke - diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java -index 0a9970d015ec65997a1882e01339d52cf0b7350e..44be21a736c0d94b7ea0d0b47e5b40bfd09497ad 100644 +index 0a9970d015ec65997a1882e01339d52cf0b7350e..c536cf050f9df235bae990fff0484957905a5fe7 100644 --- a/io/papermc/paper/entity/activation/ActivationRange.java +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -39,6 +39,7 @@ import net.minecraft.world.phys.AABB; import org.spigotmc.SpigotWorldConfig; import java.util.List; import java.util.Set; -+import net.minecraft.world.phys.Vec3; // Pufferfork - DAB ++import net.minecraft.world.phys.Vec3; // Pufferfish public final class ActivationRange { -@@ -165,6 +166,22 @@ public final class ActivationRange { +@@ -165,6 +166,24 @@ public final class ActivationRange { } ActivationRange.activateEntity(entity); + -+ // Pufferfork start - DAB -+ if (entity instanceof LivingEntity livingEntity) { -+ if (gg.pufferfish.pufferfish.PufferfishConfig.dearEnabled && livingEntity.getType().dabEnabled) { -+ Vec3 playerVec = player.position(); -+ Vec3 entityVec = entity.position(); -+ final double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z; -+ final int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ); -+ livingEntity.activatedPriority = squaredDistance > gg.pufferfish.pufferfish.PufferfishConfig.startDistanceSquared ? -+ Math.max(1, Math.min(squaredDistance >> gg.pufferfish.pufferfish.PufferfishConfig.activationDistanceMod, livingEntity.activatedPriority)) : -+ 1; -+ } else { -+ livingEntity.activatedPriority = 1; ++ // Pufferfish start ++ if (gg.pufferfish.pufferfish.PufferfishConfig.dearEnabled && entity.getType().dabEnabled) { ++ if (!entity.activatedPriorityReset) { ++ entity.activatedPriorityReset = true; ++ entity.activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; + } -+ // Pufferfork end ++ Vec3 playerVec = player.position(); ++ Vec3 entityVec = entity.position(); ++ double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z; ++ int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ); ++ entity.activatedPriority = squaredDistance > gg.pufferfish.pufferfish.PufferfishConfig.startDistanceSquared ? ++ Math.max(1, Math.min(squaredDistance >> gg.pufferfish.pufferfish.PufferfishConfig.activationDistanceMod, entity.activatedPriority)) : ++ 1; ++ } else { ++ entity.activatedPriority = 1; + } ++ // Pufferfish end } } } +@@ -176,11 +195,11 @@ public final class ActivationRange { + */ + private static void activateEntity(final Entity entity) { + if (MinecraftServer.currentTick > entity.activatedTick) { +- if (entity.defaultActivationState) { ++ if (entity.defaultActivationState) { // Pufferfish - diff on change + entity.activatedTick = MinecraftServer.currentTick; + return; + } +- if (entity.activationType.boundingBox.intersects(entity.getBoundingBox())) { ++ if (entity.activationType.boundingBox.intersects(entity.getBoundingBox())) { // Pufferfish - diff on change + entity.activatedTick = MinecraftServer.currentTick; + } + } +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index 9990a997470c5b6a537992a1bf158c16214c66cc..6af2c89916985ac768823bbc895a90269af1156e 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -820,6 +820,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + this.entityTickList + .forEach( + entity -> { ++ entity.activatedPriorityReset = false; // Pufferfish - DAB + if (!entity.isRemoved()) { + if (!tickRateManager.isEntityFrozen(entity)) { + profilerFiller.push("checkDespawn"); +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index 2e3e038874757049445a91bf590d5a1a427a3f6d..583c0a460e01dd24963ad3345d52b269d0bc98c7 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -365,6 +365,8 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + public boolean freezeLocked = false; // Paper - Freeze Tick Lock API + public boolean fixedPose = false; // Paper - Expand Pose API + private final int despawnTime; // Paper - entity despawn time limit ++ public boolean activatedPriorityReset = false; // Pufferfish - DAB ++ public int activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // Pufferfish - DAB (golf score) + public int totalEntityAge; // Paper - age-like counter for all entities + public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges + // Paper start - EAR 2 diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index cdf71340278e05e58bbb4ed51a432336de46e549..d27b3b03330a8c61871af190ddea665566f7222e 100644 +index 4706a41ecaccd20fc623ce64858b160204f60f9e..6c65b1fcae5cbfd32802ae94effa492f1e37cf73 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -185,6 +185,7 @@ public class EntityType implements FeatureElement, EntityTypeT - public static final Codec> CODEC = BuiltInRegistries.ENTITY_TYPE.byNameCodec(); - private static final float MAGIC_HORSE_WIDTH = 1.3964844F; - private static final int DISPLAY_TRACKING_RANGE = 10; -+ public boolean dabEnabled; // Pufferfork - DAB - public static final EntityType ACACIA_BOAT = register( - "acacia_boat", - EntityType.Builder.of(boatFactory(() -> Items.ACACIA_BOAT), MobCategory.MISC) -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index aee7b3a63c5f0c974b431edee11e423f5d9557c4..6f0f998512a413f76de40d16605e2659d99cf91a 100644 ---- a/net/minecraft/world/entity/LivingEntity.java -+++ b/net/minecraft/world/entity/LivingEntity.java -@@ -287,6 +287,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API - public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; // Paper - Make shield blocking delay configurable - // CraftBukkit end -+ public int activatedPriority; // Pufferfork - DAB - - protected LivingEntity(EntityType entityType, Level level) { - super(entityType, level); -@@ -300,6 +301,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - this.setYRot((float)(Math.random() * (float) (Math.PI * 2))); - this.yHeadRot = this.getYRot(); - this.brain = this.makeBrain(EMPTY_BRAIN); -+ this.activatedPriority = gg.pufferfish.pufferfish.PufferfishConfig.maximumActivationPrio; // Pufferfork - DAB (golf score) - } - - @Contract( +@@ -1194,6 +1194,7 @@ public class EntityType implements FeatureElement, EntityTypeT + private final int clientTrackingRange; + private final int updateInterval; + private final String descriptionId; ++ public boolean dabEnabled = false; // Pufferfish + @Nullable + private Component description; + private final Optional> lootTable; diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 5794b6c74ba6c78039b8c614e7bb1b18d7293dfc..179497f212dda941b0e0fc45dbe563546583c1da 100644 +index 078cda1e103b1da3c0b33465819ab34dfa649227..8ccb6aec85a41ef3cd4f6918f348f886eceaf132 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -213,10 +213,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -223,10 +223,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab public void inactiveTick() { super.inactiveTick(); boolean isThrottled = gg.pufferfish.pufferfish.PufferfishConfig.throttleInactiveGoalSelectorTick && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking setting @@ -114,7 +131,7 @@ index 5794b6c74ba6c78039b8c614e7bb1b18d7293dfc..179497f212dda941b0e0fc45dbe56354 this.targetSelector.tick(); } } -@@ -763,16 +763,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -774,16 +774,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab int i = this.tickCount + this.getId(); if (i % 2 != 0 && this.tickCount > 1) { profilerFiller.push("targetSelector"); @@ -135,130 +152,201 @@ index 5794b6c74ba6c78039b8c614e7bb1b18d7293dfc..179497f212dda941b0e0fc45dbe56354 this.goalSelector.tick(); profilerFiller.pop(); } -diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java -index 98652c2c549bd7657a606d25ba4fe3cffa0548da..1f960e5cbec0048d0936d107dab464a4d12a637d 100644 ---- a/net/minecraft/world/entity/ai/Brain.java -+++ b/net/minecraft/world/entity/ai/Brain.java -@@ -55,6 +55,12 @@ public class Brain { - private final Set activeActivities = Sets.newHashSet(); - private Activity defaultActivity = Activity.IDLE; - private long lastScheduleUpdate = -9999L; -+ // Pufferfork start - DAB -+ private int behaviorTick; -+ private boolean dirtyMemories = true; -+ private boolean dirtyActivities = true; -+ private boolean active; -+ // Pufferfork end - DAB +diff --git a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java +index f6c673b1abe53afcb14fd68d590431027ed29f67..21deb221b87ecb70c8a0dc963ab79124b26ac930 100644 +--- a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java ++++ b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java +@@ -36,7 +36,11 @@ public class VillagerPanicTrigger extends Behavior { - public static Brain.Provider provider( - Collection> memoryTypes, Collection>> sensorTypes -@@ -161,6 +167,7 @@ public class Brain { + @Override + protected void tick(ServerLevel level, Villager owner, long gameTime) { +- if (gameTime % 100L == 0L) { ++ // Pufferfish start ++ if (owner.nextGolemPanic < 0) owner.nextGolemPanic = gameTime + 100; ++ if (--owner.nextGolemPanic < gameTime) { ++ owner.nextGolemPanic = -1; ++ // Pufferfish end + owner.spawnGolemIfNeeded(level, gameTime, 3); + } } - - public void clearMemories() { -+ this.dirtyMemories = true; // Pufferfork - DAB - this.memories.keySet().forEach(memoryModuleType -> this.memories.put((MemoryModuleType)memoryModuleType, Optional.empty())); +diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java +index 859b859d29b637200cf7c9a0bd52d9f712413e3d..6b7c619a255aea1a2e7432fb60f9b2c08dfbbf96 100644 +--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java ++++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java +@@ -36,9 +36,12 @@ public class GoalSelector { } -@@ -185,6 +192,7 @@ public class Brain { - if (memory.isPresent() && this.isEmptyCollection(memory.get().getValue())) { - this.eraseMemory(memoryType); - } else { -+ this.dirtyMemories = true; // Pufferfork - DAB - this.memories.put(memoryType, memory); - } - } -@@ -290,6 +298,7 @@ public class Brain { - - private void setActiveActivity(Activity activity) { - if (!this.isActive(activity)) { -+ this.dirtyActivities = true; // Pufferfork - DAB - this.eraseMemoriesForOtherActivitesThan(activity); - this.activeActivities.clear(); - this.activeActivities.addAll(this.coreActivities); -@@ -321,12 +330,14 @@ public class Brain { + // Paper start - EAR 2 +- public boolean inactiveTick() { ++ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start ++ if (inactive && !gg.pufferfish.pufferfish.PufferfishConfig.dearEnabled) tickRate = 4; // reset to Paper's ++ tickRate = Math.min(tickRate, 3); + this.curRate++; +- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct ++ return this.curRate % tickRate == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct ++ // Pufferfish end } - public void setActiveActivityToFirstValid(List activities) { -+ if (!this.dirtyMemories) return; // Pufferfork - DAB; assumes that this is always called with the same list - for (Activity activity : activities) { - if (this.activityRequirementsAreMet(activity)) { - this.setActiveActivity(activity); - break; - } - } -+ this.dirtyMemories = false; // Pufferfork - DAB + public boolean hasTasks() { +diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java +index f0dc6dfa78da497aa9a7a021e71f8be397016a93..a8c67a95f771c35cdb2a7181341677bb0f5fa4ce 100644 +--- a/net/minecraft/world/entity/animal/allay/Allay.java ++++ b/net/minecraft/world/entity/animal/allay/Allay.java +@@ -224,10 +224,12 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS + return 0.4F; } - public void setDefaultActivity(Activity newFallbackActivity) { -@@ -372,6 +383,7 @@ public class Brain { - Set, MemoryStatus>> memorieStatuses, - Set> memoryTypes - ) { -+ this.dirtyMemories = true; // Pufferfork - DAB; just in case - this.activityRequirements.put(activity, memorieStatuses); - if (!memoryTypes.isEmpty()) { - this.activityMemoriesToEraseWhenStopped.put(activity, memoryTypes); -@@ -408,6 +420,7 @@ public class Brain { ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("allayBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + profilerFiller.push("allayActivityUpdate"); +diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java +index e40bb3232de7ae3a9b9490ec9eb41256ae25ea12..68059074c6cc77dd5e31d67a0bdd9a2848e74ae1 100644 +--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java ++++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java +@@ -326,10 +326,12 @@ public class Axolotl extends Animal implements Bucketable { + return true; } - public void tick(ServerLevel level, E entity) { -+ this.active = this.behaviorTick++ % entity.activatedPriority == 0; // Pufferfork - DAB - this.forgetOutdatedMemories(); - this.tickSensors(level, entity); - this.startEachNonRunningBehavior(level, entity); -@@ -415,7 +428,13 @@ public class Brain { ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("axolotlBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + profilerFiller.push("axolotlActivityUpdate"); +diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java +index f14e79bd8902dc17b63e124cfa44db9e60a42934..e1483067854892153bbb18c360053238eb8c0f8e 100644 +--- a/net/minecraft/world/entity/animal/frog/Frog.java ++++ b/net/minecraft/world/entity/animal/frog/Frog.java +@@ -201,10 +201,12 @@ public class Frog extends Animal { + VariantUtils.readVariant(input, Registries.FROG_VARIANT).ifPresent(this::setVariant); } - private void tickSensors(ServerLevel level, E brainHolder) { -- for (Sensor sensor : this.sensors.values()) { -+ // Pufferfork start - DAB -+ for (final Map.Entry>, Sensor> entry : this.sensors.entrySet()) { -+ if (!this.active && entry.getKey() != SensorType.IS_IN_WATER) { -+ continue; -+ } -+ final Sensor sensor = entry.getValue(); -+ // Pufferfork end - sensor.tick(level, brainHolder); - } ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("frogBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + profilerFiller.push("frogActivityUpdate"); +diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java +index 3ce172c1bdaf8b8a8ad774dd37498e8e379c68bb..126e8b6c35b2c57010a4d9c170b8561d5cee45a4 100644 +--- a/net/minecraft/world/entity/animal/frog/Tadpole.java ++++ b/net/minecraft/world/entity/animal/frog/Tadpole.java +@@ -97,10 +97,12 @@ public class Tadpole extends AbstractFish { + return SoundEvents.TADPOLE_FLOP; } -@@ -442,6 +461,12 @@ public class Brain { + ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("tadpoleBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + profilerFiller.push("tadpoleActivityUpdate"); +diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java +index 7549be3f72beb31ce20cbac96f4909368d877067..98c35024f506bc067a2bc76af150dcc7012b0ab5 100644 +--- a/net/minecraft/world/entity/animal/goat/Goat.java ++++ b/net/minecraft/world/entity/animal/goat/Goat.java +@@ -188,10 +188,12 @@ public class Goat extends Animal { + return (Brain)super.getBrain(); } - private void startEachNonRunningBehavior(ServerLevel level, E entity) { -+ // Pufferfork start - DAB -+ if (!this.dirtyActivities) { -+ return; -+ } -+ this.dirtyActivities = false; -+ // Pufferfork end - long gameTime = level.getGameTime(); ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("goatBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + profilerFiller.push("goatActivityUpdate"); +diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java +index a60f40c7986bbcec854df490bd66111a79fc635a..1d41c05fbed3745c5e593baa858a5830d5c61ee0 100644 +--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java ++++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java +@@ -160,10 +160,12 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { + return (Brain)super.getBrain(); + } - for (Map>> map : this.availableBehaviorsByPriority.values()) { -@@ -462,6 +487,7 @@ public class Brain { - long gameTime = level.getGameTime(); ++ private int behaviorTick; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("hoglinBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + HoglinAi.updateActivity(this); +diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java +index fbbf7364b07ea49116dd86fa9722fa341978bc19..805562a45f4a43d74a15a2d47e249ff0f9cbae0f 100644 +--- a/net/minecraft/world/entity/monster/piglin/Piglin.java ++++ b/net/minecraft/world/entity/monster/piglin/Piglin.java +@@ -306,10 +306,12 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento + return !this.cannotHunt; + } - for (BehaviorControl behaviorControl : this.getRunningBehaviors()) { -+ if (!this.active && !(behaviorControl instanceof net.minecraft.world.entity.ai.behavior.Swim)) continue; // Pufferfork - DAB - behaviorControl.tickOrStop(level, entity, gameTime); ++ private int behaviorTick; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("piglinBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + PiglinAi.updateActivity(this); +diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java +index 2383f3fbe06f6b9a663798deb75ee75eacacf788..ffbd0e0af6bcf29ae3dc4d0b178e6d9ce2897e1a 100644 +--- a/net/minecraft/world/entity/monster/warden/Warden.java ++++ b/net/minecraft/world/entity/monster/warden/Warden.java +@@ -277,10 +277,12 @@ public class Warden extends Monster implements VibrationSystem { } } -diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 859b859d29b637200cf7c9a0bd52d9f712413e3d..5b26295438d6c003c51f8c5e81b7cce9f15c6595 100644 ---- a/net/minecraft/world/entity/ai/goal/GoalSelector.java -+++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java -@@ -36,9 +36,12 @@ public class GoalSelector { - } - // Paper start - EAR 2 -- public boolean inactiveTick() { -+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start - DAB -+ if (inactive && !gg.pufferfish.pufferfish.PufferfishConfig.dearEnabled) tickRate = 4; // reset to Paper's -+ tickRate = Math.min(tickRate, 3); - this.curRate++; -- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct -+ return this.curRate % tickRate == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct -+ // Pufferfish end ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("wardenBrain"); ++ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish + this.getBrain().tick(level, this); + profilerFiller.pop(); + super.customServerAiStep(level); +diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java +index d10a407bef7da29a24582e48d8ee599c981384c5..88895272c5186caa883f70414095e91009d088c6 100644 +--- a/net/minecraft/world/entity/npc/Villager.java ++++ b/net/minecraft/world/entity/npc/Villager.java +@@ -288,6 +288,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } + // Paper end - EAR 2 - public boolean hasTasks() { ++ public long nextGolemPanic = -1; // Pufferfish ++ private int behaviorTick = 0; // Pufferfish + @Override + protected void customServerAiStep(ServerLevel level) { + // Paper start - EAR 2 +@@ -297,7 +299,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + // Paper end - EAR 2 + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("villagerBrain"); +- if (!inactive) this.getBrain().tick(level, this); // Paper - EAR 2 ++ // Pufferfish start ++ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) { ++ this.getBrain().tick(level, this); // Paper ++ } ++ // Pufferfish end + profilerFiller.pop(); + if (this.assignProfessionWhenSpawned) { + this.assignProfessionWhenSpawned = false; diff --git a/pufferfork-server/minecraft-patches/features/0002-Optimize-mob-spawning.patch b/pufferfork-server/minecraft-patches/features/0002-Optimize-mob-spawning.patch index d4741630d..7755967ce 100644 --- a/pufferfork-server/minecraft-patches/features/0002-Optimize-mob-spawning.patch +++ b/pufferfork-server/minecraft-patches/features/0002-Optimize-mob-spawning.patch @@ -17,34 +17,34 @@ and, in my opinion, worth the low risk of minor mob-spawning-related inconsistencies. diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index f84b90cd0fc78847df8beee879a692fa7d3af3e0..2ff89a70f120a440ce9dfdaa67d75028acd578a2 100644 +index 4f5dea8ba7543c30eb3bee6016ac609c73dfea72..516f27eb52518b9346c8b0fa9576ff6acf36f437 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -303,6 +303,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation + public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning - - public static S spin(Function threadFunction) { - ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system + // Paper start - improve tick loop + public final ca.spottedleaf.moonrise.common.time.TickData tickTimes1s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(1L)); + public final ca.spottedleaf.moonrise.common.time.TickData tickTimes5s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(5L)); diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 20350fa481be37c3d6220a535f13ed5449c8389f..c3af8efb53da7154712af7631864053bd2754402 100644 +index b8e2baab29e8828384a978f882a8fa3dadc96945..838363bf6326b73e882b4b1feecb0924524e5ff2 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -309,6 +309,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - LOGGER.info("JMX monitoring enabled"); +@@ -395,6 +395,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } + this.notificationManager().serverStarted(); + if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) mobSpawnExecutor.start(); // Pufferfish - optimize mob spawning return true; } } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c72c6c145f 100644 +index 488fc6088d69148f60a913b42ffb964c48eb0324..d8328cdc64b7449e0a7bd541cd279a2c03694d22 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -184,6 +184,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -185,6 +185,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } // Paper end - chunk tick iteration optimisations @@ -53,7 +53,7 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 public ServerChunkCache( ServerLevel level, -@@ -522,6 +524,42 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -517,6 +519,42 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon this.broadcastChangedChunks(profilerFiller); profilerFiller.pop(); } @@ -92,11 +92,11 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 + }); + } + } -+ // Pufferfish end ++ // Pufferfish end - optimize mob spawning } private void broadcastChangedChunks(ProfilerFiller profiler) { -@@ -544,6 +582,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -539,6 +577,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon // Paper start - Optional per player mob spawns NaturalSpawner.SpawnState spawnState; if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled @@ -104,7 +104,7 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 // re-set mob counts for (ServerPlayer player : this.level.players) { // Paper start - per player mob spawning backoff -@@ -558,12 +597,16 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -553,12 +592,16 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } // Paper end - per player mob spawning backoff } @@ -113,19 +113,18 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 + } // Pufferfish - (endif) moved down when async processing } else { - spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); -- } -+ // Pufferfish start - async mob spawning ++ // Pufferfish start - optimize mob spawning + lastSpawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); + _pufferfish_spawnCountsReady.set(true); -+ // Pufferfish - end -+ } ++ // Pufferfish end - optimize mob spawning + } // Paper end - Optional per player mob spawns - this.lastSpawnState = spawnState; + // this.lastSpawnState = spawnState; // Pufferfish - optimize mob spawning (this is managed asynchronously) - profiler.popPush("spawnAndTick"); boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); -@@ -578,7 +621,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + List filteredSpawningCategories; +@@ -572,7 +615,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } // Paper end - PlayerNaturallySpawnCreaturesEvent boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit @@ -134,7 +133,7 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 } else { filteredSpawningCategories = List.of(); } -@@ -596,7 +639,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -590,7 +633,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon profiler.popPush("tickSpawningChunks"); for (LevelChunk levelChunk : list) { @@ -143,7 +142,7 @@ index 2882cd829d4d8e1f8615f085f6908efcdf68ac62..b4618eae403b7587a2214ae9a21359c7 } } finally { list.clear(); -@@ -619,8 +662,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -614,8 +657,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } if (!spawnCategories.isEmpty()) { diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch index 84a988b7b..3df94143b 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,19 +1,15 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1261,6 +_,12 @@ - profilerFiller.popPush("nextTickWait"); - this.mayHaveDelayedTasks = true; - this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + l, this.nextTickTimeNanos); -+ // Pufferfish start - tps catchup -+ if (!gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup) { -+ this.nextTickTimeNanos = currentTime + l; -+ this.delayedTasksMaxNextTickTimeNanos = nextTickTimeNanos; -+ } -+ // Pufferfish end - this.startMeasuringTaskExecutionTime(); - this.waitUntilNextTick(); - this.finishMeasuringTaskExecutionTime(); -@@ -2598,6 +_,7 @@ +@@ -1304,7 +_,7 @@ + final long ticksBehind = Math.max(1L, this.tickSchedule.getPeriodsAhead(l, tickStart)); + final long catchup = (long)Math.max( + 1, +- 5 //ConfigHolder.getConfig().tickLoop.catchupTicks.getOrDefault(MoonriseConfig.TickLoop.DEFAULT_CATCHUP_TICKS).intValue() ++ gg.pufferfish.pufferfish.PufferfishConfig.tpsCatchup ? 5 : 1 // Pufferfish - tps catchup config - diff on change + ); + + // adjust ticksBehind so that it is not greater-than catchup +@@ -2707,6 +_,7 @@ // CraftBukkit end private ProfilerFiller createProfiler() { diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/ReloadableServerResources.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/ReloadableServerResources.java.patch index 6248c359e..bbd69b032 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/ReloadableServerResources.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/ReloadableServerResources.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/server/ReloadableServerResources.java +++ b/net/minecraft/server/ReloadableServerResources.java -@@ -41,6 +_,8 @@ +@@ -42,6 +_,8 @@ this.commands = new Commands(commandSelection, CommandBuildContext.simple(registries, enabledFeatures), true); // Paper - Brigadier Command API - use modern alias registration io.papermc.paper.command.brigadier.PaperCommands.INSTANCE.setDispatcher(this.commands, CommandBuildContext.simple(registries, enabledFeatures)); // Paper - Brigadier Command API io.papermc.paper.command.PaperCommands.registerCommands(); // Paper + gg.pufferfish.pufferfish.command.registrar.PufferfishCommandRegistrar.registerCommands(); // Pufferfork - built-in pufferfish commands + gg.pufferfish.pufferfish.flare.FlareCommand.init(); // Pufferfork - flare command this.advancements = new ServerAdvancementManager(registries); - this.functionLibrary = new ServerFunctionLibrary(functionCompilationLevel, this.commands.getDispatcher()); + this.functionLibrary = new ServerFunctionLibrary(permissions, this.commands.getDispatcher()); } diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index c05b99795..a91d5c9fd 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -184,6 +_,7 @@ +@@ -274,6 +_,7 @@ this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now + gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish - Rebranding - this.setPvpAllowed(properties.pvp); - this.setFlightAllowed(properties.allowFlight); + // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading + LOGGER.info("Default game type: {}", properties.gameMode.get()); diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 7f09bb9cd..c2a815cd3 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -193,7 +_,10 @@ +@@ -181,7 +_,10 @@ packet = ClientboundEntityPositionSyncPacket.of(this.entity); flag3 = true; flag4 = true; @@ -12,11 +12,11 @@ if (flag2) { packet = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short)l, (short)l1, (short)l2, this.entity.onGround()); flag3 = true; -@@ -206,6 +_,7 @@ +@@ -194,6 +_,7 @@ flag3 = true; flag4 = true; } + } // Pufferfish - Better checking for useless move packets - if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) { + if (this.entity.needsSync || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) { Vec3 deltaMovement = this.entity.getDeltaMovement(); diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch index df41b168c..d304e533d 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -808,7 +_,19 @@ +@@ -851,7 +_,19 @@ } profilerFiller.push("tick"); @@ -21,7 +21,7 @@ profilerFiller.pop(); } } -@@ -943,7 +_,7 @@ +@@ -1002,7 +_,7 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index dbe1d948c..7c7d1273d 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2160,6 +_,7 @@ +@@ -2201,6 +_,7 @@ @Override public void handlePaddleBoat(ServerboundPaddleBoatPacket packet) { diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 7b59aa403..7aa3c215a 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -437,7 +_,7 @@ - +@@ -440,7 +_,7 @@ + profilerFiller.push("livingEntityBaseTick"); if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) { boolean flag = this instanceof Player; - if (this.isInWall()) { + if (shouldCheckForSuffocation() && this.isInWall()) { // Pufferfish - optimize suffocation this.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F); } else if (flag && !serverLevel1.getWorldBorder().isWithinBounds(this.getBoundingBox())) { - double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getDamageSafeZone(); -@@ -518,6 +_,18 @@ - profilerFiller.pop(); + double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getSafeZone(); +@@ -525,6 +_,18 @@ + return this.getAirSupply() <= -20; } + // Pufferfish start - optimize suffocation diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch index 7d5567585..5c76d81f8 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -207,10 +_,12 @@ +@@ -217,10 +_,12 @@ return this.lookControl; } diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch index 5dbfd0ef4..26ce4c9b3 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch @@ -12,10 +12,10 @@ } private void onAttributeModified(AttributeInstance instance) { -@@ -44,7 +_,7 @@ +@@ -43,7 +_,7 @@ + } - @Nullable - public AttributeInstance getInstance(Holder attribute) { + public @Nullable AttributeInstance getInstance(Holder attribute) { - return this.attributes.computeIfAbsent(attribute, holder -> this.supplier.createInstance(this::onAttributeModified, (Holder)holder)); + return this.attributes.computeIfAbsent(attribute, this.createInstance); // Pufferfish - Reduce entity allocations (cache lambda, as for some reason java allocates it anyways) } diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch deleted file mode 100644 index 6bb21dd61..000000000 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/net/minecraft/world/entity/ambient/Bat.java -+++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -245,11 +_,20 @@ - } - } - -+ // Pufferfish start - only check for spooky season once an hour -+ private static boolean isSpookySeason = false; -+ private static final int ONE_HOUR = 20 * 60 * 60; -+ private static int lastSpookyCheck = -ONE_HOUR; - private static boolean isHalloween() { -+ if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) { - LocalDate localDate = LocalDate.now(); - int i = localDate.get(ChronoField.DAY_OF_MONTH); - int i1 = localDate.get(ChronoField.MONTH_OF_YEAR); -- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3; -+ isSpookySeason = i1 == 10 && i >= 20 || i1 == 11 && i <= 3; -+ lastSpookyCheck = net.minecraft.server.MinecraftServer.currentTick; -+ } -+ return isSpookySeason; -+ // Pufferfish end - } - - private void setupAnimationStates() { diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 0eda783e0..9765adfea 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -136,6 +_,13 @@ +@@ -137,6 +_,13 @@ this.bossEvent.setName(this.getDisplayName()); } diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 1d6e6a272..6aa931b78 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -296,11 +_,17 @@ +@@ -300,11 +_,17 @@ private boolean teleport(double x, double y, double z) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(x, y, z); diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 693505b88..3a0bf144e 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java @@ -50,6 +_,36 @@ - super(entityType, level); + super(type, level); } + // Pufferfish start - Reduce projectile chunk loading @@ -36,4 +36,4 @@ + protected void setOwner(@Nullable EntityReference owner) { this.owner = owner; - } + this.refreshProjectileSource(false); // Paper diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch index fb0158392..b0ff5471e 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/item/crafting/ShapelessRecipe.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -23,8 +_,13 @@ +@@ -22,8 +_,13 @@ + final ItemStack result; final List ingredients; - @Nullable - private PlacementInfo placementInfo; + private @Nullable PlacementInfo placementInfo; + // Pufferfish start - Simpler ShapelessRecipes comparison for Vanilla + private final boolean isBukkit; @@ -14,7 +14,7 @@ this.group = group; this.category = category; this.result = result; -@@ -73,6 +_,27 @@ +@@ -72,6 +_,27 @@ @Override public boolean matches(CraftingInput input, Level level) { // Paper start - Improve exact choice recipe ingredients & unwrap ternary diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch index c4b4b9a32..f1b005a2d 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1481,15 +_,15 @@ - public void guardEntityTick(Consumer consumerEntity, T entity) { +@@ -1427,15 +_,15 @@ + public void guardEntityTick(Consumer action, T entity) { try { - consumerEntity.accept(entity); + action.accept(entity); - } catch (Throwable var6) { + } catch (Throwable var6) { // Pufferfish - Remove lambda from ticking guard (diff on change ServerLevel.tick) // Paper start - Prevent block entity and entity crashes diff --git a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index 2f85050fe..752e26ead 100644 --- a/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/pufferfork-server/minecraft-patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -88,6 +_,17 @@ +@@ -94,6 +_,17 @@ private final LevelChunkTicks blockTicks; private final LevelChunkTicks fluidTicks; private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {}; @@ -18,7 +18,7 @@ // CraftBukkit start public boolean mustNotSave; public boolean needsDecoration; -@@ -158,6 +_,7 @@ +@@ -164,6 +_,7 @@ this.postLoad = postLoad; this.blockTicks = blockTicks; this.fluidTicks = fluidTicks; diff --git a/pufferfork-server/paper-patches/features/0001-Pufferfish-Pufferfork-branding.patch b/pufferfork-server/paper-patches/features/0001-Pufferfish-Pufferfork-branding.patch index 64f5ca5cb..8a0a39dff 100644 --- a/pufferfork-server/paper-patches/features/0001-Pufferfish-Pufferfork-branding.patch +++ b/pufferfork-server/paper-patches/features/0001-Pufferfish-Pufferfork-branding.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Pufferfish/Pufferfork branding Also rebrand to Pufferfork to avoid legal issues diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 6abc57669e87f7f98f3b76af3c0e50825fea6eb1..49b9fcdc44c778ca248790c6277cafd2e756c41e 100644 +index 9f4d73fd321f6f0cd19fdd1b63068d2ea6c0816b..39e91959b2fa010fc748fd4dd1cce6b5ba8c6885 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,7 @@ public class Metrics { @@ -57,7 +57,7 @@ index 74ffdc823e66fc5ec027c4b7c462382bcbfe2be2..1342a27b74de34080c5760f12b179ec8 SharedConstants.getCurrentVersion().name(), getManifestAttribute(manifest, ATTRIBUTE_BUILD_NUMBER) diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index c1aad9203af20102e560571435dfa75150b37c1b..b2ccdc9bd2f7d830db1c530f9339e291e9e633f8 100644 +index 299e53032471f1529df8b0fd14e0d34eda416226..da2d975a4b9dbd3df744c2a7be72239e3f47de93 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -481,7 +481,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @@ -69,16 +69,3 @@ index c1aad9203af20102e560571435dfa75150b37c1b..b2ccdc9bd2f7d830db1c530f9339e291 } @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 774556a62eb240da42e84db4502e2ed43495be17..4de80741e020adf69c82736116ed76ab320ce0af 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -@@ -11,7 +11,7 @@ public final class Versioning { - public static String getBukkitVersion() { - String result = "Unknown-Version"; - -- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties"); -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/gg.pufferfish.pufferfish/pufferfork-api/pom.properties"); // Pufferfork - Rebranding - Properties properties = new Properties(); - - if (stream != null) { diff --git a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java index de3d6cbac..b68f8e58b 100644 --- a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java +++ b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/FlareCommand.java @@ -39,6 +39,7 @@ public class FlareCommand { .append(Component.text("]", NamedTextColor.DARK_GRAY)) .append(Component.text(" ")) .build(); + private static String PROFILING_URI = ""; public static void init() { @@ -92,13 +93,14 @@ public static void init() { .executes(ctx -> { CommandSender sender = ctx.getSource().getSender(); - String profile = ProfilingManager.getProfilingUri(); - if (ProfilingManager.stop()) { - broadcastPrefixed( - Component.text("Profiling has been stopped.", MAIN_COLOR), - Component.text(profile, HEX).clickEvent(ClickEvent.openUrl(profile)) - ); - } + MCUtil.scheduleAsyncTask(() -> { + if (ProfilingManager.stop()) { + broadcastPrefixed( + Component.text("Profiling has been stopped.", MAIN_COLOR), + Component.text(PROFILING_URI, HEX).clickEvent(ClickEvent.openUrl(PROFILING_URI)) + ); + } + }); return Command.SINGLE_SUCCESS; }) ) @@ -157,13 +159,14 @@ private static void execute(CommandSender sender, final ProfileType profileType) MCUtil.scheduleAsyncTask(() -> { try { if (ProfilingManager.start(profileType)) { + PROFILING_URI = ProfilingManager.getProfilingUri(); broadcastPrefixed( Component.text("Flare has been started!", MAIN_COLOR), Component.text("It will run in the background for 15 minutes", NamedTextColor.GRAY), Component.text("or until manually stopped using:", NamedTextColor.GRAY), Component.text(" ").append(Component.text("/flare stop", NamedTextColor.WHITE).clickEvent(ClickEvent.runCommand("flare stop"))), Component.text("Follow its progress here:", NamedTextColor.GRAY), - Component.text(ProfilingManager.getProfilingUri(), HEX).clickEvent(ClickEvent.openUrl(ProfilingManager.getProfilingUri())) + Component.text(PROFILING_URI, HEX).clickEvent(ClickEvent.openUrl(PROFILING_URI)) ); } } catch (UserReportableException e) { @@ -197,4 +200,11 @@ private static void broadcastPrefixed(Component ...lines) { } + protected static void broadcastException() { + broadcastPrefixed( + Component.text("An exception happened and profiling has stopped", MAIN_COLOR), + Component.text(PROFILING_URI, HEX).clickEvent(ClickEvent.openUrl(PROFILING_URI)) + ); + } + } \ No newline at end of file diff --git a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java index 8225e2aec..2e74bcc09 100644 --- a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java +++ b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/ProfilingManager.java @@ -106,7 +106,11 @@ public static synchronized boolean start(ProfileType profileType) throws UserRep .setFamily(os.getFamily()) .setVersion(os.getVersionInfo().toString()) .setBitness(os.getBitness()) - ); + ) + + .withExceptionRunnable(() -> { + FlareCommand.broadcastException(); + }); currentFlare = builder.build(); } catch (IOException e) { diff --git a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java index 40447d00a..e94532341 100644 --- a/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java +++ b/pufferfork-server/src/main/java/gg/pufferfish/pufferfish/flare/collectors/TPSCollector.java @@ -4,6 +4,7 @@ import co.technove.flare.live.LiveCollector; import co.technove.flare.live.formatter.SuffixFormatter; import gg.pufferfish.pufferfish.flare.CustomCategories; +import ca.spottedleaf.moonrise.common.time.TickData.MSPTData; import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; @@ -22,10 +23,9 @@ public TPSCollector() { @Override public void run() { - long[] times = MinecraftServer.getServer().tickTimes5s.getTimes(); - double mspt = ((double) Arrays.stream(times).sum() / (double) times.length) * 1.0E-6D; - + MSPTData msptData = MinecraftServer.getServer().getMSPTData5s(); + double mspt = msptData != null ? Math.round(msptData.avg() * 100d) / 100d : 0.0; this.report(TPS, Math.min(20D, Math.round(Bukkit.getServer().getTPS()[0] * 100d) / 100d)); - this.report(MSPT, (double) Math.round(mspt * 100d) / 100d); + this.report(MSPT, mspt); } }