Added Blood Letter's backpack, attempting to add NBT-sensitive blood altar recipes.

This commit is contained in:
WayofTime 2014-11-14 17:11:50 -05:00
parent 66501744f6
commit 9935197282
4 changed files with 227 additions and 2 deletions

View file

@ -79,6 +79,7 @@ import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfTheFastMiner;
import WayofTime.alchemicalWizardry.common.items.sigil.SigilOfWind;
import WayofTime.alchemicalWizardry.common.items.sigil.VoidSigil;
import WayofTime.alchemicalWizardry.common.items.sigil.WaterSigil;
import WayofTime.alchemicalWizardry.common.items.thaumcraft.ItemBloodLetterPack;
import cpw.mods.fml.common.registry.GameRegistry;
/**
@ -194,6 +195,8 @@ public class ModItems
public static Item itemBloodMagicBook;
public static Item bucketLife;
public static Item itemBloodPack;
public static void init()
{
@ -291,6 +294,8 @@ public class ModItems
itemTankSegmenter = new ItemTankSegmenter().setUnlocalizedName("itemTankSegmenter");
itemDestinationClearer = new ItemDestinationClearer().setUnlocalizedName("destinationClearer");
itemBloodMagicBook = new ItemBMBook().setUnlocalizedName("bmBook");
itemBloodPack = new ItemBloodLetterPack().setUnlocalizedName("itemBloodPack");
}
public static void registerItems()
@ -393,6 +398,8 @@ public class ModItems
GameRegistry.registerItem(ModItems.baseItems, "bloodMagicBaseItems");
GameRegistry.registerItem(ModItems.baseAlchemyItems, "bloodMagicBaseAlchemyItems");
GameRegistry.registerItem(ModItems.itemBloodPack, "itemBloodPack");
//GameRegistry.registerItem(ModItems.itemBloodFrame, "itemBloodFrame");
}
}

View file

@ -1,6 +1,10 @@
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
public class AltarRecipe
{
@ -11,16 +15,23 @@ public class AltarRecipe
public int drainRate;
public ItemStack requiredItem;
public ItemStack result;
public boolean useTag;
public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
{
this.result = result;
this(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled, false);
}
public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled, boolean useTag)
{
this.result = result;
this.requiredItem = requiredItem;
this.minTier = minTier;
this.liquidRequired = liquidRequired;
this.consumptionRate = consumptionRate;
this.drainRate = drainRate;
this.canBeFilled = canBeFilled;
this.useTag = useTag;
}
public ItemStack getResult()
@ -40,7 +51,40 @@ public class AltarRecipe
return false;
}
return tierCheck >= minTier && this.requiredItem.isItemEqual(comparedStack);
return tierCheck >= minTier && this.requiredItem.isItemEqual(comparedStack) && this.useTag ? this.areRequiredTagsEqual(comparedStack) : true;
}
public boolean areRequiredTagsEqual(ItemStack comparedStack)
{
if(requiredItem.hasTagCompound())
{
NBTTagCompound tag = requiredItem.getTagCompound();
if(!comparedStack.hasTagCompound())
{
return false;
}
NBTTagCompound comparedTag = comparedStack.getTagCompound();
Set set = tag.func_150296_c();
for(Object obj : set)
{
if(obj instanceof String)
{
String str = (String)obj;
NBTBase baseTag = comparedTag.getTag(str);
if(baseTag != null && !baseTag.equals(comparedTag.getTag(str)))
{
return false;
}
}
}
}
return true;
}
public int getMinTier()

View file

@ -0,0 +1,162 @@
package WayofTime.alchemicalWizardry.common.items.thaumcraft;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBloodLetterPack extends ItemArmor implements ArmourUpgrade
{
private static IIcon helmetIcon;
private static IIcon plateIcon;
private static IIcon leggingsIcon;
private static IIcon bootsIcon;
public static int conversionRate = 100; //LP / half heart
public static float activationPoint = 0.5f;
public static int tickRate = 20;
public ItemBloodLetterPack()
{
super(ArmorMaterial.CHAIN, 0, 1);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
this.helmetIcon = iconRegister.registerIcon("AlchemicalWizardry:SanguineHelmet");
this.plateIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundPlate");
this.leggingsIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundLeggings");
this.bootsIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundBoots");
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("Crystal of unimaginable power");
if (!(par1ItemStack.stackTagCompound == null))
{
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
par3List.add("Stored LP: " + this.getStoredLP(par1ItemStack));
}
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
return this.itemIcon;
}
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
return "alchemicalwizardry:models/armor/sanguineArmour_layer_1.png";
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (world.isRemote)
{
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null)
{
return super.onItemRightClick(itemStack, world, player);
} else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TEAltar))
{
return super.onItemRightClick(itemStack, world, player);
}
TEAltar altar = (TEAltar)tile;
if(!altar.isActive())
{
int amount = this.getStoredLP(itemStack);
if(amount > 0)
{
int filledAmount = altar.fillMainTank(amount);
amount -= filledAmount;
this.setStoredLP(itemStack, amount);
}
}
}
}
return itemStack;
}
public void setStoredLP(ItemStack itemStack, int lp)
{
if(!itemStack.hasTagCompound())
{
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = itemStack.getTagCompound();
tag.setInteger("storedLP", lp);
}
public int getStoredLP(ItemStack itemStack)
{
if(!itemStack.hasTagCompound())
{
itemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = itemStack.getTagCompound();
return tag.getInteger("storedLP");
}
@Override
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
{
//This is where I need to do the updating
return;
}
@Override
public boolean isUpgrade()
{
return true;
}
@Override
public int getEnergyForTenSeconds()
{
return 0;
}
}

View file

@ -84,6 +84,18 @@ public class TEAltar extends TileEntity implements IInventory, IFluidTank, IFlui
progress = 0;
this.lockdownDuration = 0;
}
/**
*
* @return Amount filled
*/
public int fillMainTank(int amount) //TODO
{
int filledAmount = Math.min(capacity - fluid.amount, amount);
fluid.amount += filledAmount;
return filledAmount;
}
public int getRSPowerOutput()
{