Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Minecraft 1.21.4 #183

Merged
merged 8 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
Minecraft server mod/plugin to show TPS, MSPT, and other information in the tab menu, boss bar, and action bar.

Current supported platforms:
- [Paper](https://papermc.io)/Spigot API (Minecraft versions 1.8.8-1.21.1+)
- [Paper](https://papermc.io)/Spigot API (Minecraft versions 1.8.8-1.21.4+)
- [Sponge](https://spongepowered.org) 12+
- [Fabric](https://fabricmc.net/) (Minecraft 1.21.1, requires [Fabric API](https://modrinth.com/mod/fabric-api))
- [NeoForge](https://neoforged.net/) (Minecraft 1.21.1)
- [Fabric](https://fabricmc.net/) (Minecraft 1.21.4, requires [Fabric API](https://modrinth.com/mod/fabric-api))
- [NeoForge](https://neoforged.net/) (Minecraft 1.21.4)

## Features

Expand Down
3 changes: 3 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies {
include(libs.bundles.configurate)
implementation(libs.adventureSerializerConfigurate4)
include(libs.adventureSerializerConfigurate4)

modImplementation(libs.fabricPermissionsApi)
include(libs.fabricPermissionsApi)
}

indra {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
import net.kyori.adventure.text.Component;
import net.minecraft.server.level.ServerPlayer;
import org.checkerframework.checker.nullness.qual.NonNull;
Expand All @@ -46,7 +47,7 @@ public static FabricUser from(final TabTPSFabric tabTPSFabric, final ServerPlaye

@Override
public Component displayName() {
return this.base().getDisplayName().asComponent();
return MinecraftServerAudiences.of(this.base().getServer()).asAdventure(this.base().getDisplayName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package xyz.jpenilla.tabtps.fabric.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.function.BooleanSupplier;
Expand All @@ -37,7 +38,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import xyz.jpenilla.tabtps.common.service.TickTimeService;
import xyz.jpenilla.tabtps.common.util.RollingAverage;
import xyz.jpenilla.tabtps.common.util.TPSUtil;
Expand All @@ -51,29 +51,55 @@
@Mixin(MinecraftServer.class)
@Implements({@Interface(iface = TickTimeService.class, prefix = "tabtps$")})
abstract class MinecraftServerMixin implements MinecraftServerAccess {
@Unique
private final TickTimes tickTimes5s = new TickTimes(100);
@Unique
private final TickTimes tickTimes10s = new TickTimes(200);
@Unique
private final TickTimes tickTimes60s = new TickTimes(1200);

@Unique
private final RollingAverage tps5s = new RollingAverage(5);
@Unique
private final RollingAverage tps1m = new RollingAverage(60);
@Unique
private final RollingAverage tps5m = new RollingAverage(60 * 5);
@Unique
private final RollingAverage tps15m = new RollingAverage(60 * 15);

@Unique
private long previousTime;
@Unique
private boolean tickingPaused;

@Shadow private int tickCount;
@Shadow @Final private long[] tickTimesNanos;

@Inject(method = "tickServer", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
public void injectTick(final BooleanSupplier var1, final CallbackInfo ci, final long tickStartTimeNanos, final long tickDurationNanos) {
@Inject(
method = "tickServer",
at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", ordinal = 0)
)
private void injectPause(final BooleanSupplier keepTicking, final CallbackInfo ci) {
this.tickingPaused = true;
}

@Inject(method = "tickServer", at = @At(value = "RETURN", ordinal = 1))
public void injectTick(
final BooleanSupplier keepTicking,
final CallbackInfo ci,
@Local(ordinal = 0) final long tickStartTimeNanos,
@Local(ordinal = 1) final long tickDurationNanos
) {
this.tickTimes5s.add(this.tickCount, tickDurationNanos);
this.tickTimes10s.add(this.tickCount, tickDurationNanos);
this.tickTimes60s.add(this.tickCount, tickDurationNanos);

if (this.tickCount % RollingAverage.SAMPLE_INTERVAL == 0) {
if (this.previousTime == 0) {
this.previousTime = tickStartTimeNanos - RollingAverage.TICK_TIME;
if (this.previousTime == 0 || this.tickingPaused) {
this.previousTime = tickStartTimeNanos - tickDurationNanos;
if (this.tickingPaused) {
this.tickingPaused = false;
}
}
final long diff = tickStartTimeNanos - this.previousTime;
this.previousTime = tickStartTimeNanos;
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"fabricloader": ">=0.15.11",
"fabric": "*",
"fabric-permissions-api-v0": "*",
"minecraft": ">=1.21 <=1.21.1"
"minecraft": "1.21.4"
}
}
2 changes: 1 addition & 1 deletion gradle/build-logic/src/main/kotlin/CopyFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class CopyFile : DefaultTask() {
abstract val destination: RegularFileProperty

@TaskAction
private fun copyFile() {
fun copyFile() {
destination.get().asFile.parentFile.mkdirs()
fileToCopy.get().asFile.copyTo(destination.get().asFile, overwrite = true)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/build-logic/src/main/kotlin/ext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ val bukkitVersions = listOf(
"1.18.2",
"1.19.4",
"1.20.6",
"1.21.1",
"1.21.4",
)
22 changes: 11 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
blossom = { id = "net.kyori.blossom", version = "2.1.0" }
localization = { id = "ca.stellardrift.localization", version = "6.1.0" }
runPaper = { id = "xyz.jpenilla.run-paper", version = "2.3.1" }
sponge-gradle = { id = "org.spongepowered.gradle.plugin", version = "2.2.0" }
sponge-gradle = { id = "org.spongepowered.gradle.plugin", version = "2.3.0" }

[versions]
adventure = "4.17.0"
adventurePagination = "4.0.0-SNAPSHOT"
adventurePlatform = "4.3.4"
cloud = "2.0.0"
cloudMinecraft = "2.0.0-beta.9"
cloudModded = "2.0.0-beta.9"
cloudMinecraft = "2.0.0-beta.10"
cloudModded = "2.0.0-beta.10"
cloudSponge = "2.0.0-SNAPSHOT"
configurate = "4.1.2"
typesafeConfig = "1.4.3"
Expand All @@ -22,14 +22,13 @@ guava = "21.0"
bstats = "3.1.0"
paperApi = "1.16.5-R0.1-SNAPSHOT"
paperLib = "1.0.8"
fabricApi = "0.110.0+1.21.1"
fabricApi = "0.114.0+1.21.4"
fabricLoader = "0.16.9"
minecraft = "1.21.1"
adventurePlatformFabric = "5.14.2"
adventurePlatformNeoforge = "6.0.0"
minecraft = "1.21.4"
adventurePlatformMod = "6.2.0"
mixin = "0.8.7"
neoforge = "21.1.82"
neoForm = "1.21.1-20240808.144430"
neoforge = "21.4.47-beta"
neoForm = "1.21.4-20241203.161809"

# buildSrc
indra = "3.1.3"
Expand All @@ -44,8 +43,8 @@ adventureTextSerializerLegacy = { group = "net.kyori", name = "adventure-text-se
adventureSerializerConfigurate4 = { group = "net.kyori", name = "adventure-serializer-configurate4", version.ref = "adventure" }
adventureTextFeaturePagination = { group = "net.kyori", name = "adventure-text-feature-pagination", version.ref = "adventurePagination" }
adventurePlatformBukkit = { group = "net.kyori", name = "adventure-platform-bukkit", version.ref = "adventurePlatform" }
adventurePlatformFabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurePlatformFabric" }
adventurePlatformNeoforge = { group = "net.kyori", name = "adventure-platform-neoforge", version.ref = "adventurePlatformNeoforge" }
adventurePlatformFabric = { group = "net.kyori", name = "adventure-platform-fabric", version.ref = "adventurePlatformMod" }
adventurePlatformNeoforge = { group = "net.kyori", name = "adventure-platform-neoforge", version.ref = "adventurePlatformMod" }
minimessage = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "adventure" }

cloudBom = { group = "org.incendo", name = "cloud-bom", version.ref = "cloud" }
Expand Down Expand Up @@ -81,6 +80,7 @@ paperLib = { group = "io.papermc", name = "paperlib", version.ref = "paperLib" }

fabricApi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabricApi" }
fabricLoader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabricLoader" }
fabricPermissionsApi = "me.lucko:fabric-permissions-api:0.3.3"
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }

zNeoforge = { module = "net.neoforged:neoforge", version.ref = "neoforge" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 1 addition & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
4 changes: 3 additions & 1 deletion neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ plugins {
val minecraftVersion = libs.versions.minecraft.get()

neoForge {
version = libs.versions.neoforge
enable {
version = libs.versions.neoforge.get()
}

mods {
register("tabtps") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package xyz.jpenilla.tabtps.neoforge.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.function.BooleanSupplier;
Expand All @@ -37,7 +38,6 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import xyz.jpenilla.tabtps.common.service.TickTimeService;
import xyz.jpenilla.tabtps.common.util.RollingAverage;
import xyz.jpenilla.tabtps.common.util.TPSUtil;
Expand All @@ -51,29 +51,55 @@
@Mixin(MinecraftServer.class)
@Implements({@Interface(iface = TickTimeService.class, prefix = "tabtps$")})
abstract class MinecraftServerMixin implements MinecraftServerAccess {
@Unique
private final TickTimes tickTimes5s = new TickTimes(100);
@Unique
private final TickTimes tickTimes10s = new TickTimes(200);
@Unique
private final TickTimes tickTimes60s = new TickTimes(1200);

@Unique
private final RollingAverage tps5s = new RollingAverage(5);
@Unique
private final RollingAverage tps1m = new RollingAverage(60);
@Unique
private final RollingAverage tps5m = new RollingAverage(60 * 5);
@Unique
private final RollingAverage tps15m = new RollingAverage(60 * 15);

@Unique
private long previousTime;
@Unique
private boolean tickingPaused;

@Shadow private int tickCount;
@Shadow @Final private long[] tickTimesNanos;

@Inject(method = "tickServer", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD)
public void injectTick(final BooleanSupplier var1, final CallbackInfo ci, final long tickStartTimeNanos, final long tickDurationNanos) {
@Inject(
method = "tickServer",
at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;Ljava/lang/Object;)V", ordinal = 0)
)
private void injectPause(final BooleanSupplier keepTicking, final CallbackInfo ci) {
this.tickingPaused = true;
}

@Inject(method = "tickServer", at = @At(value = "RETURN", ordinal = 1))
public void injectTick(
final BooleanSupplier keepTicking,
final CallbackInfo ci,
@Local(ordinal = 0) final long tickStartTimeNanos,
@Local(ordinal = 1) final long tickDurationNanos
) {
this.tickTimes5s.add(this.tickCount, tickDurationNanos);
this.tickTimes10s.add(this.tickCount, tickDurationNanos);
this.tickTimes60s.add(this.tickCount, tickDurationNanos);

if (this.tickCount % RollingAverage.SAMPLE_INTERVAL == 0) {
if (this.previousTime == 0) {
this.previousTime = tickStartTimeNanos - RollingAverage.TICK_TIME;
if (this.previousTime == 0 || this.tickingPaused) {
this.previousTime = tickStartTimeNanos - tickDurationNanos;
if (this.tickingPaused) {
this.tickingPaused = false;
}
}
final long diff = tickStartTimeNanos - this.previousTime;
this.previousTime = tickStartTimeNanos;
Expand Down
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ side = "BOTH"
[[dependencies.tabtps]]
modId = "minecraft"
type = "required"
versionRange = "[1.21,1.21.2)"
versionRange = "[1.21.4]"
ordering = "NONE"
side = "BOTH"

Expand Down
5 changes: 3 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven("https://maven.fabricmc.net/")
maven("https://repo.spongepowered.org/repository/maven-public/")
maven("https://repo.jpenilla.xyz/snapshots/") {
mavenContent { snapshotsOnly() }
}
Expand All @@ -33,9 +34,9 @@ pluginManagement {
}

plugins {
id("quiet-fabric-loom") version "1.8-SNAPSHOT"
id("quiet-fabric-loom") version "1.9-SNAPSHOT"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
id("net.neoforged.moddev.repositories") version "2.0.49-beta"
id("net.neoforged.moddev.repositories") version "2.0.71"
}

rootProject.name = "TabTPS"
Expand Down
12 changes: 6 additions & 6 deletions sponge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ java {

sponge {
injectRepositories(false)
apiVersion("12.0.0-SNAPSHOT")
apiVersion("14.0.0-SNAPSHOT")
plugin(rootProject.name.lowercase()) {
loader {
name(PluginLoaders.JAVA_PLAIN)
Expand All @@ -54,7 +54,9 @@ sponge {
}

neoForge {
neoFormVersion = libs.versions.neoForm
enable {
neoFormVersion = libs.versions.neoForm.get()
}
}

tasks {
Expand Down Expand Up @@ -95,18 +97,16 @@ tabTPSPlatform {
publishMods.modrinth {
modLoaders.add("sponge")
minecraftVersions.addAll(
"1.21.1"
"1.21.4"
)
}

/*
configurations.spongeRuntime {
resolutionStrategy {
eachDependency {
if (target.name == "spongevanilla") {
useVersion("1.20.+")
useVersion("1.21.4-14.+")
}
}
}
}
*/
Loading
Loading