-
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.
add client versions between 1.0.0 and 1.2.5
- Loading branch information
Showing
87 changed files
with
3,346 additions
and
0 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
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 | ||
} |
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,8 @@ | ||
# Mod Properties | ||
archives_base_name = server-stats-mixins-client | ||
|
||
# Minecraft Properties | ||
minecraft_version = 1.0.0 | ||
|
||
nests_version = 1.0.0-client+build.1 | ||
feather_version = 1.0.0-client+build.11 |
18 changes: 18 additions & 0 deletions
18
...ions/1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/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.server; | ||
|
||
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); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ons/1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/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,36 @@ | ||
package net.lostluma.server_stats.mixin.server; | ||
|
||
import net.lostluma.server_stats.stats.ServerPlayerStats; | ||
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; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.living.player.InputPlayerEntity; | ||
|
||
@Mixin(Minecraft.class) | ||
public class MinecraftMixin { | ||
@Shadow | ||
public InputPlayerEntity player; | ||
|
||
@Inject(method = "main", at = @At("HEAD")) | ||
private static void onMain(CallbackInfo callbackInfo) { | ||
Stats.init(); | ||
} | ||
|
||
@Inject(method = "startGame", at = @At("HEAD")) | ||
private void loadWorld(String worldDir, String worldName, WorldSettings worldSettings, CallbackInfo callbackInfo) { | ||
ServerPlayerStats.setWorldDirectory(String.format("saves/%s", worldDir)); | ||
} | ||
|
||
// This method is called when the player switches between worlds | ||
@Inject(method = "m_4977780", at = @At("TAIL")) | ||
private void onRespawn(int dimension, CallbackInfo callbackInfo) { | ||
this.player.server_stats$saveStats(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
.../1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/PlayerEntityMixin.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,52 @@ | ||
package net.lostluma.server_stats.mixin.server; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import net.lostluma.server_stats.stats.ServerPlayerStats; | ||
import net.lostluma.server_stats.stats.Stat; | ||
import net.lostluma.server_stats.types.StatsPlayer; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.entity.living.player.PlayerEntity; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public class PlayerEntityMixin implements StatsPlayer { | ||
@Unique | ||
private ServerPlayerStats server_stats$serverPlayerStats = null; | ||
|
||
@Override | ||
public void server_stats$incrementStat(Stat stat, int amount) { | ||
var stats = this.server_stats$getStats(); | ||
var player = (PlayerEntity)(Object)this; | ||
|
||
if (stats != null) { | ||
stats.increment(player, stat, amount); | ||
} | ||
} | ||
|
||
@Override | ||
public void server_stats$saveStats() { | ||
var stats = this.server_stats$getStats(); | ||
|
||
if (stats != null) { | ||
stats.save(); | ||
} | ||
} | ||
|
||
@Override | ||
public @Nullable ServerPlayerStats server_stats$getStats() { | ||
var player = (PlayerEntity)(Object)this; | ||
|
||
// Unmapped method returns true when the server is multiplayer | ||
if (Minecraft.INSTANCE.m_2812472()) { | ||
return null; | ||
} | ||
|
||
if (this.server_stats$serverPlayerStats == null) { | ||
this.server_stats$serverPlayerStats = new ServerPlayerStats(player); | ||
} | ||
|
||
return this.server_stats$serverPlayerStats; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
versions/1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/WorldMixin.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,25 @@ | ||
package net.lostluma.server_stats.mixin.server; | ||
|
||
import java.util.List; | ||
|
||
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 net.minecraft.entity.living.player.PlayerEntity; | ||
import net.minecraft.world.World; | ||
|
||
@Mixin(World.class) | ||
public class WorldMixin { | ||
@Shadow | ||
public List<PlayerEntity> players; | ||
|
||
@Inject(method = "saveData", at = @At("TAIL")) | ||
public void onSave(CallbackInfo callbackInfo) { | ||
for (PlayerEntity player : this.players) { | ||
player.server_stats$saveStats(); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../src/main/java/net/lostluma/server_stats/mixin/server/stats/FishingBobberEntityMixin.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,22 @@ | ||
package net.lostluma.server_stats.mixin.server.stats; | ||
|
||
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.CallbackInfoReturnable; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.entity.FishingBobberEntity; | ||
import net.minecraft.entity.living.player.PlayerEntity; | ||
|
||
@Mixin(FishingBobberEntity.class) | ||
public class FishingBobberEntityMixin { | ||
@Shadow | ||
public PlayerEntity player; | ||
|
||
@Inject(method = "retract", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void onRetract(CallbackInfoReturnable<?> callbackInfo) { | ||
this.player.server_stats$incrementStat(Stats.FISH_CAUGHT, 1); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/stats/ItemStackMixin.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,52 @@ | ||
package net.lostluma.server_stats.mixin.server.stats; | ||
|
||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.entity.living.LivingEntity; | ||
import net.minecraft.entity.living.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
|
||
@Mixin(ItemStack.class) | ||
public class ItemStackMixin { | ||
@Shadow | ||
public int size; | ||
|
||
@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void use(PlayerEntity player, World world, int x, int y, int z, int face, CallbackInfoReturnable<?> callbackInfo) { | ||
var stack = (ItemStack)(Object)this; | ||
player.server_stats$incrementStat(Stats.ITEMS_USED[stack.itemId], 1); | ||
} | ||
|
||
@Inject(method = "damageAndBreak", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void damageAndBreak(int amount, LivingEntity entity, CallbackInfo callbackInfo) { | ||
var stack = (ItemStack)(Object)this; | ||
var player = (PlayerEntity)(Object)entity; | ||
|
||
player.server_stats$incrementStat(Stats.ITEMS_BROKEN[stack.itemId], 1); | ||
} | ||
|
||
@Inject(method = "attackEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void attackEntity(LivingEntity entity, PlayerEntity player, CallbackInfo callbackInfo) { | ||
var stack = (ItemStack)(Object)this; | ||
player.server_stats$incrementStat(Stats.ITEMS_USED[stack.itemId], 1); | ||
} | ||
|
||
@Inject(method = "mineBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void mineBlock(int blockId, int x, int y, int z, PlayerEntity player, CallbackInfo callbackInfo) { | ||
var stack = (ItemStack)(Object)this; | ||
player.server_stats$incrementStat(Stats.ITEMS_USED[stack.itemId], 1); | ||
} | ||
|
||
@Inject(method = "onResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/living/player/PlayerEntity;incrementStat(Lnet/minecraft/stat/Stat;I)V")) | ||
private void onResult(World world, PlayerEntity player, CallbackInfo callbackInfo) { | ||
var stack = (ItemStack)(Object)this; | ||
player.server_stats$incrementStat(Stats.ITEMS_CRAFTED[stack.itemId], this.size); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...0.0-client/src/main/java/net/lostluma/server_stats/mixin/server/stats/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,26 @@ | ||
package net.lostluma.server_stats.mixin.server.stats; | ||
|
||
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 net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.living.player.InputPlayerEntity; | ||
import net.minecraft.entity.living.player.PlayerEntity; | ||
import net.minecraft.world.World; | ||
|
||
@Mixin(Minecraft.class) | ||
public abstract class MinecraftMixin { | ||
@Shadow | ||
public InputPlayerEntity player; | ||
|
||
@Inject(method = "setWorld(Lnet/minecraft/world/World;Ljava/lang/String;Lnet/minecraft/entity/living/player/PlayerEntity;)V", at = @At("HEAD")) | ||
private void detectWorldLeaving(World world, String string, PlayerEntity playerEntity, CallbackInfo callbackInfo) { | ||
if (world == null && this.player != null) { | ||
this.player.server_stats$incrementStat(Stats.GAMES_LEFT, 1); | ||
} | ||
} | ||
} |
Oops, something went wrong.