Some final touches on the potion item, everything seems to be going well now.

This commit is contained in:
Lizbeth Rika committed 2014-11-02 00:22:49 +00:00
1 parent 6214e8b0c6
commit d9d15ff0ed
2 files changed
+24 -17

No files matched your search

@@ -22,8 +22,8 @@ public class ModBrews {
public static Brew strength;
public static void init() {
speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 2000, new PotionEffect(Potion.moveSpeed.id, 1200, 1));
strength = new BrewMod(LibBrewNames.STRENGTH, 0XEE3F3F, 2000, new PotionEffect(Potion.damageBoost.id, 1200, 1));
speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 2000, new PotionEffect(Potion.moveSpeed.id, 1800, 1));
strength = new BrewMod(LibBrewNames.STRENGTH, 0XEE3F3F, 2000, new PotionEffect(Potion.damageBoost.id, 1800, 1));
}
}
@@ -76,22 +76,29 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem {
@Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) {
PotionEffect newEffect = new PotionEffect(effect);
player.addPotionEffect(newEffect);
}
if(!world.isRemote && world.rand.nextBoolean())
world.playSoundAtEntity(player, "random.burp", 0.4F, 1F);
int swigs = getSwigsLeft(stack);
if(!player.capabilities.isCreativeMode) {
if(swigs == 1)
return baseItem.copy();
if(!player.worldObj.isRemote) {
for(PotionEffect effect : getBrew(stack).getPotionEffects(stack)) {
PotionEffect newEffect = new PotionEffect(effect);
player.addPotionEffect(newEffect);
}
setSwigsLeft(stack, swigs - 1);
if(!world.isRemote && world.rand.nextBoolean())
world.playSoundAtEntity(player, "random.burp", 0.4F, 1F);
int swigs = getSwigsLeft(stack);
if(!player.capabilities.isCreativeMode) {
if(swigs == 1) {
ItemStack copy = baseItem.copy();
if(!player.inventory.addItemStackToInventory(copy))
return baseItem.copy();
return null;
}
setSwigsLeft(stack, swigs - 1);
}
}
return stack;
}
@@ -120,7 +127,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem {
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return pass == 0 ? itemIcon : icons[Math.max(0, swigs - getSwigsLeft(stack))];
return pass == 0 ? itemIcon : icons[Math.max(0, Math.min(icons.length - 1, swigs - getSwigsLeft(stack)))];
}
@Override