Cleaned up events a bit

This commit is contained in:
Ellpeck 2015-11-23 19:17:17 +01:00
parent 60ad0b1caa
commit aeb340fe57
5 changed files with 15 additions and 54 deletions

View file

@ -13,7 +13,7 @@ package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
import ellpeck.actuallyadditions.nei.NeiScreenEvents; import ellpeck.actuallyadditions.nei.NeiScreenEvents;
import ellpeck.actuallyadditions.update.UpdateCheckerClientNotifier; import ellpeck.actuallyadditions.update.UpdateCheckerClientNotificationEvent;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -23,11 +23,8 @@ public class InitEvents{
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Events..."); ModUtil.LOGGER.info("Initializing Events...");
Util.registerEvent(new SmeltEvent()); Util.registerEvent(new PlayerObtainEvents());
Util.registerEvent(new CraftEvent());
Util.registerEvent(new LivingDropEvent()); Util.registerEvent(new LivingDropEvent());
Util.registerEvent(new PickupEvent());
Util.registerEvent(new EntityLivingEvent()); Util.registerEvent(new EntityLivingEvent());
Util.registerEvent(new BucketFillEvent()); Util.registerEvent(new BucketFillEvent());
Util.registerEvent(new LogoutEvent()); Util.registerEvent(new LogoutEvent());
@ -43,7 +40,7 @@ public class InitEvents{
} }
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){
Util.registerEvent(new UpdateCheckerClientNotifier()); Util.registerEvent(new UpdateCheckerClientNotificationEvent());
} }
} }

View file

@ -1,23 +0,0 @@
/*
* This file ("PickupEvent.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import ellpeck.actuallyadditions.achievement.InitAchievements;
public class PickupEvent{
@SubscribeEvent
public void onPickupEvent(PlayerEvent.ItemPickupEvent event){
CraftEvent.checkAchievements(event.pickedUp.getEntityItem(), event.player, InitAchievements.PICKUP_ACH);
}
}

View file

@ -25,7 +25,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
public class CraftEvent{ public class PlayerObtainEvents{
@SubscribeEvent @SubscribeEvent
public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){ public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){
@ -46,6 +46,16 @@ public class CraftEvent{
} }
} }
@SubscribeEvent
public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){
checkAchievements(event.smelting, event.player, InitAchievements.SMELTING_ACH);
}
@SubscribeEvent
public void onPickupEvent(PlayerEvent.ItemPickupEvent event){
checkAchievements(event.pickedUp.getEntityItem(), event.player, InitAchievements.PICKUP_ACH);
}
public static void checkAchievements(ItemStack gotten, EntityPlayer player, int type){ public static void checkAchievements(ItemStack gotten, EntityPlayer player, int type){
for(int i = 0; i < TheAchievements.values().length; i++){ for(int i = 0; i < TheAchievements.values().length; i++){
TheAchievements ach = TheAchievements.values()[i]; TheAchievements ach = TheAchievements.values()[i];

View file

@ -1,23 +0,0 @@
/*
* This file ("SmeltEvent.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import ellpeck.actuallyadditions.achievement.InitAchievements;
public class SmeltEvent{
@SubscribeEvent
public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){
CraftEvent.checkAchievements(event.smelting, event.player, InitAchievements.SMELTING_ACH);
}
}

View file

@ -18,7 +18,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
public class UpdateCheckerClientNotifier{ public class UpdateCheckerClientNotificationEvent{
private static boolean notified = false; private static boolean notified = false;
private static int ticksElapsedBeforeInfo; private static int ticksElapsedBeforeInfo;