mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 19:59:36 +00:00
Brews and potions
This commit is contained in:
1 parent
c23b9dcaee
commit
fe16702db4
7 files changed
+37
-70
No files matched your search
@@ -28,7 +28,7 @@ public class Brew {
|
||||
private final String name;
|
||||
private final int color;
|
||||
private final int cost;
|
||||
private final List<PotionEffectShim> effects;
|
||||
private final List<PotionEffect> effects;
|
||||
boolean canInfuseBloodPendant = true;
|
||||
boolean canInfuseIncense = true;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Brew {
|
||||
* @param cost The cost, in Mana for this brew.
|
||||
* @param effects A list of effects to apply to the player when they drink it.
|
||||
*/
|
||||
public Brew(String key, String name, int color, int cost, PotionEffectShim... effects) {
|
||||
public Brew(String key, String name, int color, int cost, PotionEffect... effects) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.color = color;
|
||||
@@ -116,23 +116,13 @@ public class Brew {
|
||||
return getManaCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PotionEffectShim's that this brew has.
|
||||
*/
|
||||
public List<PotionEffectShim> getPotionEffectsShim(ItemStack stack) {
|
||||
return effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of vanilla PotionEffects for the ItemStack passed in.
|
||||
* Note that for the lexicon, this passes in a botania Managlass
|
||||
* Vial or an Alfglass Flask at all times.
|
||||
*/
|
||||
public List<PotionEffect> getPotionEffects(ItemStack stack) {
|
||||
List<PotionEffect> ret = new ArrayList<>();
|
||||
for(PotionEffectShim s : getPotionEffectsShim(stack))
|
||||
ret.add(s.toVanilla());
|
||||
return ret;
|
||||
return effects;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package vazkii.botania.api.brew;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
|
||||
// Version of PotionEffect that doesn't use number ID's
|
||||
// See https://github.com/MinecraftForge/MinecraftForge/issues/2374
|
||||
// todo 1.9 remove?
|
||||
public class PotionEffectShim {
|
||||
|
||||
public final Potion potion;
|
||||
public final int duration;
|
||||
public final int amplifier;
|
||||
|
||||
public PotionEffectShim(Potion potion, int duration, int amplifier) {
|
||||
this.potion = potion;
|
||||
this.duration = duration;
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public PotionEffect toVanilla() {
|
||||
return new PotionEffect(GameData.getPotionRegistry().getId(potion), duration, amplifier, true, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,13 +10,13 @@
|
||||
*/
|
||||
package vazkii.botania.common.brew;
|
||||
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.PotionEffectShim;
|
||||
|
||||
public class BrewMod extends Brew {
|
||||
|
||||
public BrewMod(String key, int color, int cost, PotionEffectShim... effects) {
|
||||
public BrewMod(String key, int color, int cost, PotionEffect... effects) {
|
||||
super(key, key, color, cost, effects);
|
||||
BotaniaAPI.registerBrew(this);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,11 @@
|
||||
package vazkii.botania.common.brew;
|
||||
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.brew.PotionEffectShim;
|
||||
|
||||
public class BrewModPotion extends BrewMod {
|
||||
|
||||
public BrewModPotion(String key, int cost, PotionEffectShim... effects) {
|
||||
super(key, effects[0].potion.getLiquidColor(), cost, effects);
|
||||
public BrewModPotion(String key, int cost, PotionEffect... effects) {
|
||||
super(key, effects[0].getPotion().getLiquidColor(), cost, effects);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,10 +10,12 @@
|
||||
*/
|
||||
package vazkii.botania.common.brew;
|
||||
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.PotionEffectShim;
|
||||
import vazkii.botania.common.lib.LibBrewNames;
|
||||
|
||||
public class ModBrews {
|
||||
@@ -43,34 +45,34 @@ public class ModBrews {
|
||||
public static Brew warpWard;
|
||||
|
||||
public static void init() {
|
||||
speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffectShim(Potion.moveSpeed, 1800, 1));
|
||||
strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffectShim(Potion.damageBoost, 1800, 1));
|
||||
haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffectShim(Potion.digSpeed, 1800, 1));
|
||||
healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffectShim(Potion.heal, 1, 1));
|
||||
jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffectShim(Potion.jump, 1800, 1));
|
||||
regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffectShim(Potion.regeneration, 500, 1));
|
||||
regenWeak = new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffectShim(Potion.regeneration, 2400, 0));
|
||||
resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffectShim(Potion.resistance, 1800, 1));
|
||||
fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffectShim(Potion.fireResistance, 9600, 0));
|
||||
waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffectShim(Potion.waterBreathing, 9600, 0));
|
||||
invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffectShim(Potion.invisibility, 9600, 0));
|
||||
nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffectShim(Potion.nightVision, 9600, 0));
|
||||
absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffectShim(Potion.absorption, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable();
|
||||
speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new PotionEffect(MobEffects.moveSpeed, 1800, 1));
|
||||
strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new PotionEffect(MobEffects.damageBoost, 1800, 1));
|
||||
haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new PotionEffect(MobEffects.digSpeed, 1800, 1));
|
||||
healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new PotionEffect(MobEffects.heal, 1, 1));
|
||||
jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new PotionEffect(MobEffects.jump, 1800, 1));
|
||||
regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new PotionEffect(MobEffects.regeneration, 500, 1));
|
||||
regenWeak = new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new PotionEffect(MobEffects.regeneration, 2400, 0));
|
||||
resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(MobEffects.resistance, 1800, 1));
|
||||
fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(MobEffects.fireResistance, 9600, 0));
|
||||
waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(MobEffects.waterBreathing, 9600, 0));
|
||||
invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(MobEffects.invisibility, 9600, 0));
|
||||
nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(MobEffects.nightVision, 9600, 0));
|
||||
absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(MobEffects.absorption, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable();
|
||||
|
||||
overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffectShim(Potion.damageBoost, 1800, 3), new PotionEffectShim(Potion.moveSpeed, 1800, 2), new PotionEffectShim(Potion.weakness, 3600, 2), new PotionEffectShim(Potion.hunger, 200, 2));
|
||||
soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffectShim(ModPotions.soulCross, 1800, 0));
|
||||
featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffectShim(ModPotions.featherfeet, 1800, 0));
|
||||
emptiness = new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffectShim(ModPotions.emptiness, 7200, 0));
|
||||
bloodthirst = new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffectShim(ModPotions.bloodthrst, 7200, 0));
|
||||
allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffectShim(ModPotions.allure, 4800, 0));
|
||||
clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffectShim(ModPotions.clear, 0, 0));
|
||||
overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new PotionEffect(MobEffects.damageBoost, 1800, 3), new PotionEffect(MobEffects.moveSpeed, 1800, 2), new PotionEffect(MobEffects.weakness, 3600, 2), new PotionEffect(MobEffects.hunger, 200, 2));
|
||||
soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross, 1800, 0));
|
||||
featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet, 1800, 0));
|
||||
emptiness = new BrewModPotion(LibBrewNames.EMPTINESS, 30000, new PotionEffect(ModPotions.emptiness, 7200, 0));
|
||||
bloodthirst = new BrewModPotion(LibBrewNames.BLOODTHIRST, 20000, new PotionEffect(ModPotions.bloodthrst, 7200, 0));
|
||||
allure = new BrewModPotion(LibBrewNames.ALLURE, 2000, new PotionEffect(ModPotions.allure, 4800, 0));
|
||||
clear = new BrewModPotion(LibBrewNames.CLEAR, 4000, new PotionEffect(ModPotions.clear, 0, 0));
|
||||
}
|
||||
|
||||
public static void initTC() {
|
||||
Potion warpWardPotion = Potion.getPotionFromResourceLocation("minecraft:warp_ward");
|
||||
Potion warpWardPotion = GameData.getPotionRegistry().getObject(new ResourceLocation("minecraft:warp_ward"));
|
||||
// thaumcraft 5 is registering its potions under the Minecraft namespace
|
||||
|
||||
if(warpWardPotion != null)
|
||||
warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffectShim(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable();
|
||||
warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.GameData;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -23,7 +25,8 @@ public class PotionMod extends Potion {
|
||||
private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS);
|
||||
|
||||
public PotionMod(String name, boolean badEffect, int color, int iconIndex) {
|
||||
super(new ResourceLocation("botania", name), badEffect, color);
|
||||
super(badEffect, color);
|
||||
// todo 1.9 register
|
||||
setPotionName("botania.potion." + name);
|
||||
setIconIndex(iconIndex % 8, iconIndex / 8);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
|
||||
|
||||
@Override
|
||||
public ItemStack getItemForBrew(Brew brew, ItemStack stack) {
|
||||
if(!brew.canInfuseIncense() || brew.getPotionEffectsShim(stack).size() != 1 || brew.getPotionEffectsShim(stack).get(0).potion.isInstant())
|
||||
if(!brew.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || brew.getPotionEffects(stack).get(0).getPotion().isInstant())
|
||||
return null;
|
||||
|
||||
ItemStack brewStack = new ItemStack(this);
|
||||
|
||||
Reference in new issue
Block a user