From 4b9356d04964d5e6194a726817187618d6658131 Mon Sep 17 00:00:00 2001 From: UselessBullets <80850784+UselessBullets@users.noreply.github.com> Date: Sat, 14 Oct 2023 09:34:36 -0500 Subject: [PATCH] Stat system now equivalent in functionality to vanilla Still bug where picking up items doesn't get logged but issue exists in vanilla too. Interacting with the item in your inventory logs it though --- .../halplibe/mixin/mixins/registry/BlockMixin.java | 4 ++++ .../halplibe/mixin/mixins/registry/MinecraftMixin.java | 2 ++ .../mixin/mixins/registry/MinecraftServerMixin.java | 9 +++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/BlockMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/BlockMixin.java index 8c8f986..6ea3aaa 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/BlockMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/BlockMixin.java @@ -4,6 +4,7 @@ import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import turniplabs.halplibe.helper.BlockHelper; @@ -17,4 +18,7 @@ public class BlockMixin { private static void captureHighest(CallbackInfo ci) { BlockHelper.highestVanilla = highestBlockId; } + @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/achievement/stat/StatList;onBlockInit()V")) + private static void delayInit() { + } } diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftMixin.java index 1d1c578..d6e10fd 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftMixin.java @@ -19,6 +19,8 @@ public void postInit(CallbackInfo ci) { m.setAccessible(true); m.invoke(null); m.setAccessible(false); + StatList.init(); + StatList.onBlockInit(); StatList.onItemInit(); } catch (Throwable err) { throw new RuntimeException(err); diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftServerMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftServerMixin.java index 181899f..641a0de 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftServerMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/registry/MinecraftServerMixin.java @@ -1,15 +1,11 @@ package turniplabs.halplibe.mixin.mixins.registry; -import net.minecraft.client.Minecraft; -import net.minecraft.core.achievement.stat.StatBase; import net.minecraft.core.achievement.stat.StatList; -import net.minecraft.core.item.Item; import net.minecraft.server.MinecraftServer; 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 turniplabs.halplibe.helper.BlockHelper; import turniplabs.halplibe.helper.RegistryHelper; import java.lang.reflect.Method; @@ -23,8 +19,9 @@ public void postInit(CallbackInfo ci) { m.setAccessible(true); m.invoke(null); m.setAccessible(false); - StatList.craftedItemStats = new StatBase[Item.itemsList.length]; - StatList.pickUpItemStats = new StatBase[Item.itemsList.length]; + StatList.init(); + StatList.onBlockInit(); + StatList.onItemInit(); } catch (Throwable err) { throw new RuntimeException(err); }