aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java b/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
new file mode 100644
index 0000000..b27b219
--- /dev/null
+++ b/src/main/java/com/anthonyhilyard/iceberg/mixin/PlayerAdvancementsMixin.java
@@ -0,0 +1,31 @@
+package com.anthonyhilyard.iceberg.mixin;
+
+import com.anthonyhilyard.iceberg.events.CriterionEvent;
+
+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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
+import net.minecraft.advancements.Advancement;
+import net.minecraft.advancements.PlayerAdvancements;
+import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraftforge.common.MinecraftForge;
+
+@Mixin(PlayerAdvancements.class)
+public class PlayerAdvancementsMixin
+{
+ @Shadow
+ private ServerPlayerEntity player;
+
+ @Inject(method = "award", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
+ public void onAward(Advancement advancement, String criterionKey, CallbackInfoReturnable<Boolean> callbackInfo, boolean success)
+ {
+ if (success)
+ {
+ MinecraftForge.EVENT_BUS.post(new CriterionEvent(player, advancement, criterionKey));
+ }
+ }
+}