Skip to content

Commit

Permalink
Fix several bugs and bump to version 1.5.0
Browse files Browse the repository at this point in the history
Sound System works now
Potion Aid works now
  • Loading branch information
liushuyu committed Apr 7, 2016
1 parent fcf5f7e commit eee93d4
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 62 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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.
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zyin/zyinhud/ZyinHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ZyinHUD
* </ol>
* 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.
*/
Expand Down Expand Up @@ -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);
}

Expand Down
44 changes: 28 additions & 16 deletions src/main/java/com/zyin/zyinhud/mods/EatingAid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zyin/zyinhud/mods/HealthMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/zyin/zyinhud/mods/PotionAid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zyin/zyinhud/util/InventoryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
110 changes: 73 additions & 37 deletions src/main/resources/assets/zyinhud/sounds.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
"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"
]
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit eee93d4

Please sign in to comment.