Skip to content

Commit

Permalink
Move Luminizer stats tracking to ServerPlayerMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealWormbo authored and artemisSystem committed Aug 28, 2024
1 parent da7fffb commit 541c978
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
22 changes: 0 additions & 22 deletions Xplat/src/main/java/vazkii/botania/mixin/PlayerMixin.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
package vazkii.botania.mixin;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import vazkii.botania.common.BotaniaStats;
import vazkii.botania.common.PlayerAccess;
import vazkii.botania.common.entity.BotaniaEntities;
import vazkii.botania.common.item.ResoluteIvyItem;
import vazkii.botania.common.item.equipment.armor.terrasteel.TerrasteelHelmItem;

Expand All @@ -33,22 +27,6 @@ protected PlayerMixin(EntityType<? extends LivingEntity> type, Level level) {
@Unique
private LivingEntity terraWillCritTarget;

@Shadow
public abstract void awardStat(ResourceLocation stat, int i);

/**
* Updates the distance by luminizer stat
*/
@Inject(
at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/entity/player/Player;getVehicle()Lnet/minecraft/world/entity/Entity;"),
method = "checkRidingStatistics", locals = LocalCapture.CAPTURE_FAILSOFT
)
private void trackLuminizerTravel(double dx, double dy, double dz, CallbackInfo ci, int cm, Entity mount) {
if (mount.getType() == BotaniaEntities.PLAYER_MOVER) {
awardStat(BotaniaStats.LUMINIZER_ONE_CM, cm);
}
}

@Override
public void botania$setCritTarget(LivingEntity entity) {
this.terraWillCritTarget = entity;
Expand Down
27 changes: 26 additions & 1 deletion Xplat/src/main/java/vazkii/botania/mixin/ServerPlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,45 @@
*/
package vazkii.botania.mixin;

import com.mojang.authlib.GameProfile;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import vazkii.botania.common.BotaniaStats;
import vazkii.botania.common.entity.BotaniaEntities;
import vazkii.botania.common.handler.EquipmentHandler;
import vazkii.botania.common.world.SkyblockWorldEvents;
import vazkii.botania.xplat.XplatAbstractions;

@Mixin(ServerPlayer.class)
public class ServerPlayerMixin {
public abstract class ServerPlayerMixin extends Player {
protected ServerPlayerMixin(Level level, BlockPos pos, float yRot, GameProfile gameProfile) {
super(level, pos, yRot, gameProfile);
}

/**
* Updates the distance by luminizer stat
*/
@Inject(
at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/server/level/ServerPlayer;getVehicle()Lnet/minecraft/world/entity/Entity;"),
method = "checkRidingStatistics", locals = LocalCapture.CAPTURE_FAILSOFT
)
private void trackLuminizerTravel(double dx, double dy, double dz, CallbackInfo ci, int cm, Entity mount) {
if (mount.getType() == BotaniaEntities.PLAYER_MOVER) {
awardStat(BotaniaStats.LUMINIZER_ONE_CM, cm);
}
}

/**
* Setups up a player when spawning into a GoG world for the first time
*/
Expand Down

0 comments on commit 541c978

Please sign in to comment.