package com.yolp900.itsjustacharm.common.avchievemetns;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
public class AchievementTrigger {
@SubscribeEvent
public void onItemPickUp(PlayerEvent.ItemPickupEvent event) {
ItemStack stack = event.pickedUp.getEntityItem();
if (stack != null && stack.getItem() instanceof IPickupAchievement) {
Achievement achievement = ((IPickupAchievement)stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp);
if (achievement != null) {
event.player.addStat(achievement, 1);
}
}
}
@SubscribeEvent
public void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
ItemStack stack = event.crafting;
if (stack != null && stack.getItem() instanceof ICraftAchievement) {
Achievement achievement = ((ICraftAchievement)stack.getItem()).getAchievementOnCraft(stack, event.player, event.craftMatrix);
if (achievement != null) {
event.player.addStat(achievement, 1);
}
}
}
@SubscribeEvent
public void inItemSmelted(PlayerEvent.ItemSmeltedEvent event) {
ItemStack stack = event.smelting;
if (stack != null && stack.getItem() instanceof ISmeltAchievement) {
Achievement achievement = ((ISmeltAchievement)stack.getItem()).getAchievementOnSmelt(stack, event.player);
if (achievement != null) {
event.player.addStat(achievement, 1);
}
}
}
}