mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-05 08:29:09 +01:00
29 lines
1.1 KiB
Java
29 lines
1.1 KiB
Java
package ellpeck.actuallyadditions.event;
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
|
import ellpeck.actuallyadditions.achievement.InitAchievements;
|
|
import ellpeck.actuallyadditions.achievement.TheAchievements;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
public class CraftEvent{
|
|
|
|
@SubscribeEvent
|
|
public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){
|
|
checkAchievements(event.crafting, event.player, InitAchievements.CRAFTING_ACH);
|
|
}
|
|
|
|
public static void checkAchievements(ItemStack gotten, EntityPlayer player, int type){
|
|
for(int i = 0; i < TheAchievements.values().length; i++){
|
|
TheAchievements ach = TheAchievements.values()[i];
|
|
if(ach.type == type){
|
|
if(gotten != null && ach.ach.theItemStack != null && gotten.getItem() == ach.ach.theItemStack.getItem()){
|
|
if(gotten.getItemDamage() == ach.ach.theItemStack.getItemDamage()){
|
|
player.addStat(ach.ach, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|