-
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.
Merge pull request #2 from Pixaurora/more-client-versions
Add client versions between 1.0.0 and 1.2.5
- Loading branch information
Showing
63 changed files
with
2,535 additions
and
1 deletion.
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
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 |
6 changes: 6 additions & 0 deletions
6
versions/1.0.0-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
...0-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); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ons/1.0.0-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,34 @@ | ||
package net.lostluma.server_stats.mixin.client; | ||
|
||
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 = "<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(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ions/1.0.0-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); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
.../1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/common/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,75 @@ | ||
package net.lostluma.server_stats.mixin.common; | ||
|
||
import net.lostluma.server_stats.stats.Stats; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.living.LivingEntity; | ||
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; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(PlayerEntity.class) | ||
public class PlayerEntityMixin implements StatsPlayer { | ||
@Unique | ||
private ServerPlayerStats server_stats$serverPlayerStats = null; | ||
|
||
private PlayerEntity getPlayer() { | ||
return (PlayerEntity) (Object) this; | ||
} | ||
|
||
@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; | ||
} | ||
|
||
@Inject(method = "onKill", at = @At("HEAD")) | ||
private void onKill(LivingEntity entity, CallbackInfo callbackInfo) { | ||
this.getPlayer().server_stats$incrementStat(Stats.getEntityKillStat(entity), 1); | ||
} | ||
|
||
@Inject(method = "onKilled", at = @At("HEAD")) | ||
private void onKilled(DamageSource source, CallbackInfo callbackInfo) { | ||
if (source.getAttacker() != null) { | ||
var attacker = source.getAttacker(); | ||
this.getPlayer().server_stats$incrementStat(Stats.getKilledByEntityStat(attacker), 1); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
versions/1.0.0-client/src/main/java/net/lostluma/server_stats/mixin/common/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.common; | ||
|
||
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(); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
versions/1.0.0-client/src/main/java/net/lostluma/server_stats/stats/GeneralStat.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,16 @@ | ||
package net.lostluma.server_stats.stats; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class GeneralStat extends Stat { | ||
public GeneralStat(String key, @Nullable Integer vanillaId) { | ||
super(key, vanillaId); | ||
} | ||
|
||
@Override | ||
public Stat register() { | ||
super.register(); | ||
Stats.GENERAL.add(this); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.