Skip to content

Commit

Permalink
Updating drop logic from blocks and crops, Adding multiple effects fo…
Browse files Browse the repository at this point in the history
…r foods and adding isWolfFood propertie to food
  • Loading branch information
Otho committed Dec 5, 2014
1 parent 7d93a3d commit 7096fbb
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 137 deletions.
108 changes: 108 additions & 0 deletions src/main/java/com/Otho/customItems/configuration/Cfg_PotionEffect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.Otho.customItems.configuration;

public class Cfg_PotionEffect {
public String effect = "moveSpeed";
public int potionDuration = 30;
public int potionAmplifier = 0;
public float potionEffectProbability = 1;

public static int potionEffectId (String effect)
{
if(effect.equals("moveSpeed"))
{
return 1;
}
else if(effect.equals("moveSlowdown"))
{
return 2;
}
else if(effect.equals("digSpeed"))
{
return 3;
}
else if(effect.equals("digSlowdown"))
{
return 4;
}
else if(effect.equals("damageBoost"))
{
return 5;
}
else if(effect.equals("heal"))
{
return 6;
}
else if(effect.equals("harm"))
{
return 7;
}
else if(effect.equals("jump"))
{
return 8;
}
else if(effect.equals("confusion"))
{
return 9;
}
else if(effect.equals("regeneration"))
{
return 10;
}
else if(effect.equals("resistance"))
{
return 11;
}
else if(effect.equals("fireResistance"))
{
return 12;
}
else if(effect.equals("waterBreathing"))
{
return 13;
}
else if(effect.equals("invisibility"))
{
return 14;
}
else if(effect.equals("blindness"))
{
return 15;
}
else if(effect .equals("nightVision"))
{
return 16;
}
else if(effect.equals("hunger"))
{
return 17;
}
else if(effect.equals("weakness"))
{
return 18;
}
else if(effect.equals("poison"))
{
return 19;
}
else if(effect.equals("wither"))
{
return 20;
}
else if(effect.equals("healthBoost"))
{
return 21;
}
else if(effect.equals("healthBoost"))
{
return 22;
}
else if(effect.equals("healthBoost"))
{
return 23;
}
else
{
return 6;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Cfg_block extends Cfg_basicData
public float hardness = 2;
public float lightLevel = 0;
public int harvestLevel = 0;
public SideTextures multipleTextures;
public Cfg_sideTextures multipleTextures;

public String stepSound = "stone";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ public class Cfg_food extends Cfg_item
public int healAmount = 1;
public float saturationModifier = 1;
public boolean alwaysEdible = false;
public PotionEffect potionEffect;
public boolean isWolfFood = false;

public Cfg_PotionEffect[] potionEffects;

public class PotionEffect{
public String effect = "moveSpeed";
public int potionDuration = 20;
public int potionAmplifier = 1;
public float potionEffectProbability = 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.Otho.customItems.configuration;

public class SideTextures {
public class Cfg_sideTextures {
public String ypos;
public String yneg;
public String xpos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,14 @@ private static void registerSingleFood(Cfg_food foodData)

String registerName = StringUtil.parseRegisterName(foodData.name);

CustomFood food = new CustomFood(foodData.healAmount, foodData.saturationModifier, false);
CustomFood food = new CustomFood(foodData.healAmount, foodData.saturationModifier, foodData.isWolfFood);

if(foodData.alwaysEdible)
food.setAlwaysEdible();

if(foodData.potionEffect != null)
if(foodData.potionEffects.length > 0)
{
food.setPotionEffect(potionEffectId(foodData.potionEffect.effect),
foodData.potionEffect.potionDuration,
foodData.potionEffect.potionAmplifier,
foodData.potionEffect.potionEffectProbability);
food.setFoodEffectsArray(foodData.potionEffects);
}


Expand Down Expand Up @@ -664,7 +661,7 @@ private static void registerSingleHelmet(Cfg_helmet helmetData)
reduction[0] = helmetData.reductionNum;

ItemArmor.ArmorMaterial material = EnumHelper.addArmorMaterial(helmetData.textureName, helmetData.durability, reduction, helmetData.enchantability);
CustomArmor armor = new CustomArmor(material, 0, 0, helmetData.textureName);
CustomArmor armor = new CustomArmor(material, 0, 0, helmetData.textureName, helmetData.durability);
//Register Armor

itemsList.add(armor);
Expand All @@ -686,7 +683,7 @@ private static void registerSingleChestplate(Cfg_chestplate chestplateData)
reduction[1] = chestplateData.reductionNum;

ItemArmor.ArmorMaterial material = EnumHelper.addArmorMaterial(chestplateData.textureName, chestplateData.durability, reduction, chestplateData.enchantability);
CustomArmor armor = new CustomArmor(material, 0, 1, chestplateData.textureName);
CustomArmor armor = new CustomArmor(material, 0, 1, chestplateData.textureName, chestplateData.durability);
//Register Armor

itemsList.add(armor);
Expand All @@ -707,7 +704,7 @@ private static void registerSingleLeggings(Cfg_leggings leggingData)
reduction[2] = leggingData.reductionNum;

ItemArmor.ArmorMaterial material = EnumHelper.addArmorMaterial(leggingData.textureName, leggingData.durability, reduction, leggingData.enchantability);
CustomArmor armor = new CustomArmor(material, 0, 2, leggingData.textureName);
CustomArmor armor = new CustomArmor(material, 0, 2, leggingData.textureName, leggingData.durability);
//Register Armor

itemsList.add(armor);
Expand All @@ -729,7 +726,7 @@ private static void registerSingleBoots(Cfg_boots bootsData)
reduction[3] = bootsData.reductionNum;

ItemArmor.ArmorMaterial material = EnumHelper.addArmorMaterial(bootsData.textureName, bootsData.durability, reduction, bootsData.enchantability);
CustomArmor armor = new CustomArmor(material, 0, 3, bootsData.textureName);
CustomArmor armor = new CustomArmor(material, 0, 3, bootsData.textureName, bootsData.durability);
//Register Armor

itemsList.add(armor);
Expand Down Expand Up @@ -823,104 +820,4 @@ public static String validateToolClass(String toolClass){
return "pickaxe";
}
}

public static int potionEffectId (String effect)
{
if(effect.equals("moveSpeed"))
{
return 1;
}
else if(effect.equals("moveSlowdown"))
{
return 2;
}
else if(effect.equals("digSpeed"))
{
return 3;
}
else if(effect.equals("digSlowdown"))
{
return 4;
}
else if(effect.equals("damageBoost"))
{
return 5;
}
else if(effect.equals("heal"))
{
return 6;
}
else if(effect.equals("harm"))
{
return 7;
}
else if(effect.equals("jump"))
{
return 8;
}
else if(effect.equals("confusion"))
{
return 9;
}
else if(effect.equals("regeneration"))
{
return 10;
}
else if(effect.equals("resistance"))
{
return 11;
}
else if(effect.equals("fireResistance"))
{
return 12;
}
else if(effect.equals("waterBreathing"))
{
return 13;
}
else if(effect.equals("invisibility"))
{
return 14;
}
else if(effect.equals("blindness"))
{
return 15;
}
else if(effect .equals("nightVision"))
{
return 16;
}
else if(effect.equals("hunger"))
{
return 17;
}
else if(effect.equals("weakness"))
{
return 18;
}
else if(effect.equals("poison"))
{
return 19;
}
else if(effect.equals("wither"))
{
return 20;
}
else if(effect.equals("healthBoost"))
{
return 21;
}
else if(effect.equals("healthBoost"))
{
return 22;
}
else if(effect.equals("healthBoost"))
{
return 23;
}
else
{
return 6;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ private int getItemDropQuantity(World world, int fortune)
{
int ret = 0;
int i;
for(i=0;i < this.maxItemDrop + fortune;i++)
ret = this.minItemDrop;
for(i= this.minItemDrop;i < this.maxItemDrop + fortune;i++)
{
boolean willDrop = world.rand.nextInt(100) < this.eachExtraItemDropChance;
if(willDrop)
ret++;
}
if(ret < this.minItemDrop)
ret = this.minItemDrop;

return ret;
}

}

public void setMaxItemDrop(int maxItemDrop) {
this.maxItemDrop = maxItemDrop;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/Otho/customItems/mod/blocks/CustomCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ private int getSeedDropQuantity(World world, int fortune)
{
int ret = 0;
int i;
for(i=0;i < this.maxSeedDrop + fortune;i++)
ret = this.minSeedDrop;

for(i=this.minSeedDrop;i < this.maxSeedDrop + fortune;i++)
{
boolean willDrop = world.rand.nextInt(100) < this.eachExtraSeedDropChance;
if(willDrop)
ret++;
}
if(ret < this.minSeedDrop)
ret = this.minSeedDrop;

return ret;
}
Expand Down
Loading

0 comments on commit 7096fbb

Please sign in to comment.