mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Added the Tainted Blood Pendant.
This commit is contained in:
1 parent
403b90b849
commit
7281be661f
10 files changed
+212
-14
No files matched your search
@@ -28,6 +28,7 @@ public class Brew {
|
||||
int color;
|
||||
int cost;
|
||||
List<PotionEffect> effects;
|
||||
boolean canInfuseBloodPendant = true;
|
||||
|
||||
/**
|
||||
* @param name The unlocalized name of this potion.
|
||||
@@ -44,6 +45,18 @@ public class Brew {
|
||||
this.effects = new ArrayList(Arrays.asList(effects));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this brew to not be able to be infused onto the Tainted Blood Pendant.
|
||||
*/
|
||||
public Brew setNotBloodPendantInfusable() {
|
||||
canInfuseBloodPendant = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean canInfuseBloodPendant() {
|
||||
return canInfuseBloodPendant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for this brew, for it to be found in the map in the API.
|
||||
* This should ALWAYS return the same result.
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
|
||||
public int signal = 0;
|
||||
|
||||
public boolean addItem(EntityPlayer player, ItemStack stack) {
|
||||
if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem || ((getStackInSlot(0) == null) != stack.getItem() instanceof IBrewContainer))
|
||||
if(recipe != null || stack == null || (stack.getItem() instanceof IBrewItem && (((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew)) || ((getStackInSlot(0) == null) != stack.getItem() instanceof IBrewContainer))
|
||||
return false;
|
||||
|
||||
boolean did = false;
|
||||
@@ -63,7 +63,7 @@ public class TileBrewery extends TileSimpleInventory implements ISidedInventory,
|
||||
if(did) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
for(RecipeBrew recipe : BotaniaAPI.brewRecipes)
|
||||
if(recipe.matches(this)) {
|
||||
if(recipe.matches(this) && recipe.getOutput(getStackInSlot(0)) != null) {
|
||||
this.recipe = recipe;
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 | 2);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ public class ModBrews {
|
||||
resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new PotionEffect(Potion.resistance.id, 1800, 1));
|
||||
fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new PotionEffect(Potion.fireResistance.id, 9600, 0));
|
||||
waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new PotionEffect(Potion.waterBreathing.id, 9600, 0));
|
||||
invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 4000, new PotionEffect(Potion.invisibility.id, 9600, 0));
|
||||
invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new PotionEffect(Potion.invisibility.id, 9600, 0));
|
||||
nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new PotionEffect(Potion.nightVision.id, 9600, 0));
|
||||
absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3));
|
||||
absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new PotionEffect(Potion.field_76444_x.id, 1800, 3)).setNotBloodPendantInfusable();
|
||||
|
||||
/*soulCross = new BrewModPotion(LibBrewNames.SOUL_CROSS, 10000, new PotionEffect(ModPotions.soulCross.id, 1800, 0));
|
||||
featherfeet = new BrewModPotion(LibBrewNames.FEATHER_FEET, 7000, new PotionEffect(ModPotions.featherfeet.id, 1800, 0));
|
||||
@@ -78,6 +78,6 @@ public class ModBrews {
|
||||
}
|
||||
|
||||
if(warpWardPotion != null)
|
||||
warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0));
|
||||
warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion.id, 12000, 0)).setNotBloodPendantInfusable();
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.vial);
|
||||
addItem(ModItems.brewVial);
|
||||
addItem(ModItems.brewFlask);
|
||||
addItem(ModItems.bloodPendant);
|
||||
addBlock(ModBlocks.pylon);
|
||||
addBlock(ModBlocks.pistonRelay);
|
||||
addBlock(ModBlocks.shinyFlower);
|
||||
|
||||
@@ -30,6 +30,7 @@ import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelChest
|
||||
import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelHelm;
|
||||
import vazkii.botania.common.item.equipment.armor.terrasteel.ItemTerrasteelLegs;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemAuraRing;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemBloodPendant;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemDivaCharm;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemGoldenLaurel;
|
||||
@@ -162,6 +163,7 @@ public final class ModItems {
|
||||
public static Item vial;
|
||||
public static Item brewVial;
|
||||
public static Item brewFlask;
|
||||
public static Item bloodPendant;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -255,6 +257,7 @@ public final class ModItems {
|
||||
vial = new ItemVial();
|
||||
brewVial = new ItemBrewVial();
|
||||
brewFlask = new ItemBrewFlask();
|
||||
bloodPendant = new ItemBloodPendant();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
|
||||
@@ -142,7 +142,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem {
|
||||
int g = Math.max(0, Math.min(255, color.getGreen() + add));
|
||||
int b = Math.max(0, Math.min(255, color.getBlue() + add));
|
||||
|
||||
return pass == 0 ? 0xFFFFFF : r << 16 | g << 8 | b;
|
||||
return r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,6 +160,7 @@ public abstract class ItemBrewBase extends ItemMod implements IBrewItem {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Brew getBrew(ItemStack stack) {
|
||||
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
|
||||
return BotaniaAPI.getBrewFromKey(key);
|
||||
|
||||
@@ -66,18 +66,22 @@ public abstract class ItemBauble extends ItemMod implements IBauble {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
if(GuiScreen.isShiftKeyDown())
|
||||
addHiddenTooltip(par1ItemStack, par2EntityPlayer, par3List, par4);
|
||||
else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List);
|
||||
}
|
||||
|
||||
public void addHiddenTooltip(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
BaubleType type = getBaubleType(par1ItemStack);
|
||||
if(GuiScreen.isShiftKeyDown()) {
|
||||
addStringToTooltip(StatCollector.translateToLocal("botania.baubletype." + type.name().toLowerCase()), par3List);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botania.baubletype." + type.name().toLowerCase()), par3List);
|
||||
|
||||
String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory");
|
||||
String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory");
|
||||
|
||||
if(key != null)
|
||||
addStringToTooltip(StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List);
|
||||
} else addStringToTooltip(StatCollector.translateToLocal("botaniamisc.shiftinfo"), par3List);
|
||||
if(key != null)
|
||||
addStringToTooltip(StatCollector.translateToLocal("botania.baubletooltip").replaceAll("%key%", key), par3List);
|
||||
}
|
||||
|
||||
private void addStringToTooltip(String s, List<String> tooltip) {
|
||||
protected void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Nov 6, 2014, 5:11:23 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import baubles.api.BaubleType;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.brew.ItemBrewBase;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem {
|
||||
|
||||
private static final String TAG_BREW_KEY = "brewKey";
|
||||
|
||||
IIcon[] icons;
|
||||
|
||||
public ItemBloodPendant() {
|
||||
super(LibItemNames.BLOOD_PENDANT);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
super.getSubItems(item, tab, list);
|
||||
for(String s : BotaniaAPI.brewMap.keySet()) {
|
||||
ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this));
|
||||
if(brewStack != null)
|
||||
list.add(brewStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
icons = new IIcon[2];
|
||||
for(int i = 0; i < 2; i++)
|
||||
icons[i] = IconHelper.forItem(par1IconRegister, this, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass) {
|
||||
return icons[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack stack, int pass) {
|
||||
if(pass == 0)
|
||||
return 0xFFFFFF;
|
||||
|
||||
Brew brew = getBrew(stack);
|
||||
if(brew == BotaniaAPI.fallbackBrew)
|
||||
return 0xC6000E;
|
||||
|
||||
Color color = new Color(brew.getColor(stack));
|
||||
int add = (int) (Math.sin((double) ClientTickHandler.ticksInGame * 0.2) * 24);
|
||||
|
||||
int r = Math.max(0, Math.min(255, color.getRed() + add));
|
||||
int g = Math.max(0, Math.min(255, color.getGreen() + add));
|
||||
int b = Math.max(0, Math.min(255, color.getBlue() + add));
|
||||
|
||||
return r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHiddenTooltip(ItemStack stack, EntityPlayer player, List list, boolean adv) {
|
||||
super.addHiddenTooltip(stack, player, list, adv);
|
||||
|
||||
Brew brew = getBrew(stack);
|
||||
if(brew == BotaniaAPI.fallbackBrew) {
|
||||
addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal("botaniamisc.notInfused"), list);
|
||||
return;
|
||||
}
|
||||
|
||||
addStringToTooltip(EnumChatFormatting.LIGHT_PURPLE + String.format(StatCollector.translateToLocal("botaniamisc.brewOf"), StatCollector.translateToLocal(brew.getUnlocalizedName(stack))), list);
|
||||
for(PotionEffect effect : brew.getPotionEffects(stack)) {
|
||||
Potion potion = Potion.potionTypes[effect.getPotionID()];
|
||||
EnumChatFormatting format = potion.isBadEffect() ? EnumChatFormatting.RED : EnumChatFormatting.GRAY;
|
||||
addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : (" " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1)))), list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack arg0) {
|
||||
return BaubleType.AMULET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
Brew brew = getBrew(stack);
|
||||
if(brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.worldObj.isRemote) {
|
||||
EntityPlayer eplayer = (EntityPlayer) player;
|
||||
PotionEffect effect = brew.getPotionEffects(stack).get(0);
|
||||
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
|
||||
boolean doRand = cost < 1;
|
||||
if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
|
||||
PotionEffect currentEffect = player.getActivePotionEffect(Potion.potionTypes[effect.getPotionID()]);
|
||||
if(currentEffect == null || currentEffect.getDuration() < 3) {
|
||||
PotionEffect applyEffect = new PotionEffect(effect.getPotionID(), 80, effect.getAmplifier());
|
||||
player.addPotionEffect(applyEffect);
|
||||
}
|
||||
|
||||
if(!doRand || Math.random() < cost)
|
||||
ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Brew getBrew(ItemStack stack) {
|
||||
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
|
||||
return BotaniaAPI.getBrewFromKey(key);
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, Brew brew) {
|
||||
setBrew(stack, brew.getKey());
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, String brew) {
|
||||
ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemForBrew(Brew brew, ItemStack stack) {
|
||||
if(!brew.canInfuseBloodPendant() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant())
|
||||
return null;
|
||||
|
||||
ItemStack brewStack = new ItemStack(this);
|
||||
ItemBrewBase.setBrew(brewStack, brew);
|
||||
return brewStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getManaCost(Brew brew, ItemStack stack) {
|
||||
return brew.getManaCost() * 10;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,7 +105,8 @@ public final class LibItemNames {
|
||||
public static final String FLASK = "flask";
|
||||
public static final String BREW_VIAL = "brewVial";
|
||||
public static final String BREW_FLASK = "brewFlask";
|
||||
|
||||
public static final String BLOOD_PENDANT = "bloodPendant";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
"lensSpeed",
|
||||
|
||||
Reference in new issue
Block a user