-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
1,651 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
53 changes: 53 additions & 0 deletions
53
versions/1.1.0-alpha.12w01a-to-1.2.0-alpha.12w06a-client/src/main/resources/quilt.mod.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"schema_version": 1, | ||
"quilt_loader": { | ||
"group": "net.lostluma", | ||
"id": "server_stats_mixins", | ||
"version": "${version}", | ||
"metadata": { | ||
"name": "Server Stats Mixins", | ||
"description": "Implementation of server-side statistics for Minecraft 1.2.5 on the client.", | ||
"contributors": { | ||
"LostLuma": "Owner" | ||
}, | ||
"contact": { | ||
"homepage": "https://go.lostluma.net/server-stats", | ||
"issues": "https://go.lostluma.net/server-stats-issues", | ||
"sources": "https://go.lostluma.net/server-stats-source" | ||
}, | ||
"license": { | ||
"name": "LGPL License", | ||
"id": "LGPL-3.0-or-later", | ||
"url": "https://go.lostluma.net/server-stats-license" | ||
}, | ||
"icon": "assets/server_stats_mixins/icon.png" | ||
}, | ||
"intermediate_mappings": "net.fabricmc:intermediary", | ||
"depends": [ | ||
{ | ||
"id": "minecraft", | ||
"versions": { | ||
"all": [">=1.1.0-alpha.12.1.a", "<=1.2.1-alpha.12.6.a"] | ||
} | ||
} | ||
] | ||
}, | ||
"minecraft": { | ||
"environment": "client" | ||
}, | ||
"mixin": "server_stats.mixins.json", | ||
"access_widener" : "server_stats.accesswidener", | ||
"quilt_loom": { | ||
"injected_interfaces": { | ||
"net/minecraft/unmapped/C_9590849": [ | ||
"net/lostluma/server_stats/types/StatsPlayer" | ||
], | ||
"net/minecraft/unmapped/C_2854223": [ | ||
"net/lostluma/server_stats/types/OverridableStats" | ||
] | ||
} | ||
}, | ||
"modmenu": { | ||
"parent": "server_stats" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
49 changes: 49 additions & 0 deletions
49
versions/1.1.0-alpha.12w01a-to-1.2.0-alpha.12w06a-server/src/main/resources/quilt.mod.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"schema_version": 1, | ||
"quilt_loader": { | ||
"group": "net.lostluma", | ||
"id": "server_stats_mixins", | ||
"version": "${version}", | ||
"metadata": { | ||
"name": "Server Stats Mixins", | ||
"description": "Implementation of server-side statistics for Minecraft 1.1.0.", | ||
"contributors": { | ||
"LostLuma": "Owner" | ||
}, | ||
"contact": { | ||
"homepage": "https://go.lostluma.net/server-stats", | ||
"issues": "https://go.lostluma.net/server-stats-issues", | ||
"sources": "https://go.lostluma.net/server-stats-source" | ||
}, | ||
"license": { | ||
"name": "LGPL License", | ||
"id": "LGPL-3.0-or-later", | ||
"url": "https://go.lostluma.net/server-stats-license" | ||
}, | ||
"icon": "assets/server_stats_mixins/icon.png" | ||
}, | ||
"intermediate_mappings": "net.fabricmc:intermediary", | ||
"depends": [ | ||
{ | ||
"id": "minecraft", | ||
"versions": { | ||
"all": [">=1.1.0-alpha.12.1.a", "<=1.2.1-alpha.12.6.a"] | ||
} | ||
} | ||
] | ||
}, | ||
"minecraft": { | ||
"environment": "dedicated_server" | ||
}, | ||
"mixin": "server_stats.mixins.json", | ||
"quilt_loom": { | ||
"injected_interfaces": { | ||
"net/minecraft/unmapped/C_9590849": [ | ||
"net/lostluma/server_stats/types/StatsPlayer" | ||
] | ||
} | ||
}, | ||
"modmenu": { | ||
"parent": "server_stats" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
plugins { | ||
id 'maven-publish' | ||
alias libs.plugins.shadow | ||
alias libs.plugins.quilt.loom | ||
alias libs.plugins.ploceus | ||
} | ||
|
||
apply from: "${rootProject.projectDir}/gradle/common.gradle" | ||
|
||
group = project.maven_group | ||
version = generateVersionWithMetadata() | ||
|
||
base { | ||
archivesName = project.archives_base_name | ||
} | ||
|
||
loom { | ||
clientOnlyMinecraftJar() | ||
|
||
accessWidenerPath = file("src/main/resources/server_stats.accesswidener") | ||
} | ||
|
||
ploceus { | ||
clientOnlyMappings() | ||
} | ||
|
||
dependencies { | ||
minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||
|
||
mappings loom.layered { | ||
mappings "net.ornithemc:feather:${project.feather_version}:v2" | ||
addLayer ploceus.nestedMappings() // Required for nests | ||
} | ||
|
||
nests "net.ornithemc:nests:${project.nests_version}" | ||
modImplementation libs.quilt.loader | ||
|
||
implementation libs.gson | ||
} | ||
|
||
shadowJar { | ||
configurations = [project.configurations.shadow] | ||
relocate "com.google", "net.lostluma.server_stats.external" | ||
} | ||
|
||
remapJar { | ||
inputFile.set shadowJar.archiveFile | ||
dependsOn shadowJar | ||
} |
12 changes: 12 additions & 0 deletions
12
versions/1.2.0-alpha.12w07a-to-1.2.5-client/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Mod Properties | ||
archives_base_name = server-stats-mixins-client | ||
|
||
# Mod Properties | ||
minecraft_version_min = 1.1.0-alpha.12w07a | ||
minecraft_version_max = 1.2.5 | ||
|
||
# Minecraft Properties | ||
minecraft_version = 12w07a | ||
|
||
nests_version = 12w07a-client+build.1 | ||
feather_version = 12w07a-client+build.11 |
6 changes: 6 additions & 0 deletions
6
...1.2.0-alpha.12w07a-to-1.2.5-client/src/main/java/net/lostluma/server_stats/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.lostluma.server_stats; | ||
|
||
public class Constants { | ||
public static final String MOD_ID = "server_stats"; | ||
public static final String STATS_PACKET_CHANNEL = MOD_ID + "|s"; | ||
} |
30 changes: 30 additions & 0 deletions
30
...5-client/src/main/java/net/lostluma/server_stats/mixin/client/LocalPlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.lostluma.server_stats.mixin.client; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.client.entity.living.player.InputPlayerEntity; | ||
import net.minecraft.client.entity.living.player.LocalPlayerEntity; | ||
import net.minecraft.entity.living.player.PlayerEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin({ InputPlayerEntity.class, LocalPlayerEntity.class }) | ||
public class LocalPlayerEntityMixin { | ||
private PlayerEntity getPlayer() { | ||
return (PlayerEntity) (Object) this; | ||
} | ||
|
||
@Inject(method = "incrementStat(Lnet/minecraft/stat/Stat;I)V", at = @At("HEAD")) | ||
private void incrementStat(net.minecraft.stat.Stat vanillaStat, int amount, CallbackInfo callbackInfo) { | ||
if (vanillaStat == null) { | ||
return; | ||
} | ||
|
||
var stat = Stats.byVanillaId(vanillaStat.id); | ||
|
||
if (stat != null) { | ||
this.getPlayer().server_stats$incrementStat(stat, amount); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-to-1.2.5-client/src/main/java/net/lostluma/server_stats/mixin/client/MinecraftMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.lostluma.server_stats.mixin.client; | ||
|
||
import net.lostluma.server_stats.stats.ServerPlayerStats; | ||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.living.player.InputPlayerEntity; | ||
import net.minecraft.world.WorldSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Minecraft.class) | ||
public class MinecraftMixin { | ||
@Shadow | ||
public InputPlayerEntity player; | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void onInit(CallbackInfo callbackInfo) { | ||
Stats.init(); | ||
} | ||
|
||
@Inject(method = "startGame", at = @At("HEAD")) | ||
private void startGame(String worldDir, String worldName, WorldSettings worldSettings, CallbackInfo callbackInfo) { | ||
ServerPlayerStats.setWorldDirectory(String.format("saves/%s", worldDir)); | ||
} | ||
|
||
@Inject(method = "m_4977780", at = @At("TAIL")) | ||
private void changeDimension(int dimension, CallbackInfo callbackInfo) { | ||
this.player.server_stats$saveStats(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...1.2.5-client/src/main/java/net/lostluma/server_stats/mixin/client/PacketHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.lostluma.server_stats.mixin.client; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
import net.lostluma.server_stats.Constants; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.network.handler.ClientNetworkHandler; | ||
import net.minecraft.network.PacketHandler; | ||
import net.minecraft.network.packet.CustomPayloadPacket; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.lang.reflect.Type; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Map; | ||
|
||
@Mixin(PacketHandler.class) | ||
public class PacketHandlerMixin { | ||
@Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true) | ||
private void handleCustomPayload(CustomPayloadPacket packet, CallbackInfo callbackInfo) { | ||
if (!packet.channel.equals(Constants.STATS_PACKET_CHANNEL)) { | ||
return; | ||
} | ||
|
||
var data = new String(packet.data, StandardCharsets.UTF_8); | ||
|
||
Type type = new TypeToken<Map<String, Integer>>(){}.getType(); | ||
Map<String, Integer> result = new Gson().fromJson(data, type); | ||
|
||
Minecraft.INSTANCE.statHandler.player_stats$override(result); | ||
callbackInfo.cancel(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...o-1.2.5-client/src/main/java/net/lostluma/server_stats/mixin/client/PlayerStatsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package net.lostluma.server_stats.mixin.client; | ||
|
||
import net.lostluma.server_stats.types.OverridableStats; | ||
import net.minecraft.stat.PlayerStats; | ||
import net.minecraft.stat.Stat; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
@Mixin(PlayerStats.class) | ||
public class PlayerStatsMixin implements OverridableStats { | ||
@Shadow | ||
private Map<Stat, Integer> stats; | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void onInit(CallbackInfo callbackInfo) { | ||
this.stats = Collections.synchronizedMap(this.stats); | ||
} | ||
|
||
@Override | ||
public void player_stats$override(Map<String, Integer> override) { | ||
// Reset all stats for the case where the world joined has some stats not set | ||
this.stats.keySet().removeAll( | ||
this.stats.keySet().stream().filter(integer -> !integer.isAchievement()).toList() | ||
); | ||
|
||
override.forEach((key, value) -> { | ||
var stat = this.player_stats$getVanillaStat(key); | ||
|
||
if (stat != null) { | ||
this.stats.put(stat, value); | ||
} else { | ||
System.out.println("No client-side stat found for key " + key + "."); | ||
} | ||
}); | ||
} | ||
|
||
private @Nullable Stat player_stats$getVanillaStat(String key) { | ||
var stat = net.lostluma.server_stats.stats.Stats.byKey(key); | ||
|
||
if (stat == null || stat.vanillaId == null) { | ||
return null; | ||
} else { | ||
return net.minecraft.stat.Stats.byKey(stat.vanillaId); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...a-to-1.2.5-client/src/main/java/net/lostluma/server_stats/mixin/common/EntitiesMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.lostluma.server_stats.mixin.common; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.entity.Entities; | ||
|
||
@Mixin(Entities.class) | ||
public class EntitiesMixin { | ||
@Inject(method = "register", at = @At("TAIL")) | ||
private static void registerWithSpawnEgg(Class<?> type, String key, int id, CallbackInfo callbackInfo) { | ||
Stats.createEntityKillStat(key); | ||
Stats.createKilledByEntityStat(key); | ||
} | ||
} |
Oops, something went wrong.