diff --git a/build.gradle b/build.gradle index 42a8faa..48d9bcb 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ plugins { id "net.minecraftforge.gradle.forge" version "2.0.2" } */ -version = "(1.9)-v.1.4.8" +version = "(1.9)-v.1.5.0-SNAPSHOT" group= "com.zyin.zyinhud" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "ZyinsHUD" @@ -33,7 +33,7 @@ minecraft { // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. - mappings = "snapshot_20160312" + mappings = "snapshot_20160404" makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } diff --git a/src/main/java/com/zyin/zyinhud/ZyinHUD.java b/src/main/java/com/zyin/zyinhud/ZyinHUD.java index 7e13382..3173884 100644 --- a/src/main/java/com/zyin/zyinhud/ZyinHUD.java +++ b/src/main/java/com/zyin/zyinhud/ZyinHUD.java @@ -61,7 +61,7 @@ public class ZyinHUD * * If incrementing the Minecraft version, also update "curseFilenameParser" in AddVersionChecker() */ - public static final String VERSION = "1.4.8"; + public static final String VERSION = "1.5.0-SNAPSHOT"; /** * The constant MODID. */ @@ -165,7 +165,7 @@ public void AddVersionChecker() { NBTTagCompound compound = new NBTTagCompound(); compound.setString("curseProjectName", "59953-zyins-hud"); //http://minecraft.curseforge.com/mc-mods/59953-zyins-hud - compound.setString("curseFilenameParser", "ZyinsHUD-(1.8.8)-v.[].jar"); + compound.setString("curseFilenameParser", "ZyinsHUD-(1.9)-v.[].jar"); FMLInterModComms.sendRuntimeMessage(ZyinHUD.MODID, "VersionChecker", "addCurseCheck", compound); } diff --git a/src/main/java/com/zyin/zyinhud/mods/EatingAid.java b/src/main/java/com/zyin/zyinhud/mods/EatingAid.java index 52e7b7a..4bcb667 100644 --- a/src/main/java/com/zyin/zyinhud/mods/EatingAid.java +++ b/src/main/java/com/zyin/zyinhud/mods/EatingAid.java @@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import com.zyin.zyinhud.ZyinHUDRenderer; import com.zyin.zyinhud.mods.Coordinates.Modes; @@ -284,8 +285,8 @@ private void StartEatingFromInventory(int foodInventoryIndex) ItemStack currentItemStack = mc.thePlayer.getHeldItemMainhand(); ItemFood currentFood = (ItemFood)currentItemStack.getItem(); - int eatingDurationInMilliseconds = 1000 * currentFood.itemUseDuration / 20; - + int eatingDurationInMilliseconds = 1000 * currentFood.itemUseDuration / 17; //I think 17 is better, for 20 can only be reached by fast computers + //Alternatively, may be we can introduce tps dectection in the future. if(UsePvPSoup && food.equals(Items.mushroom_stew) && (mc.thePlayer.getHealth() < 20 || mc.thePlayer.getFoodStats().needFood())) //for PvP Soup eating { @@ -403,14 +404,19 @@ public int GetStrongestFoodItemIndexFromInventory() ItemFood food = (ItemFood)item; float saturationModifier = food.getSaturationModifier(itemStack); - Integer potionId = ZyinHUDUtil.GetFieldByReflection(ItemFood.class, food, "potionId", "aaaaaa"); - if (potionId == null) potionId = -1; + PotionEffect potionId = ZyinHUDUtil.GetFieldByReflection(ItemFood.class, food, "potionId", "field_77851_ca"); //Former "aaaaa" + String potionName; + if (potionId == null) { + potionName = ""; + }else{ + potionName = potionId.getEffectName(); + } if (UsePvPSoup && item.equals(Items.mushroom_stew)) { saturationModifier = 1000f; //setting the saturation value very high will make it appealing to the food selection algorithm - } else if (potionId == 16262179 //Former known as `Potion.saturation.id` - || potionId == 16262179) //Potion.heal.id + } else if (potionName.equals("effect.saturation") //Former known as `Potion.saturation.id` + || potionName.equals("effect.heal")) //Potion.heal.id // modded foods like [Botania] Mana Cookie may have these effects { saturationModifier = 999; //setting the saturation value very high will make it appealing to the food selection algorithm @@ -439,9 +445,9 @@ else if(HasSmeltingRecipe(itemStack)) } saturationModifier = 0.0003f; //setting the saturation value low will make it unappealing to the food selection algorithm - } else if (potionId == 5149489 //Potion.poison.id - || potionId == 5797459 //Potion.hunger.id - || potionId == 5578058 //Potion.confusion.id + } else if (potionName.equals("effect.poison") //Potion.poison.id + || potionName.equals("effect.hunger") //Potion.hunger.id + || potionName.equals("effect.confusion") //Potion.confusion.id || FishType.byItemStack(itemStack) == FishType.PUFFERFISH) { saturationModifier = 0.0002f; //setting the saturation value low will make it unappealing to the food selection algorithm @@ -503,14 +509,20 @@ public int GetBestFoodItemIndexFromInventory() int overeat = foodNeeded - heal; overeat = (overeat > 0) ? 0 : Math.abs(overeat); //positive number, amount we would overeat by eating this food - Integer potionId = ZyinHUDUtil.GetFieldByReflection(ItemFood.class, food, "potionId", "field_77851_ca"); - if (potionId == null) potionId = -1; + //Integer potionId = ZyinHUDUtil.GetFieldByReflection(ItemFood.class, food, "potionId", "field_77851_ca"); + PotionEffect potionId = ZyinHUDUtil.GetFieldByReflection(ItemFood.class, food, "potionId", "field_77851_ca"); + String potionName; + if (potionId == null) { + potionName = ""; + }else{ + potionName = potionId.getEffectName(); + } if (UsePvPSoup && item.equals(Items.mushroom_stew)) { overeat = -1000; //setting the overeat value very low will make it appealing to the food selection algorithm - } else if (potionId == 16262179 //Potion.saturation.id - || potionId == 16262179) //Potion.heal.id) //modded foods like [Botania] Mana Cookie may have these effects + } else if (potionName.equals("effect.saturation") //Potion.saturation.id + || potionName.equals("effect.heal")) //Potion.heal.id) //modded foods like [Botania] Mana Cookie may have these effects { overeat = -999; //setting the overeat value very low will make it appealing to the food selection algorithm } @@ -538,9 +550,9 @@ else if(HasSmeltingRecipe(itemStack)) } overeat = 997; //setting the overeat value high will make it unappealing to the food selection algorithm - } else if (potionId == 5149489 //Potion.poison.id - || potionId == 5797459 //Potion.hunger.id - || potionId == 5578058 //Potion.confusion.id + } else if (potionName.equals("effect.poison") //Potion.poison.id + || potionName.equals("effect.hunger") //Potion.hunger.id + || potionName.equals("effect.confusion") //Potion.confusion.id || FishType.byItemStack(itemStack) == FishType.PUFFERFISH) { overeat = 998; //setting the overeat value high will make it unappealing to the food selection algorithm diff --git a/src/main/java/com/zyin/zyinhud/mods/HealthMonitor.java b/src/main/java/com/zyin/zyinhud/mods/HealthMonitor.java index a7d39d1..dec1d06 100644 --- a/src/main/java/com/zyin/zyinhud/mods/HealthMonitor.java +++ b/src/main/java/com/zyin/zyinhud/mods/HealthMonitor.java @@ -79,7 +79,7 @@ private Modes(String friendlyName, String soundName) { } /** - * Sets the next availble mode for this mod + * Sets the next available mode for this mod * * @return the modes */ @@ -88,7 +88,7 @@ public static Modes ToggleMode() { } /** - * Sets the next availble mode for this mod if forward=true, or previous mode if false + * Sets the next available mode for this mod if forward=true, or previous mode if false * * @param forward the forward * @return the modes diff --git a/src/main/java/com/zyin/zyinhud/mods/PotionAid.java b/src/main/java/com/zyin/zyinhud/mods/PotionAid.java index c04cbac..54f0b33 100644 --- a/src/main/java/com/zyin/zyinhud/mods/PotionAid.java +++ b/src/main/java/com/zyin/zyinhud/mods/PotionAid.java @@ -252,6 +252,9 @@ public int GetMostAppropriatePotionItemIndexFromInventory() continue; } List potionEffects = PotionUtils.getEffectsFromStack(itemStack); //FIXME: Temporary fix + if (potionEffects.isEmpty()) { + continue; + } PotionEffect potionEffect = (PotionEffect) potionEffects.get(0); String potionEffectName = potionEffect.getEffectName(); diff --git a/src/main/java/com/zyin/zyinhud/util/InventoryUtil.java b/src/main/java/com/zyin/zyinhud/util/InventoryUtil.java index c9e6f6b..887d60a 100644 --- a/src/main/java/com/zyin/zyinhud/util/InventoryUtil.java +++ b/src/main/java/com/zyin/zyinhud/util/InventoryUtil.java @@ -1382,7 +1382,7 @@ private static void SendInventoryClick(int itemIndex, boolean rightClick, boolea try { - mc.playerController.func_187098_a( + mc.playerController.windowClick( mc.thePlayer.inventoryContainer.windowId, itemIndex, (rightClick) ? 1 : 0, @@ -1411,7 +1411,7 @@ private static void SendContainerClick(int itemIndex, boolean rightClick, boolea try { - mc.playerController.func_187098_a( //Former <>.windowClick( + mc.playerController.windowClick( mc.thePlayer.openContainer.windowId, itemIndex, (rightClick) ? 1 : 0, diff --git a/src/main/resources/assets/zyinhud/sounds.json b/src/main/resources/assets/zyinhud/sounds.json index 5e26cd0..1f37c48 100644 --- a/src/main/resources/assets/zyinhud/sounds.json +++ b/src/main/resources/assets/zyinhud/sounds.json @@ -1,38 +1,74 @@ { - "lowhealth_AoL": { - "category": "master", - "sounds": [ - "hud/lowhealth_AoL" - ] - }, - "lowhealth_LA": { - "category": "master", - "sounds": [ - "hud/lowhealth_LA" - ] - }, - "lowhealth_LoZ": { - "category": "master", - "sounds": [ - "hud/lowhealth_LoZ" - ] - }, - "lowhealth_LttP": { - "category": "master", - "sounds": [ - "hud/lowhealth_LttP" - ] - }, - "lowhealth_OoT": { - "category": "master", - "sounds": [ - "hud/lowhealth_OoT" - ] - }, - "lowhealth_Oracle": { - "category": "master", - "sounds": [ - "hud/lowhealth_Oracle" - ] - } -} \ No newline at end of file + "lowhealth_AoL": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_AoL", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_AoL" + ] + }, + "lowhealth_LA": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_LA", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_LA" + ] + }, + "lowhealth_LoZ": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_LoZ", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_LoZ" + ] + }, + "lowhealth_LttP": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_LttP", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_LttP" + ] + }, + "lowhealth_OoT": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_OoT", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_OoT" + ] + }, + "lowhealth_Oracle": { + "category": "master", + "replace": false, + "sounds": [ + { + "name": "lowhealth_Oracle", + "type": "event", + "weight": 6 + }, + "zyinhud:hud/lowhealth_Oracle" + ] + } +} diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index af636d0..ba9e32a 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,7 +2,7 @@ { "modid": "zyinhud", "name": "Zyin's HUD", - "version": "1.4.8.1-SNAPSHOT", + "version": "1.5.0-SNAPSHOT", "mcversion": "1.9", "url": "http://minecraft.curseforge.com/projects/zyins-hud", "updateUrl": "http://minecraft.curseforge.com/projects/zyins-hud/files",