Last active
August 7, 2016 14:02
-
-
Save justisr/3b653dbe97f939f26dfff9aebdb75a42 to your computer and use it in GitHub Desktop.
A single method util for getting the resulting potion from a potion brew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EventHandler | |
public void brew(BrewEvent e) { | |
ItemStack[] contents = e.getContents().getContents(); | |
for (int i = 2; i >= 0; i--) { | |
PotionType type = result(contents[i], contents[3]); | |
if (type == null) continue; | |
} | |
} | |
private static PotionType result(ItemStack potion, ItemStack ing) { | |
if (potion == null) return null; | |
Material type = ing.getType(); | |
if (potion.getDurability() == 0) { | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.WEAKNESS; | |
return PotionType.WATER; | |
} | |
Potion pot = Potion.fromItemStack(potion); | |
if (pot.getType() == null) pot.setType(PotionType.WATER); | |
switch (pot.getType()) { | |
case FIRE_RESISTANCE: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.SLOWNESS; | |
return pot.getType(); | |
case INSTANT_DAMAGE: | |
return pot.getType(); | |
case INSTANT_HEAL: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.INSTANT_DAMAGE; | |
return pot.getType(); | |
case INVISIBILITY: | |
return pot.getType(); | |
case NIGHT_VISION: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.INVISIBILITY; | |
return pot.getType(); | |
case POISON: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.INSTANT_DAMAGE; | |
return pot.getType(); | |
case REGEN: | |
return pot.getType(); | |
case SLOWNESS: | |
return pot.getType(); | |
case SPEED: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.SLOWNESS; | |
return pot.getType(); | |
case STRENGTH: | |
return pot.getType(); | |
case WATER: | |
if (potion.getDurability() == 16) | |
if (type == Material.GOLDEN_CARROT) | |
return PotionType.NIGHT_VISION; | |
if (type == Material.MAGMA_CREAM) | |
return PotionType.FIRE_RESISTANCE; | |
if (type == Material.SUGAR) | |
return PotionType.SPEED; | |
if (type == Material.RAW_FISH && ing.getDurability() == 3) | |
return PotionType.WATER_BREATHING; | |
if (type == Material.SPECKLED_MELON) | |
return PotionType.INSTANT_HEAL; | |
if (type == Material.SPIDER_EYE) | |
return PotionType.POISON; | |
if (type == Material.GHAST_TEAR) | |
return PotionType.REGEN; | |
if (type == Material.BLAZE_POWDER) | |
return PotionType.STRENGTH; | |
return PotionType.WATER; | |
case WATER_BREATHING: | |
if (type == Material.FERMENTED_SPIDER_EYE) | |
return PotionType.INSTANT_DAMAGE; | |
return pot.getType(); | |
case WEAKNESS: | |
return pot.getType(); | |
default: return pot.getType(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment