mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Added Incense Sticks. Now to make them do stuffs...
This commit is contained in:
1 parent
cb160985b9
commit
2c41e88628
13 files changed
+170
-4
No files matched your search
@@ -28,6 +28,7 @@ public class Brew {
|
||||
int cost;
|
||||
List<PotionEffect> effects;
|
||||
boolean canInfuseBloodPendant = true;
|
||||
boolean canInfuseIncense = true;
|
||||
|
||||
/**
|
||||
* @param name The unlocalized name of this potion.
|
||||
@@ -51,10 +52,22 @@ public class Brew {
|
||||
canInfuseBloodPendant = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this brew to not be able to be infused onto Incense Sticks.
|
||||
*/
|
||||
public Brew setNotIncenseInfusable() {
|
||||
canInfuseIncense = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean canInfuseBloodPendant() {
|
||||
return canInfuseBloodPendant;
|
||||
}
|
||||
|
||||
public boolean canInfuseIncense() {
|
||||
return canInfuseIncense;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key for this brew, for it to be found in the map in the API.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "48", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "49", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -120,6 +120,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
addItem(ModItems.vial);
|
||||
addItem(ModItems.brewVial);
|
||||
addItem(ModItems.brewFlask);
|
||||
addItem(ModItems.incenseStick);
|
||||
addItem(ModItems.bloodPendant);
|
||||
addBlock(ModBlocks.pylon);
|
||||
addBlock(ModBlocks.pistonRelay);
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.item.brew.ItemBrewFlask;
|
||||
import vazkii.botania.common.item.brew.ItemBrewVial;
|
||||
import vazkii.botania.common.item.brew.ItemIncenseStick;
|
||||
import vazkii.botania.common.item.brew.ItemVial;
|
||||
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumBoots;
|
||||
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumChest;
|
||||
@@ -239,7 +240,8 @@ public final class ModItems {
|
||||
public static Item recordGaia1;
|
||||
public static Item recordGaia2;
|
||||
public static Item temperanceStone;
|
||||
|
||||
public static Item incenseStick;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
petal = new ItemPetal();
|
||||
@@ -370,7 +372,8 @@ public final class ModItems {
|
||||
recordGaia1 = new ItemRecordGaia1();
|
||||
recordGaia2 = new ItemRecordGaia2();
|
||||
temperanceStone = new ItemTemperanceStone();
|
||||
|
||||
incenseStick = new ItemIncenseStick();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
OreDictionary.registerOre(LibOreDict.PETAL[i], new ItemStack(petal, 1, i));
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* 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 the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 15, 2015, 3:13:43 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item.brew;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
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 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.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContainer {
|
||||
|
||||
private static final String TAG_BREW_KEY = "brewKey";
|
||||
public static final int TIME_MULTIPLIER = 60;
|
||||
|
||||
IIcon[] icons;
|
||||
|
||||
public ItemIncenseStick() {
|
||||
setUnlocalizedName(LibItemNames.INCENSE_STICK);
|
||||
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[4];
|
||||
for(int i = 0; i < 4; 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 0x989898;
|
||||
|
||||
Color color = new Color(brew.getColor(stack));
|
||||
int add = (int) (Math.sin(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 addInformation(ItemStack stack, EntityPlayer player, List list, boolean 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;
|
||||
PotionEffect longEffect = new PotionEffect(effect.getPotionID(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false);
|
||||
addStringToTooltip(" " + format + StatCollector.translateToLocal(effect.getEffectName()) + (effect.getAmplifier() == 0 ? "" : " " + StatCollector.translateToLocal("botania.roman" + (effect.getAmplifier() + 1))) + EnumChatFormatting.GRAY + (potion.isInstant() ? "" : " (" + Potion.getDurationString(longEffect) + ")"), list);
|
||||
}
|
||||
}
|
||||
|
||||
void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
}
|
||||
|
||||
@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.canInfuseIncense() || brew.getPotionEffects(stack).size() != 1 || Potion.potionTypes[brew.getPotionEffects(stack).get(0).getPotionID()].isInstant())
|
||||
return null;
|
||||
|
||||
ItemStack brewStack = new ItemStack(this);
|
||||
setBrew(brewStack, brew);
|
||||
return brewStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getManaCost(Brew brew, ItemStack stack) {
|
||||
return brew.getManaCost() * 10;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
return null;
|
||||
|
||||
ItemStack brewStack = new ItemStack(this);
|
||||
ItemBrewBase.setBrew(brewStack, brew);
|
||||
setBrew(brewStack, brew);
|
||||
return brewStack;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
import vazkii.botania.api.recipe.IElvenItem;
|
||||
import vazkii.botania.api.recipe.IFlowerComponent;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
@@ -173,4 +175,5 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
|
||||
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) {
|
||||
return stack.getItemDamage() == 4 ? ModAchievements.terrasteelPickup : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -142,6 +142,7 @@ public final class LibItemNames {
|
||||
public static final String RECORD_GAIA1 = "recordGaia1";
|
||||
public static final String RECORD_GAIA2 = "recordGaia2";
|
||||
public static final String TEMPERANCE_STONE = "temperanceStone";
|
||||
public static final String INCENSE_STICK = "incenseStick";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
|
||||
Reference in new issue
Block a user