mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-25 14:34:36 +00:00
Added Mana and Aura rings.
This commit is contained in:
1 parent
830d67e8af
commit
8471283d46
8 files changed
+140
-8
No files matched your search
@@ -44,7 +44,6 @@ public interface IManaItem {
|
||||
|
||||
/**
|
||||
* Can this item recieve mana from another item?
|
||||
* The getItem() of both stacks can be casted to IManaItem.
|
||||
*/
|
||||
public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack);
|
||||
|
||||
@@ -57,7 +56,6 @@ public interface IManaItem {
|
||||
|
||||
/**
|
||||
* Can this item export mana to another item?
|
||||
* The getItem() of both stacks can be casted to IManaItem.
|
||||
*/
|
||||
public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack);
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
public final class ManaItemHandler {
|
||||
|
||||
/**
|
||||
* Requests mana from items in a given player's inventory. Note that stack.getItem()
|
||||
* must be instanceof IManaItem.
|
||||
* Requests mana from items in a given player's inventory.
|
||||
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
|
||||
* the amount of mana existent will be returned instead, if you want exact values use requestManaExact.
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
@@ -70,7 +69,6 @@ public final class ManaItemHandler {
|
||||
|
||||
/**
|
||||
* Requests an exact amount of mana from items in a given player's inventory.
|
||||
* Note that stack.getItem() must be instanceof IManaItem.
|
||||
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
|
||||
* false will be returned instead, and nothing will happen.
|
||||
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
|
||||
@@ -82,7 +80,6 @@ public final class ManaItemHandler {
|
||||
|
||||
IInventory mainInv = player.inventory;
|
||||
IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player);
|
||||
System.out.println(baublesInv);
|
||||
|
||||
List<ItemStack> stacks = new ArrayList();
|
||||
int invSize = mainInv.getSizeInventory();
|
||||
@@ -113,5 +110,99 @@ public final class ManaItemHandler {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches mana to items in a given player's inventory. Note that this method
|
||||
* does not automatically remove mana from the item which is exporting.
|
||||
* @param manaToSend How much mana is to be sent.
|
||||
* @param remove If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return The amount of mana actually sent.
|
||||
*/
|
||||
public static int dispatchMana(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) {
|
||||
if(stack == null)
|
||||
return 0;
|
||||
|
||||
IInventory mainInv = player.inventory;
|
||||
IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player);
|
||||
|
||||
List<ItemStack> stacks = new ArrayList();
|
||||
int invSize = mainInv.getSizeInventory();
|
||||
int size = invSize;
|
||||
if(baublesInv != null)
|
||||
size += baublesInv.getSizeInventory();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
boolean useBaubles = i >= invSize;
|
||||
IInventory inv = useBaubles ? baublesInv : mainInv;
|
||||
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
|
||||
if(stackInSlot == stack)
|
||||
continue;
|
||||
|
||||
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
|
||||
if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot))
|
||||
continue;
|
||||
|
||||
int received = 0;
|
||||
if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot))
|
||||
received = manaToSend;
|
||||
else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot));
|
||||
|
||||
|
||||
if(add)
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
|
||||
return received;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an exact amount of mana to items in a given player's inventory. Note that this method
|
||||
* does not automatically remove mana from the item which is exporting.
|
||||
* @param manaToSend How much mana is to be sent.
|
||||
* @param remove If true, the mana will be added from the target item. Set to false to just check.
|
||||
* @return If an item received the mana sent.
|
||||
*/
|
||||
public static boolean dispatchManaExact(ItemStack stack, EntityPlayer player, int manaToSend, boolean add) {
|
||||
if(stack == null)
|
||||
return false;
|
||||
|
||||
IInventory mainInv = player.inventory;
|
||||
IInventory baublesInv = BotaniaAPI.internalHandler.getBaublesInventory(player);
|
||||
|
||||
List<ItemStack> stacks = new ArrayList();
|
||||
int invSize = mainInv.getSizeInventory();
|
||||
int size = invSize;
|
||||
if(baublesInv != null)
|
||||
size += baublesInv.getSizeInventory();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
boolean useBaubles = i >= invSize;
|
||||
IInventory inv = useBaubles ? baublesInv : mainInv;
|
||||
ItemStack stackInSlot = inv.getStackInSlot(i - (useBaubles ? invSize : 0));
|
||||
if(stackInSlot == stack)
|
||||
continue;
|
||||
|
||||
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
|
||||
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
|
||||
if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
|
||||
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot))
|
||||
continue;
|
||||
|
||||
if(add)
|
||||
manaItemSlot.addMana(stackInSlot, manaToSend);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
|
||||
addItem(ModItems.tinyPlanet);
|
||||
addItem(ModItems.manaRing);
|
||||
addItem(ModItems.auraRing);
|
||||
|
||||
addItem(ModItems.manaTablet);
|
||||
addItem(ModItems.manaMirror);
|
||||
|
||||
@@ -23,6 +23,7 @@ import vazkii.botania.common.item.equipment.armor.ItemTerrasteelBoots;
|
||||
import vazkii.botania.common.item.equipment.armor.ItemTerrasteelChest;
|
||||
import vazkii.botania.common.item.equipment.armor.ItemTerrasteelHelm;
|
||||
import vazkii.botania.common.item.equipment.armor.ItemTerrasteelLegs;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemAuraRing;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemManaRing;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet;
|
||||
import vazkii.botania.common.item.equipment.tool.ItemManasteelAxe;
|
||||
@@ -70,6 +71,7 @@ public final class ModItems {
|
||||
public static Item terraSword;
|
||||
public static Item tinyPlanet;
|
||||
public static Item manaRing;
|
||||
public static Item auraRing;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -107,6 +109,7 @@ public final class ModItems {
|
||||
terraSword = new ItemTerraSword();
|
||||
tinyPlanet = new ItemTinyPlanet();
|
||||
manaRing = new ItemManaRing();
|
||||
auraRing = new ItemAuraRing();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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 @ [Apr 24, 2014, 4:43:47 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.bauble;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import baubles.api.BaubleType;
|
||||
|
||||
public class ItemAuraRing extends ItemBauble {
|
||||
|
||||
public ItemAuraRing() {
|
||||
super(LibItemNames.AURA_RING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, EntityLivingBase player) {
|
||||
if(player instanceof EntityPlayer && player.worldObj.getTotalWorldTime() % 2 == 0)
|
||||
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemstack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import baubles.api.BaubleType;
|
||||
|
||||
public class ItemManaRing extends ItemBauble implements IManaItem {
|
||||
|
||||
private static final int MAX_MANA = 50000;
|
||||
private static final int MAX_MANA = 500000;
|
||||
|
||||
private static final String TAG_MANA = "mana";
|
||||
|
||||
|
||||
@@ -289,7 +289,8 @@ item.botania:terrasteelLegs.name=Terrasteel Leggings
|
||||
item.botania:terrasteelBoots.name=Terrasteel Boots
|
||||
item.botania:terraSword.name=Terra Blade
|
||||
item.botania:tinyPlanet.name=Tiny Planet
|
||||
item.botnaia:manaRing.name=Band of Mana
|
||||
item.botania:manaRing.name=Band of Mana
|
||||
item.botania:auraRing.name=Band of Aura
|
||||
|
||||
# GUI TEXT
|
||||
botania.gui.lexicon.header=Lexica Botania Index - Pick which category you would like to study:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
Reference in new issue
Block a user