From 93cfe0cd5fca75e2d1f7f74c7e45a93b29159957 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 3 Jul 2015 00:21:20 +0200 Subject: [PATCH] Some More Updating, Crash Prevention --- .../actuallyadditions/ActuallyAdditions.java | 2 -- .../config/ConfigurationHandler.java | 2 +- .../actuallyadditions/event/InitEvents.java | 1 - .../event/LivingKillEvent.java | 20 ----------- .../tile/TileEntityInputter.java | 6 ++-- .../update/UpdateChecker.java | 33 ++++++++++--------- 6 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/ellpeck/actuallyadditions/event/LivingKillEvent.java diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index 6599c6d14..85dcbf014 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -92,10 +92,8 @@ public class ActuallyAdditions{ @EventHandler public void serverStarting(FMLServerStartingEvent event){ - Util.registerDispenserHandler(InitItems.itemBucketOil, new DispenserHandlerEmptyBucket()); Util.registerDispenserHandler(InitItems.itemBucketCanolaOil, new DispenserHandlerEmptyBucket()); Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize()); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java index ad0f84a36..37f71d731 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java @@ -18,7 +18,7 @@ public class ConfigurationHandler{ ConfigValues.defineConfigValues(config); } catch(Exception e){ - e.printStackTrace(); + ModUtil.LOGGER.error("Loading the Config File failed!", e); } finally{ if(config.hasChanged()){ diff --git a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java index 82be3f69f..00f38e659 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java @@ -15,7 +15,6 @@ public class InitEvents{ Util.registerEvent(new TooltipEvent()); Util.registerEvent(new EntityLivingEvent()); Util.registerEvent(new WorldDecorationEvent()); - //Util.registerEvent(new LivingKillEvent()); Util.registerEvent(new BucketFillEvent()); } diff --git a/src/main/java/ellpeck/actuallyadditions/event/LivingKillEvent.java b/src/main/java/ellpeck/actuallyadditions/event/LivingKillEvent.java deleted file mode 100644 index 7b95f5a22..000000000 --- a/src/main/java/ellpeck/actuallyadditions/event/LivingKillEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package ellpeck.actuallyadditions.event; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.event.entity.living.LivingDeathEvent; - -public class LivingKillEvent{ - - private static final int SQUID_MESSAGES = 3; - - @SubscribeEvent - public void onDeathEvent(LivingDeathEvent event){ - /*if(event.source.getEntity() instanceof EntityPlayer){ - if(event.entity instanceof EntitySquid){ - String message = StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".squidKilled.desc."+(new Random().nextInt(SQUID_MESSAGES)+1)); - ((EntityPlayer)event.source.getEntity()).addChatComponentMessage(new ChatComponentText(message)); - event.source.getEntity().worldObj.playSoundAtEntity(event.source.getEntity(), "mob.wither.death", 0.3F, 0.001F); - } - }*/ - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java index f9b675686..18ce63522 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java @@ -139,7 +139,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt ItemStack theStack = null; for(int i = theSlotToPull; i < this.slotToPullEnd; i++){ - if(i < 0 || i >= theInventory.getSizeInventory()) return; + if(i < 0) continue; + if(i >= theInventory.getSizeInventory()) return; ItemStack tempStack = theInventory.getStackInSlot(i); if(tempStack != null){ @@ -201,7 +202,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt if(this.slots[0] != null){ ItemStack theStack = null; for(int i = theSlotToPut; i < this.slotToPutEnd; i++){ - if(i < 0 || i >= theInventory.getSizeInventory()) return; + if(i < 0) continue; + if(i >= theInventory.getSizeInventory()) return; ItemStack tempStack = theInventory.getStackInSlot(i); if(tempStack != null){ diff --git a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java index f49a70175..b449c6128 100644 --- a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java +++ b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java @@ -28,7 +28,7 @@ public class UpdateChecker{ new UpdateCheckThread(); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void onTick(TickEvent.ClientTickEvent event){ if(doneChecking && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().thePlayer != null && !notified){ EntityPlayer player = Minecraft.getMinecraft().thePlayer; @@ -36,20 +36,24 @@ public class UpdateChecker{ player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".update.failed.desc"))); } else if(onlineVersion.length() > 0){ - int update = Integer.parseInt(onlineVersion.replace("-", "").replace(".", "")); - int client = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", "")); + try{ + int update = Integer.parseInt(onlineVersion.replace("-", "").replace(".", "")); + int client = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", "")); - if(update > client){ - String notice1 = "info." + ModUtil.MOD_ID_LOWER + ".update.generic.desc"; - String notice2 = "info." + ModUtil.MOD_ID_LOWER + ".update.versionComp.desc"; - String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".update.changelog.desc"; - String notice4 = "info." + ModUtil.MOD_ID_LOWER + ".update.download.desc"; - player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1))); - player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, onlineVersion))); - player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog))); - player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice4, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files"))); + if(update > client){ + String notice1 = "info."+ModUtil.MOD_ID_LOWER+".update.generic.desc"; + String notice2 = "info."+ModUtil.MOD_ID_LOWER+".update.versionComp.desc"; + String notice3 = "info."+ModUtil.MOD_ID_LOWER+".update.changelog.desc"; + String notice4 = "info."+ModUtil.MOD_ID_LOWER+".update.download.desc"; + player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1))); + player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, onlineVersion))); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog))); + player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice4, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files"))); + } + } + catch(Exception e){ + ModUtil.LOGGER.error("Sending the Update Check Information to the Chat failed!", e); } - } notified = true; } @@ -80,9 +84,8 @@ public class UpdateChecker{ ModUtil.LOGGER.info("Update Check done!"); } catch(Exception e){ - ModUtil.LOGGER.error("Update Check failed!"); checkFailed = true; - e.printStackTrace(); + ModUtil.LOGGER.error("Update Check failed!", e); } doneChecking = true; }