Testing the creation of hell
This commit is contained in:
parent
796e75b1f9
commit
a2b006105e
2587 changed files with 0 additions and 129617 deletions
|
@ -0,0 +1,44 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AWBaseItems extends Item
|
||||
{
|
||||
public AWBaseItems()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(64);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
if (this.equals(ModItems.blankSlate))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankSlate");
|
||||
} else if (this.equals(ModItems.reinforcedSlate))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ReinforcedSlate");
|
||||
} else if (this.equals(ModItems.imbuedSlate))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:InfusedSlate");
|
||||
} else if (this.equals(ModItems.demonicSlate))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DemonSlate");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Infused stone inside of");
|
||||
par3List.add("a blood altar");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ActivationCrystal extends EnergyItems
|
||||
{
|
||||
private static final String[] ACTIVATION_CRYSTAL_NAMES = new String[]{"Weak", "Awakened"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ActivationCrystal()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(100);
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[ACTIVATION_CRYSTAL_NAMES.length];
|
||||
|
||||
for (int i = 0; i < ACTIVATION_CRYSTAL_NAMES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon("AlchemicalWizardry:" + "activationCrystal" + ACTIVATION_CRYSTAL_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
switch (par1ItemStack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
par3List.add("Activates low-level rituals");
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
par3List.add("Activates more powerful rituals");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getCrystalLevel(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItemDamage() + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
//This is what will do all the localisation things on the alchemy components so you dont have to set it :D
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ACTIVATION_CRYSTAL_NAMES.length - 1);
|
||||
return ("" + "item.activationCrystal" + ACTIVATION_CRYSTAL_NAMES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
int j = MathHelper.clamp_int(meta, 0, ACTIVATION_CRYSTAL_NAMES.length - 1);
|
||||
return icons[j];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < ACTIVATION_CRYSTAL_NAMES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class AirScribeTool extends ScribeTool
|
||||
{
|
||||
public AirScribeTool()
|
||||
{
|
||||
super(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AirScribeTool");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class ApprenticeBloodOrb extends EnergyBattery
|
||||
{
|
||||
public ApprenticeBloodOrb(int damage)
|
||||
{
|
||||
super(damage);
|
||||
orbLevel = 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ApprenticeBloodOrb");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class ArchmageBloodOrb extends EnergyBattery
|
||||
{
|
||||
public ArchmageBloodOrb(int damage)
|
||||
{
|
||||
super(damage);
|
||||
orbLevel = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ArchmageBloodOrb");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArmourInhibitor extends EnergyItems
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int tickDelay = 200;
|
||||
|
||||
public ArmourInhibitor()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(0);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to suppress a soul's");
|
||||
par3List.add("unnatural abilities.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:ArmourInhibitor_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
}
|
||||
|
||||
//TODO Do stuff
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionInhibit.id, 2, 0));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEHomHeart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlankSpell extends EnergyItems
|
||||
{
|
||||
public BlankSpell()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BlankSpell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Crystal of infinite possibilities.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
World world = DimensionManager.getWorld(getDimensionID(par1ItemStack));
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
TileEntity tileEntity = world.getTileEntity(itemTag.getInteger("xCoord"), itemTag.getInteger("yCoord"), itemTag.getInteger("zCoord"));
|
||||
|
||||
if (tileEntity instanceof TEHomHeart)
|
||||
{
|
||||
TEHomHeart homHeart = (TEHomHeart) tileEntity;
|
||||
|
||||
if (homHeart.canCastSpell(par1ItemStack, par2World, par3EntityPlayer))
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, homHeart.castSpell(par1ItemStack, par2World, par3EntityPlayer));
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getDimensionID(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getInteger("dimensionId");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BloodShard extends Item implements ArmourUpgrade
|
||||
{
|
||||
public BloodShard()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 64;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
if (this.equals(ModItems.weakBloodShard))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WeakBloodShard");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.demonBloodShard))
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DemonBloodShard");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public int getBloodShardLevel()
|
||||
{
|
||||
if (this.equals(ModItems.weakBloodShard))
|
||||
{
|
||||
return 1;
|
||||
} else if (this.equals(ModItems.demonBloodShard))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BloodboundSword extends EnergyItems
|
||||
{
|
||||
private float weaponDamage;
|
||||
private NBTTagCompound data;
|
||||
|
||||
public BloodboundSword(int id)
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(100);
|
||||
setFull3D();
|
||||
weaponDamage = 10.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergySword");
|
||||
}
|
||||
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (par3EntityLivingBase instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, (EntityPlayer) par3EntityLivingBase);
|
||||
|
||||
if (!this.syphonBatteries(par1ItemStack, (EntityPlayer) par3EntityLivingBase, this.getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public float func_82803_g()
|
||||
{
|
||||
return 4.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: may cause");
|
||||
par3List.add("a bad day...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack par1ItemStack, Block par2Block, int meta)
|
||||
{
|
||||
if (par2Block.equals(Blocks.web))
|
||||
{
|
||||
return 15.0F;
|
||||
} else
|
||||
{
|
||||
Material material = par2Block.getMaterial();
|
||||
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,802 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.IAlchemyGoggles;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.common.renderer.model.ModelOmegaArmour;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import thaumcraft.api.IGoggles;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.nodes.IRevealer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Optional.InterfaceList(value = {@Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft"), @Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft"), @Interface(iface = "thaumcraft.api.IRunicArmor", modid = "Thaumcraft")})
|
||||
public class BoundArmour extends ItemArmor implements IAlchemyGoggles, ISpecialArmor, IBindable, IRevealer, IGoggles, IRunicArmor
|
||||
{
|
||||
private static int invSize = 9;
|
||||
private static IIcon helmetIcon;
|
||||
private static IIcon plateIcon;
|
||||
private static IIcon leggingsIcon;
|
||||
private static IIcon bootsIcon;
|
||||
|
||||
private static final boolean tryComplexRendering = true;
|
||||
|
||||
public BoundArmour(int armorType)
|
||||
{
|
||||
super(ItemArmor.ArmorMaterial.GOLD, 0, armorType);
|
||||
setMaxDamage(1000);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
ModelBiped model1 = null;
|
||||
ModelBiped model2 = null;
|
||||
ModelBiped model = null;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
|
||||
{
|
||||
if (tryComplexRendering)
|
||||
{
|
||||
int type = ((ItemArmor) itemStack.getItem()).armorType;
|
||||
if (this.model1 == null)
|
||||
{
|
||||
this.model1 = new ModelOmegaArmour(1.0f, true, true, false, true);
|
||||
}
|
||||
if (this.model2 == null)
|
||||
{
|
||||
this.model2 = new ModelOmegaArmour(0.5f, false, false, true, false);
|
||||
}
|
||||
|
||||
if (type == 1 || type == 3 || type == 0)
|
||||
{
|
||||
this.model = model1;
|
||||
} else
|
||||
{
|
||||
this.model = model2;
|
||||
}
|
||||
|
||||
if (this.model != null)
|
||||
{
|
||||
this.model.bipedHead.showModel = (type == 0);
|
||||
this.model.bipedHeadwear.showModel = (type == 0);
|
||||
this.model.bipedBody.showModel = ((type == 1) || (type == 2));
|
||||
this.model.bipedLeftArm.showModel = (type == 1);
|
||||
this.model.bipedRightArm.showModel = (type == 1);
|
||||
this.model.bipedLeftLeg.showModel = (type == 2 || type == 3);
|
||||
this.model.bipedRightLeg.showModel = (type == 2 || type == 3);
|
||||
this.model.isSneak = entityLiving.isSneaking();
|
||||
|
||||
this.model.isRiding = entityLiving.isRiding();
|
||||
this.model.isChild = entityLiving.isChild();
|
||||
|
||||
this.model.aimedBow = false;
|
||||
this.model.heldItemRight = (entityLiving.getHeldItem() != null ? 1 : 0);
|
||||
|
||||
if ((entityLiving instanceof EntityPlayer))
|
||||
{
|
||||
if (((EntityPlayer) entityLiving).getItemInUseDuration() > 0)
|
||||
{
|
||||
EnumAction enumaction = ((EntityPlayer) entityLiving).getItemInUse().getItemUseAction();
|
||||
if (enumaction == EnumAction.block)
|
||||
{
|
||||
this.model.heldItemRight = 3;
|
||||
} else if (enumaction == EnumAction.bow)
|
||||
{
|
||||
this.model.aimedBow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
|
||||
} else
|
||||
{
|
||||
return super.getArmorModel(entityLiving, itemStack, armorSlot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
this.helmetIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundHelmet");
|
||||
this.plateIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundPlate");
|
||||
this.leggingsIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundLeggings");
|
||||
this.bootsIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundBoots");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (this.equals(ModItems.boundHelmet))
|
||||
{
|
||||
return this.helmetIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.boundPlate))
|
||||
{
|
||||
return this.plateIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.boundLeggings))
|
||||
{
|
||||
return this.leggingsIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.boundBoots))
|
||||
{
|
||||
return this.bootsIcon;
|
||||
}
|
||||
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
|
||||
{
|
||||
double armourReduction = 0.0;
|
||||
|
||||
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray))
|
||||
{
|
||||
int i = player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulFray).getAmplifier() + 1;
|
||||
|
||||
armourReduction = (i + 1) * 0.1;
|
||||
}
|
||||
|
||||
double damageAmount = 0.25;
|
||||
|
||||
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulHarden))
|
||||
{
|
||||
int i = player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulHarden).getAmplifier() + 1;
|
||||
damageAmount /= Math.max((1 - i * 0.1), 0.1);
|
||||
} else
|
||||
{
|
||||
damageAmount *= 0.9;
|
||||
}
|
||||
|
||||
damageAmount *= (1.0 - armourReduction);
|
||||
|
||||
int maxAbsorption = 100000;
|
||||
|
||||
if (source.equals(DamageSource.drown))
|
||||
{
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (source.equals(DamageSource.outOfWorld))
|
||||
{
|
||||
if (isImmuneToVoid(armor))
|
||||
{
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
} else
|
||||
{
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack helmet = player.getEquipmentInSlot(4);
|
||||
ItemStack plate = player.getEquipmentInSlot(3);
|
||||
ItemStack leggings = player.getEquipmentInSlot(2);
|
||||
ItemStack boots = player.getEquipmentInSlot(1);
|
||||
|
||||
if (helmet == null || plate == null || leggings == null || boots == null)
|
||||
{
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (helmet.getItem().equals(ModItems.boundHelmet) && plate.getItem().equals(ModItems.boundPlate) && leggings.getItem().equals(ModItems.boundLeggings) && boots.getItem().equals(ModItems.boundBoots))
|
||||
{
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
return new ArmorProperties(-1, damageAmount * 0.9d, maxAbsorption);
|
||||
}
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (armor.equals(ModItems.boundHelmet))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (armor.equals(ModItems.boundPlate))
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (armor.equals(ModItems.boundLeggings))
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (armor.equals(ModItems.boundBoots))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(stack, (EntityPlayer) entity);
|
||||
|
||||
if (((EntityPlayer) entity).capabilities.isCreativeMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
stack.setItemDamage(stack.getItemDamage() + damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Devilish Protection");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
ItemStack[] inv = getInternalInventory(par1ItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
if (inv[i] != null)
|
||||
{
|
||||
par3List.add("Item in slot " + i + ": " + inv[i].getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
if (this.tryComplexRendering)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/BloodArmour_WIP.png";
|
||||
}
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (this.getIsInvisible(stack))
|
||||
{
|
||||
if (this == ModItems.boundHelmet || this == ModItems.boundPlate || this == ModItems.boundBoots)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/boundArmour_invisible_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == ModItems.boundLeggings)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/boundArmour_invisible_layer_2.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this == ModItems.boundHelmet || this == ModItems.boundPlate || this == ModItems.boundBoots)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/boundArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == ModItems.boundLeggings)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/boundArmour_layer_2.png";
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
int maxBloodLevel = getMaxBloodShardLevel(itemStack);
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
|
||||
if (inv != null)
|
||||
{
|
||||
int iSize = 0;
|
||||
int iBlood = 0;
|
||||
}
|
||||
|
||||
if (!player.isPotionActive(AlchemicalWizardry.customPotionInhibit))
|
||||
{
|
||||
tickInternalInventory(itemStack, world, player, 0, false);
|
||||
}
|
||||
|
||||
this.setIsInvisible(itemStack, player.isPotionActive(Potion.invisibility.id));
|
||||
|
||||
if (itemStack.getItemDamage() > 0)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(itemStack, player);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(itemStack, player, itemStack.getItemDamage() * 75);
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void tickInternalInventory(ItemStack par1ItemStack, World par2World, EntityPlayer par3Entity, int par4, boolean par5)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(par1ItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int blood = getMaxBloodShardLevel(par1ItemStack);
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
if (inv[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inv[i].getItem() instanceof ArmourUpgrade && blood > 0)
|
||||
{
|
||||
if (((ArmourUpgrade) inv[i].getItem()).isUpgrade())
|
||||
{
|
||||
((ArmourUpgrade) inv[i].getItem()).onArmourUpdate(par2World, par3Entity, inv[i]);
|
||||
blood--;
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == 0)
|
||||
{
|
||||
if (getUpgradeCostMultiplier(par1ItemStack) > 0.02f)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3Entity, (int) (((ArmourUpgrade) inv[i].getItem()).getEnergyForTenSeconds() * getUpgradeCostMultiplier(par1ItemStack)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxBloodShardLevel(ItemStack armourStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(armourStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int max = 0;
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
ItemStack itemStack = inv[i];
|
||||
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.getItem().equals(ModItems.weakBloodShard))
|
||||
{
|
||||
max = Math.max(max, 1);
|
||||
}
|
||||
|
||||
if (itemStack.getItem().equals(ModItems.demonBloodShard))
|
||||
{
|
||||
max = Math.max(max, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
public boolean hasAddedToInventory(ItemStack sigilItemStack, ItemStack addedItemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(sigilItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addedItemStack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = addedItemStack.getItem();
|
||||
int candidateSlot = -1;
|
||||
|
||||
for (int i = invSize - 1; i >= 0; i--)
|
||||
{
|
||||
ItemStack nextItem = inv[i];
|
||||
|
||||
if (nextItem == null)
|
||||
{
|
||||
candidateSlot = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (candidateSlot == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addedItemStack.getItem() instanceof ArmourUpgrade)
|
||||
{
|
||||
inv[candidateSlot] = addedItemStack;
|
||||
saveInternalInventory(sigilItemStack, inv);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack[] getInternalInventory(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
itemTag = itemStack.stackTagCompound;
|
||||
|
||||
ItemStack[] inv = new ItemStack[9];
|
||||
NBTTagList tagList = itemTag.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
if (tagList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tag.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < invSize)
|
||||
{
|
||||
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void saveInternalInventory(ItemStack itemStack, ItemStack[] inventory)
|
||||
{
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
ItemStack stack = inventory[i];
|
||||
|
||||
if (inventory[i] != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(tag);
|
||||
itemList.appendTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
itemTag.setTag("Inventory", itemList);
|
||||
}
|
||||
|
||||
public boolean isImmuneToVoid(ItemStack itemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack item : inv)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.voidSigil))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
public boolean hasIRevealer(ItemStack itemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack item : inv)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof IRevealer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
public boolean hasIGoggles(ItemStack itemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack item : inv)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof IGoggles)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float getUpgradeCostMultiplier(ItemStack itemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
for (ItemStack item : inv)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.weakBloodOrb))
|
||||
{
|
||||
return 0.75f;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.apprenticeBloodOrb))
|
||||
{
|
||||
return 0.50f;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.magicianBloodOrb))
|
||||
{
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.masterBloodOrb))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.archmageBloodOrb))
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
public boolean getIsInvisible(ItemStack armourStack)
|
||||
{
|
||||
NBTTagCompound tag = armourStack.getTagCompound();
|
||||
if (tag != null)
|
||||
{
|
||||
return tag.getBoolean("invisible");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setIsInvisible(ItemStack armourStack, boolean invisible)
|
||||
{
|
||||
NBTTagCompound tag = armourStack.getTagCompound();
|
||||
|
||||
if (tag == null)
|
||||
{
|
||||
armourStack.setTagCompound(new NBTTagCompound());
|
||||
tag = armourStack.getTagCompound();
|
||||
}
|
||||
|
||||
tag.setBoolean("invisible", invisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
public boolean showNodes(ItemStack itemstack, EntityLivingBase player)
|
||||
{
|
||||
return this.hasIRevealer(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player)
|
||||
{
|
||||
return this.hasIGoggles(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Thaumcraft")
|
||||
public int getRunicCharge(ItemStack itemstack)
|
||||
{
|
||||
ItemStack[] inv = this.getInternalInventory(itemstack);
|
||||
int shardLevel = this.getMaxBloodShardLevel(itemstack);
|
||||
int count = 0;
|
||||
int harden = 0;
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (ItemStack stack : inv)
|
||||
{
|
||||
if (count >= shardLevel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (stack == null || !(stack.getItem() instanceof ArmourUpgrade))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).armorType != this.armorType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
int enchLvl = tag.getByte("RS.HARDEN");
|
||||
|
||||
if (stack.getItem() instanceof IRunicArmor)
|
||||
{
|
||||
enchLvl += ((IRunicArmor) stack.getItem()).getRunicCharge(stack);
|
||||
}
|
||||
|
||||
if (enchLvl > 0)
|
||||
{
|
||||
harden += enchLvl;
|
||||
if (((ArmourUpgrade) stack.getItem()).isUpgrade())
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return harden;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(stack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack item : inv)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getItem().equals(ModItems.itemSeerSigil))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,324 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BoundAxe extends ItemAxe implements IBindable
|
||||
{
|
||||
public float efficiencyOnProperMaterial = 12.0F;
|
||||
public float damageVsEntity;
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int energyUsed;
|
||||
|
||||
public BoundAxe()
|
||||
{
|
||||
super(AlchemicalWizardry.bloodBoundToolMaterial);
|
||||
this.maxStackSize = 1;
|
||||
this.efficiencyOnProperMaterial = 12.0F;
|
||||
this.damageVsEntity = 5;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(5);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i)
|
||||
{
|
||||
energyUsed = i;
|
||||
}
|
||||
|
||||
public int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Axe me about my puns!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundAxe_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundAxe_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack) || SpellHelper.isFakePlayer(par2World, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer);
|
||||
int posX = (int) (blockVec.xCoord);
|
||||
int posY = (int) (blockVec.yCoord);
|
||||
int posZ = (int) (blockVec.zCoord);
|
||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
||||
|
||||
for (int i = -5; i <= 5; i++)
|
||||
{
|
||||
for (int j = 0; j <= 10; j++)
|
||||
{
|
||||
for (int k = -5; k <= 5; k++)
|
||||
{
|
||||
Block block = par2World.getBlock(posX + i, posY + j, posZ + k);
|
||||
int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k);
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
float str = func_150893_a(par1ItemStack, block);
|
||||
|
||||
if (str > 1.1f || block instanceof BlockLeavesBase && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k))
|
||||
{
|
||||
if (silkTouch)
|
||||
{
|
||||
ItemStack droppedItem = new ItemStack(block, 1, meta);
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem));
|
||||
}
|
||||
} else
|
||||
{
|
||||
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
||||
|
||||
if (itemDropList != null)
|
||||
{
|
||||
for (ItemStack item : itemDropList)
|
||||
{
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
par2World.setBlockToAir(posX + i, posY + j, posZ + k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 10000);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 20);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
|
||||
* sword
|
||||
*/
|
||||
@Override
|
||||
public float func_150893_a(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
return super.func_150893_a(par1ItemStack, par2Block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
|
||||
* the damage on the stack.
|
||||
*/
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, Block par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase)
|
||||
{
|
||||
if ((double) par3.getBlockHardness(par2World, par4, par5, par6) != 0.0D)
|
||||
{
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns True is the item is renderer in full 3D when hold.
|
||||
*/
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
*/
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* FORGE: Overridden to allow custom tool effectiveness
|
||||
*/
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!getActivated(stack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
if (ForgeHooks.isToolEffective(stack, block, meta))
|
||||
{
|
||||
return efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
return func_150893_a(stack, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return !getActivated(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
if ("axe".equals(toolClass))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,335 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BoundPickaxe extends ItemPickaxe implements IBindable
|
||||
{
|
||||
|
||||
public float efficiencyOnProperMaterial = 12.0F;
|
||||
public float damageVsEntity;
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
private int energyUsed;
|
||||
|
||||
public BoundPickaxe()
|
||||
{
|
||||
super(AlchemicalWizardry.bloodBoundToolMaterial);
|
||||
this.maxStackSize = 1;
|
||||
this.efficiencyOnProperMaterial = 12.0F;
|
||||
this.damageVsEntity = 5;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.setEnergyUsed(5);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i)
|
||||
{
|
||||
energyUsed = i;
|
||||
}
|
||||
|
||||
public int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("The Souls of the Damned");
|
||||
par3List.add("do not like stone...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundPickaxe_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundPickaxe_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack) || SpellHelper.isFakePlayer(par2World, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par2World.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer);
|
||||
int posX = (int) (blockVec.xCoord);
|
||||
int posY = (int) (blockVec.yCoord);
|
||||
int posZ = (int) (blockVec.zCoord);
|
||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
||||
|
||||
for (int i = -5; i <= 5; i++)
|
||||
{
|
||||
for (int j = -5; j <= 5; j++)
|
||||
{
|
||||
for (int k = -5; k <= 5; k++)
|
||||
{
|
||||
Block block = par2World.getBlock(posX + i, posY + j, posZ + k);
|
||||
int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k);
|
||||
|
||||
if (block != null && block.getBlockHardness(par2World, posX + i, posY + j, posZ + k) != -1)
|
||||
{
|
||||
float str = func_150893_a(par1ItemStack, block);
|
||||
|
||||
if (str > 1.1f && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k))
|
||||
{
|
||||
if (silkTouch)
|
||||
{
|
||||
ItemStack droppedItem = new ItemStack(block, 1, meta);
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem));
|
||||
}
|
||||
} else
|
||||
{
|
||||
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
||||
|
||||
if (itemDropList != null)
|
||||
{
|
||||
for (ItemStack item : itemDropList)
|
||||
{
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par2World.setBlockToAir(posX + i, posY + j, posZ + k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 10000);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 20);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
|
||||
* sword
|
||||
*/
|
||||
@Override
|
||||
public float func_150893_a(ItemStack par1ItemStack, Block par2Block) //getStrVsBlock
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
return super.func_150893_a(par1ItemStack, par2Block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
|
||||
* the damage on the stack.
|
||||
*/
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, Block par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase)
|
||||
{
|
||||
|
||||
if (par7EntityLivingBase instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par7EntityLivingBase, getEnergyUsed());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns True is the item is renderer in full 3D when hold.
|
||||
*/
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
*/
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* FORGE: Overridden to allow custom tool effectiveness
|
||||
*/
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!getActivated(stack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
if (ForgeHooks.isToolEffective(stack, block, meta))
|
||||
{
|
||||
return efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
return func_150893_a(stack, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return !getActivated(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
if ("pickaxe".equals(toolClass))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import com.google.common.collect.Multimap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BoundShovel extends ItemSpade implements IBindable
|
||||
{
|
||||
public float efficiencyOnProperMaterial = 12.0F;
|
||||
public float damageVsEntity;
|
||||
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
private int energyUsed;
|
||||
|
||||
public BoundShovel()
|
||||
{
|
||||
super(AlchemicalWizardry.bloodBoundToolMaterial);
|
||||
this.maxStackSize = 1;
|
||||
this.efficiencyOnProperMaterial = 12.0F;
|
||||
this.damageVsEntity = 5;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(5);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i)
|
||||
{
|
||||
energyUsed = i;
|
||||
}
|
||||
|
||||
public int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("No, not that type of spade.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundShovel_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundShovel_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack) || SpellHelper.isFakePlayer(par2World, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionInhibit))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer);
|
||||
int posX = (int) (blockVec.xCoord);
|
||||
int posY = (int) (blockVec.yCoord);
|
||||
int posZ = (int) (blockVec.zCoord);
|
||||
boolean silkTouch = EnchantmentHelper.getSilkTouchModifier(par3EntityPlayer);
|
||||
int fortuneLvl = EnchantmentHelper.getFortuneModifier(par3EntityPlayer);
|
||||
|
||||
for (int i = -5; i <= 5; i++)
|
||||
{
|
||||
for (int j = 0; j <= 10; j++)
|
||||
{
|
||||
for (int k = -5; k <= 5; k++)
|
||||
{
|
||||
Block block = par2World.getBlock(posX + i, posY + j, posZ + k);
|
||||
int meta = par2World.getBlockMetadata(posX + i, posY + j, posZ + k);
|
||||
|
||||
if (block != null)
|
||||
{
|
||||
float str = func_150893_a(par1ItemStack, block);
|
||||
|
||||
if (str > 1.1f && par2World.canMineBlock(par3EntityPlayer, posX + i, posY + j, posZ + k))
|
||||
{
|
||||
if (silkTouch)
|
||||
{
|
||||
ItemStack droppedItem = new ItemStack(block, 1, meta);
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, droppedItem));
|
||||
}
|
||||
} else
|
||||
{
|
||||
ArrayList<ItemStack> itemDropList = block.getDrops(par2World, posX + i, posY + j, posZ + k, meta, fortuneLvl);
|
||||
|
||||
if (itemDropList != null)
|
||||
{
|
||||
for (ItemStack item : itemDropList)
|
||||
{
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityItem(par2World, posX, posY + par3EntityPlayer.getEyeHeight(), posZ, item));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par2World.setBlockToAir(posX + i, posY + j, posZ + k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 10000);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 20);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if
|
||||
* sword
|
||||
*/
|
||||
@Override
|
||||
public float func_150893_a(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
return super.func_150893_a(par1ItemStack, par2Block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
|
||||
* the damage on the stack.
|
||||
*/
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLivingBase par7EntityLivingBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* Returns True is the item is renderer in full 3D when hold.
|
||||
*/
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
*/
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap getItemAttributeModifiers()
|
||||
{
|
||||
Multimap multimap = super.getItemAttributeModifiers();
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", (double) this.damageVsEntity, 0));
|
||||
return multimap;
|
||||
}
|
||||
|
||||
/**
|
||||
* FORGE: Overridden to allow custom tool effectiveness
|
||||
*/
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
if (!getActivated(stack))
|
||||
{
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
if (ForgeHooks.isToolEffective(stack, block, meta))
|
||||
{
|
||||
return efficiencyOnProperMaterial;
|
||||
}
|
||||
|
||||
return func_150893_a(stack, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return !getActivated(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
if ("shovel".equals(toolClass))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CheatyItem extends Item implements IBindable
|
||||
{
|
||||
public CheatyItem()
|
||||
{
|
||||
super();
|
||||
DamageSource damageSource = DamageSource.generic;
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBattery");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Creative only");
|
||||
par3List.add("Right-click to fill network,");
|
||||
par3List.add("shift-right to empty.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
World world = par3EntityPlayer.worldObj;
|
||||
|
||||
if (par3EntityPlayer instanceof FakePlayer)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
double posX = par3EntityPlayer.posX;
|
||||
double posY = par3EntityPlayer.posY;
|
||||
double posZ = par3EntityPlayer.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.worldObj.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
EnergyItems.setCurrentEssence(itemTag.getString("ownerName"), 0);
|
||||
} else
|
||||
{
|
||||
EnergyItems.addEssenceToMaximum(itemTag.getString("ownerName"), 1000000, Integer.MAX_VALUE);
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return the damage that was not deducted
|
||||
*/
|
||||
public int damageItem(ItemStack par1ItemStack, int par2int)
|
||||
{
|
||||
if (par2int == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int before = this.getDamage(par1ItemStack);
|
||||
this.setDamage(par1ItemStack, this.getDamage(par1ItemStack) + par2int);
|
||||
return par2int - (this.getDamage(par1ItemStack) - before);
|
||||
}
|
||||
|
||||
protected void damagePlayer(World world, EntityPlayer player, int damage)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
double posX = player.posX;
|
||||
double posY = player.posY;
|
||||
double posZ = player.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
float f = (float) 1.0F;
|
||||
float f1 = f * 0.6F + 0.4F;
|
||||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < damage; i++)
|
||||
{
|
||||
player.setHealth((player.getHealth() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getHealth() <= 0)
|
||||
{
|
||||
player.inventory.dropAllItems();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCurrentEssence(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
String owner = itemTag.getString("ownerName");
|
||||
World worldSave = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) worldSave.loadItemData(LifeEssenceNetwork.class, owner);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(owner);
|
||||
worldSave.setItemData(owner, data);
|
||||
}
|
||||
|
||||
int currentEssence = data.currentEssence;
|
||||
return (currentEssence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,263 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import com.google.common.collect.Multimap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.monster.EntitySlime;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DaggerOfSacrifice extends EnergyItems
|
||||
{
|
||||
private float weaponDamage;
|
||||
|
||||
public DaggerOfSacrifice()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(100);
|
||||
setFull3D();
|
||||
setMaxDamage(100);
|
||||
weaponDamage = 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DaggerOfSacrifice");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (par3EntityLivingBase == null || par2EntityLivingBase == null || par3EntityLivingBase.worldObj.isRemote || (par3EntityLivingBase instanceof EntityPlayer && SpellHelper.isFakePlayer(par3EntityLivingBase.worldObj, (EntityPlayer) par3EntityLivingBase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (par2EntityLivingBase.isChild() || par2EntityLivingBase instanceof EntityWither || par2EntityLivingBase instanceof EntityDragon || par2EntityLivingBase instanceof EntityPlayer || par2EntityLivingBase instanceof IBossDisplayData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = par2EntityLivingBase.worldObj;
|
||||
|
||||
if (par2EntityLivingBase.isDead || par2EntityLivingBase.getHealth() < 0.5f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (par2EntityLivingBase instanceof EntityVillager && !par2EntityLivingBase.isChild())
|
||||
{
|
||||
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, 2000))
|
||||
{
|
||||
double posX = par2EntityLivingBase.posX;
|
||||
double posY = par2EntityLivingBase.posY;
|
||||
double posZ = par2EntityLivingBase.posZ;
|
||||
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
|
||||
}
|
||||
|
||||
par2EntityLivingBase.setHealth(-1);
|
||||
par2EntityLivingBase.onDeath(DamageSource.generic);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2EntityLivingBase instanceof EntitySlime && !par2EntityLivingBase.isChild())
|
||||
{
|
||||
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, 150))
|
||||
{
|
||||
double posX = par2EntityLivingBase.posX;
|
||||
double posY = par2EntityLivingBase.posY;
|
||||
double posZ = par2EntityLivingBase.posZ;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
|
||||
}
|
||||
|
||||
par2EntityLivingBase.setHealth(-1);
|
||||
par2EntityLivingBase.onDeath(DamageSource.generic);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2EntityLivingBase instanceof EntityEnderman && !par2EntityLivingBase.isChild())
|
||||
{
|
||||
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, 200))
|
||||
{
|
||||
double posX = par2EntityLivingBase.posX;
|
||||
double posY = par2EntityLivingBase.posY;
|
||||
double posZ = par2EntityLivingBase.posZ;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
|
||||
}
|
||||
|
||||
par2EntityLivingBase.setHealth(-1);
|
||||
par2EntityLivingBase.onDeath(DamageSource.generic);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (par2EntityLivingBase instanceof EntityAnimal && !par2EntityLivingBase.isChild())
|
||||
{
|
||||
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, 250))
|
||||
{
|
||||
double posX = par2EntityLivingBase.posX;
|
||||
double posY = par2EntityLivingBase.posY;
|
||||
double posZ = par2EntityLivingBase.posZ;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
|
||||
}
|
||||
|
||||
par2EntityLivingBase.setHealth(-1);
|
||||
par2EntityLivingBase.onDeath(DamageSource.generic);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, 500))
|
||||
{
|
||||
double posX = par2EntityLivingBase.posX;
|
||||
double posY = par2EntityLivingBase.posY;
|
||||
double posZ = par2EntityLivingBase.posZ;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 1, posX, posY, posZ);
|
||||
}
|
||||
|
||||
par2EntityLivingBase.setHealth(-1);
|
||||
par2EntityLivingBase.onDeath(DamageSource.generic);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public float func_82803_g()
|
||||
{
|
||||
return 4.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: may cause");
|
||||
par3List.add("a bad day...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150893_a(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (par2Block == Blocks.web)
|
||||
{
|
||||
return 15.0F;
|
||||
} else
|
||||
{
|
||||
Material material = par2Block.getMaterial();
|
||||
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Multimap getItemAttributeModifiers()
|
||||
{
|
||||
Multimap multimap = super.getItemAttributeModifiers();
|
||||
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", 1.0d, 0));
|
||||
return multimap;
|
||||
}
|
||||
|
||||
public boolean findAndFillAltar(World world, EntityLivingBase sacrifice, int amount)
|
||||
{
|
||||
int posX = (int) Math.round(sacrifice.posX - 0.5f);
|
||||
int posY = (int) sacrifice.posY;
|
||||
int posZ = (int) Math.round(sacrifice.posZ - 0.5f);
|
||||
TEAltar altarEntity = this.getAltar(world, posX, posY, posZ);
|
||||
|
||||
if (altarEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
altarEntity.sacrificialDaggerCall(amount, true);
|
||||
altarEntity.startCycle();
|
||||
return true;
|
||||
}
|
||||
|
||||
public TEAltar getAltar(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = null;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
tileEntity = world.getTileEntity(i + x, k + y, j + z);
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.entity.mob.EntityDemon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityList.EntityEggInfo;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DemonPlacer extends Item
|
||||
{
|
||||
public DemonPlacer()
|
||||
{
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabs.tabMisc);
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
public String getItemDisplayName(ItemStack par1ItemStack)
|
||||
{
|
||||
return "Demon Crystal";
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
|
||||
{
|
||||
EntityEggInfo entityegginfo = (EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(par1ItemStack.getItemDamage()));
|
||||
return entityegginfo != null ? (par2 == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
|
||||
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
|
||||
*/
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par3World.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
Block i1 = par3World.getBlock(par4, par5, par6);
|
||||
par4 += Facing.offsetsXForSide[par7];
|
||||
par5 += Facing.offsetsYForSide[par7];
|
||||
par6 += Facing.offsetsZForSide[par7];
|
||||
double d0 = 0.0D;
|
||||
|
||||
if (par7 == 1 && i1 != null && i1.getRenderType() == 11)
|
||||
{
|
||||
d0 = 0.5D;
|
||||
}
|
||||
|
||||
String demonName = DemonPlacer.getDemonString(par1ItemStack);
|
||||
Entity entity = spawnCreature(par3World, demonName, (double) par4 + 0.5D, (double) par5 + d0, (double) par6 + 0.5D, par1ItemStack);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
|
||||
{
|
||||
((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName());
|
||||
}
|
||||
|
||||
if (!par2EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
--par1ItemStack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par2World.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par2World.getBlock(i, j, k).getMaterial() == Material.water)
|
||||
{
|
||||
String demonName = DemonPlacer.getDemonString(par1ItemStack);
|
||||
Entity entity = spawnCreature(par2World, demonName, (double) i, (double) j, (double) k, par1ItemStack);
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
|
||||
{
|
||||
((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName());
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
--par1ItemStack.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawns the creature specified by the egg's type in the location specified by the last three parameters.
|
||||
* Parameters: world, entityID, x, y, z.
|
||||
*/
|
||||
public static Entity spawnCreature(World par0World, String par1, double par2, double par4, double par6, ItemStack itemStack)
|
||||
{
|
||||
Entity entity = null;
|
||||
|
||||
for (int j = 0; j < 1; ++j)
|
||||
{
|
||||
entity = SummoningRegistry.getEntityWithID(par0World, par1);
|
||||
|
||||
if (entity != null && entity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLiving entityliving = (EntityLiving) entity;
|
||||
entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F);
|
||||
entityliving.rotationYawHead = entityliving.rotationYaw;
|
||||
entityliving.renderYawOffset = entityliving.rotationYaw;
|
||||
if (entityliving instanceof EntityDemon)
|
||||
{
|
||||
((EntityDemon) entityliving).func_152115_b(DemonPlacer.getOwnerName(itemStack));
|
||||
|
||||
if (!DemonPlacer.getOwnerName(itemStack).equals(""))
|
||||
{
|
||||
((EntityDemon) entityliving).setTamed(true);
|
||||
}
|
||||
}
|
||||
|
||||
par0World.spawnEntityInWorld(entity);
|
||||
entityliving.playLivingSound();
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static void setOwnerName(ItemStack par1ItemStack, String ownerName)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setString("ownerName", ownerName);
|
||||
}
|
||||
|
||||
public static String getOwnerName(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return par1ItemStack.stackTagCompound.getString("ownerName");
|
||||
}
|
||||
|
||||
public static void setDemonString(ItemStack itemStack, String demonName)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setString("demonName", demonName);
|
||||
}
|
||||
|
||||
public static String getDemonString(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getString("demonName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to spawn demons.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Demon's Owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DemonPlacer");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DemonicTelepositionFocus extends TelepositionFocus
|
||||
{
|
||||
public DemonicTelepositionFocus()
|
||||
{
|
||||
super(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DemonicTeleposerFocus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A stronger version of the focus,");
|
||||
par3List.add("using a demonic shard");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class DuskScribeTool extends ScribeTool
|
||||
{
|
||||
public DuskScribeTool()
|
||||
{
|
||||
super(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DuskScribeTool");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class EarthScribeTool extends ScribeTool
|
||||
{
|
||||
public EarthScribeTool()
|
||||
{
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EarthScribeTool");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnergyBattery extends Item implements ArmourUpgrade, IBindable, IBloodOrb
|
||||
{
|
||||
private int maxEssence;
|
||||
protected int orbLevel;
|
||||
|
||||
public EnergyBattery(int damage)
|
||||
{
|
||||
super();
|
||||
DamageSource damageSource = DamageSource.generic;
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
maxEssence = damage;
|
||||
orbLevel = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBattery");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Stores raw Life Essence");
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
World world = par3EntityPlayer.worldObj;
|
||||
if (world != null)
|
||||
{
|
||||
double posX = par3EntityPlayer.posX;
|
||||
double posY = par3EntityPlayer.posY;
|
||||
double posZ = par3EntityPlayer.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
|
||||
}
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (world.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
EnergyItems.addEssenceToMaximum(itemTag.getString("ownerName"), 200, this.getMaxEssence());
|
||||
EnergyItems.hurtPlayer(par3EntityPlayer, 200);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return the damage that was not deducted
|
||||
*/
|
||||
public int damageItem(ItemStack par1ItemStack, int par2int)
|
||||
{
|
||||
if (par2int == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int before = this.getDamage(par1ItemStack);
|
||||
this.setDamage(par1ItemStack, this.getDamage(par1ItemStack) + par2int);
|
||||
return par2int - (this.getDamage(par1ItemStack) - before);
|
||||
}
|
||||
|
||||
protected void damagePlayer(World world, EntityPlayer player, int damage)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
double posX = player.posX;
|
||||
double posY = player.posY;
|
||||
double posZ = player.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
float f = (float) 1.0F;
|
||||
float f1 = f * 0.6F + 0.4F;
|
||||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < damage; i++)
|
||||
{
|
||||
player.setHealth((player.getHealth() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getHealth() <= 0)
|
||||
{
|
||||
player.inventory.dropAllItems();
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxEssence()
|
||||
{
|
||||
return this.maxEssence;
|
||||
}
|
||||
|
||||
public int getOrbLevel()
|
||||
{
|
||||
return orbLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//@SideOnly(Side.SERVER)
|
||||
public int getCurrentEssence(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
String owner = itemTag.getString("ownerName");
|
||||
World worldSave = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) worldSave.loadItemData(LifeEssenceNetwork.class, owner);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(owner);
|
||||
worldSave.setItemData(owner, data);
|
||||
}
|
||||
|
||||
int currentEssence = data.currentEssence;
|
||||
return (currentEssence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,211 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityEnergyBazookaMainProjectile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnergyBazooka extends EnergyItems
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private static int damage;
|
||||
private static final int maxDelay = 150;
|
||||
|
||||
public EnergyBazooka()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setFull3D();
|
||||
setMaxDamage(250);
|
||||
this.setEnergyUsed(20000);
|
||||
damage = 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBazooka_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBazooka_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 100);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.getDelay(par1ItemStack) > 0)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
|
||||
}
|
||||
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityEnergyBazookaMainProjectile(par2World, par3EntityPlayer, damage));
|
||||
this.setDelay(par1ItemStack, maxDelay);
|
||||
}
|
||||
|
||||
Vec3 vec = par3EntityPlayer.getLookVec();
|
||||
double wantedVelocity = 3.0f;
|
||||
par3EntityPlayer.motionX = -vec.xCoord * wantedVelocity;
|
||||
par3EntityPlayer.motionY = -vec.yCoord * wantedVelocity;
|
||||
par3EntityPlayer.motionZ = -vec.zCoord * wantedVelocity;
|
||||
par2World.playSoundEffect((double) ((float) par3EntityPlayer.posX + 0.5F), (double) ((float) par3EntityPlayer.posY + 0.5F), (double) ((float) par3EntityPlayer.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F);
|
||||
par3EntityPlayer.fallDistance = 0;
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
int delay = this.getDelay(par1ItemStack);
|
||||
|
||||
if (!par2World.isRemote && delay > 0)
|
||||
{
|
||||
this.setDelay(par1ItemStack, delay - 1);
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 100 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Boom.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
public void setDelay(ItemStack par1ItemStack, int newDelay)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setInteger("delay", newDelay);
|
||||
}
|
||||
|
||||
public int getDelay(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getInteger("delay");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.entity.projectile.EnergyBlastProjectile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnergyBlast extends EnergyItems
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private static int damage;
|
||||
private static final int maxDelay = 15;
|
||||
|
||||
public EnergyBlast()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setUnlocalizedName("energyBlaster");
|
||||
setFull3D();
|
||||
setMaxDamage(250);
|
||||
this.setEnergyUsed(150);
|
||||
damage = 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBlaster_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:EnergyBlaster_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 100);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.getDelay(par1ItemStack) > 0)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
|
||||
}
|
||||
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EnergyBlastProjectile(par2World, par3EntityPlayer, damage));
|
||||
this.setDelay(par1ItemStack, maxDelay);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
int delay = this.getDelay(par1ItemStack);
|
||||
|
||||
if (!par2World.isRemote && delay > 0)
|
||||
{
|
||||
this.setDelay(par1ItemStack, delay - 1);
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 100 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to fire devastating");
|
||||
par3List.add("projectiles.");
|
||||
par3List.add("Damage: " + damage);
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
public void setDelay(ItemStack par1ItemStack, int newDelay)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setInteger("delay", newDelay);
|
||||
}
|
||||
|
||||
public int getDelay(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getInteger("delay");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,335 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EnergyItems extends Item implements IBindable
|
||||
{
|
||||
private int energyUsed;
|
||||
|
||||
public EnergyItems()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
this.energyUsed = par1int;
|
||||
}
|
||||
|
||||
protected int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
protected void damagePlayer(World world, EntityPlayer player, int damage)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
double posX = player.posX;
|
||||
double posY = player.posY;
|
||||
double posZ = player.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
float f = (float) 1.0F;
|
||||
float f1 = f * 0.6F + 0.4F;
|
||||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < damage; i++)
|
||||
{
|
||||
player.setHealth((player.getHealth() - 1));
|
||||
|
||||
if (player.getHealth() <= 0.0005)
|
||||
{
|
||||
player.inventory.dropAllItems();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
return syphonAndDamageWhileInContainer(ist, player, damageToBeDone);
|
||||
} else
|
||||
{
|
||||
World world = player.worldObj;
|
||||
if (world != null)
|
||||
{
|
||||
double posX = player.posX;
|
||||
double posY = player.posY;
|
||||
double posZ = player.posZ;
|
||||
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
|
||||
world.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean syphonWhileInContainer(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= damageToBeDone)
|
||||
{
|
||||
data.currentEssence -= damageToBeDone;
|
||||
data.markDirty();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canSyphonInContainer(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.currentEssence >= damageToBeDone;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
|
||||
{
|
||||
if (energySyphoned < 100 && energySyphoned > 0)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(DamageSource.generic);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (energySyphoned >= 100)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
|
||||
{
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(DamageSource.generic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean syphonAndDamageWhileInContainer(ItemStack ist, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (!syphonWhileInContainer(ist, damageToBeDone))
|
||||
{
|
||||
hurtPlayer(player, damageToBeDone);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Global static methods
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", SoulNetworkHandler.getUsername(player));
|
||||
}
|
||||
|
||||
initializePlayer(player);
|
||||
}
|
||||
|
||||
public static void setItemOwner(ItemStack item, String ownerName)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
item.stackTagCompound.setString("ownerName", ownerName);
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initializePlayer(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound tag = player.getEntityData();
|
||||
|
||||
if (tag.getInteger("currentEssence") == 0)
|
||||
{
|
||||
tag.setInteger("currentEssence", 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOwnerName(ItemStack item)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return item.stackTagCompound.getString("ownerName");
|
||||
}
|
||||
|
||||
public static void drainPlayerNetwork(EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
String ownerName = SpellHelper.getUsername(player);
|
||||
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= damageToBeDone)
|
||||
{
|
||||
data.currentEssence -= damageToBeDone;
|
||||
data.markDirty();
|
||||
} else
|
||||
{
|
||||
hurtPlayer(player, damageToBeDone);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getCurrentEssence(String ownerName)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.currentEssence;
|
||||
}
|
||||
|
||||
public static void setCurrentEssence(String ownerName, int amount)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
data.currentEssence = amount;
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
public static void addEssenceToMaximum(String ownerName, int amount, int maximum)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= maximum)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data.currentEssence = Math.min(maximum, data.currentEssence + amount);
|
||||
data.markDirty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnergySword extends ItemSword
|
||||
{
|
||||
private NBTTagCompound data;
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int energyUsed;
|
||||
|
||||
public EnergySword()
|
||||
{
|
||||
super(AlchemicalWizardry.bloodBoundToolMaterial);
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setEnergyUsed(50);
|
||||
setFull3D();
|
||||
setMaxDamage(100);
|
||||
}
|
||||
|
||||
public void setEnergyUsed(int i)
|
||||
{
|
||||
energyUsed = i;
|
||||
}
|
||||
|
||||
public int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundSword_activated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundSword_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
return !getActivated(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
if (par3EntityLivingBase instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, (EntityPlayer) par3EntityLivingBase);
|
||||
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3EntityLivingBase, this.getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
par2EntityLivingBase.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
this.setActivated(par1ItemStack, !getActivated(par1ItemStack));
|
||||
par1ItemStack.stackTagCompound.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 100);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!getActivated(par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 100 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, 50);
|
||||
}
|
||||
}
|
||||
|
||||
par1ItemStack.setItemDamage(0);
|
||||
return;
|
||||
}
|
||||
|
||||
public void setActivated(ItemStack par1ItemStack, boolean newActivated)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemTag.setBoolean("isActive", newActivated);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack par1ItemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getBoolean("isActive");
|
||||
}
|
||||
|
||||
public float func_82803_g()
|
||||
{
|
||||
return 4.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: may cause");
|
||||
par3List.add("a bad day...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float func_150893_a(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (par2Block == Blocks.web)
|
||||
{
|
||||
return 15.0F;
|
||||
} else
|
||||
{
|
||||
Material material = par2Block.getMaterial();
|
||||
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EnhancedTelepositionFocus extends TelepositionFocus
|
||||
{
|
||||
public EnhancedTelepositionFocus()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnhancedTeleposerFocus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A focus further enhanced in an altar");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class FireScribeTool extends ScribeTool
|
||||
{
|
||||
public FireScribeTool()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:FireScribeTool");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAlchemyBase extends Item
|
||||
{
|
||||
private static final String[] ITEM_NAMES = new String[]{"Offensa", "Praesidium", "OrbisTerrae", "StrengthenedCatalyst", "ConcentratedCatalyst", "FracturedBone", "Virtus", "Reductus", "Potentia"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemAlchemyBase()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 64;
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[ITEM_NAMES.length];
|
||||
|
||||
for (int i = 0; i < ITEM_NAMES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon("AlchemicalWizardry:" + "baseAlchemyItem" + ITEM_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEM_NAMES.length - 1);
|
||||
return ("" + "item.bloodMagicAlchemyItem." + ITEM_NAMES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
int j = MathHelper.clamp_int(meta, 0, ITEM_NAMES.length - 1);
|
||||
return icons[j];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < ITEM_NAMES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainer;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockCrystalBelljar extends ItemBlock
|
||||
{
|
||||
public ItemBlockCrystalBelljar(Block par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(16);
|
||||
}
|
||||
|
||||
public int getMetadata(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
public ReagentContainer[] getReagentContainers(ItemStack stack)
|
||||
{
|
||||
if (stack != null && stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
int size = tagList.tagCount();
|
||||
ReagentContainer[] tanks = new ReagentContainer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
|
||||
tanks[i] = ReagentContainer.readFromNBT(savedTag);
|
||||
}
|
||||
|
||||
return tanks;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
ReagentContainer[] tanks = this.getReagentContainers(stack);
|
||||
|
||||
if (tanks == null)
|
||||
{
|
||||
list.add("- Empty");
|
||||
} else
|
||||
{
|
||||
list.add("Current Contents:");
|
||||
for (int i = 0; i < tanks.length; i++)
|
||||
{
|
||||
if (tanks[i] == null || tanks[i].getReagent() == null || tanks[i].getReagent().reagent == null)
|
||||
{
|
||||
list.add("- Empty");
|
||||
} else
|
||||
{
|
||||
ReagentStack reagentStack = tanks[i].getReagent();
|
||||
list.add("- " + reagentStack.reagent.name + ": " + reagentStack.amount + "/" + tanks[i].getCapacity() / 1000 + "k AR");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
if (!world.setBlock(x, y, z, field_150939_a, metadata, 3))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlock(x, y, z) == field_150939_a)
|
||||
{
|
||||
field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
field_150939_a.onPostBlockPlaced(world, x, y, z, metadata);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemBloodRuneBlock extends ItemBlock
|
||||
|
||||
{
|
||||
public ItemBloodRuneBlock(Block block)
|
||||
{
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
|
||||
{
|
||||
String name = "";
|
||||
|
||||
switch (itemstack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
name = "blank";
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
name = "fill";
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
name = "empty";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
name = "orb";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
name = "betterCapacity";
|
||||
break;
|
||||
|
||||
default:
|
||||
name = "broken";
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
public int getMetadata(int par1)
|
||||
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TESpellParadigmBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemComplexSpellCrystal extends EnergyItems
|
||||
{
|
||||
public ItemComplexSpellCrystal()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ComplexCrystal");
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
World world = DimensionManager.getWorld(getDimensionID(par1ItemStack));
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
TileEntity tileEntity = world.getTileEntity(itemTag.getInteger("xCoord"), itemTag.getInteger("yCoord"), itemTag.getInteger("zCoord"));
|
||||
|
||||
if (tileEntity instanceof TESpellParadigmBlock)
|
||||
{
|
||||
TESpellParadigmBlock tileParad = (TESpellParadigmBlock) tileEntity;
|
||||
|
||||
tileParad.castSpell(par2World, par3EntityPlayer, par1ItemStack);
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
par2World.playSoundAtEntity(par3EntityPlayer, "random.fizz", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getDimensionID(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getInteger("dimensionId");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemComponents extends Item
|
||||
{
|
||||
private static final String[] ITEM_NAMES = new String[]{"QuartzRod", "EmptyCore", "MagicalesCable", "WoodBrace", "StoneBrace", "ProjectileCore", "SelfCore", "MeleeCore", "ParadigmBackPlate", "OutputCable", "FlameCore", "IcyCore", "GustCore", "EarthenCore", "InputCable", "CrackedRunicPlate", "RunicPlate", "ScribedRunicPlate", "DefaultCore", "OffensiveCore", "DefensiveCore", "EnvironmentalCore", "PowerCore", "CostCore", "PotencyCore", "ObsidianBrace", "ToolCore"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
public ItemComponents()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 64;
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
icons = new IIcon[ITEM_NAMES.length];
|
||||
|
||||
for (int i = 0; i < ITEM_NAMES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon("AlchemicalWizardry:" + "baseItem" + ITEM_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
//This is what will do all the localisation things on the alchemy components so you dont have to set it :D
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, ITEM_NAMES.length - 1);
|
||||
return ("" + "item.bloodMagicBaseItem." + ITEM_NAMES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
int j = MathHelper.clamp_int(meta, 0, ITEM_NAMES.length - 1);
|
||||
return icons[j];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
for (int meta = 0; meta < ITEM_NAMES.length; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDiabloKey extends EnergyItems
|
||||
{
|
||||
public ItemDiabloKey()
|
||||
{
|
||||
super();
|
||||
DamageSource damageSource = DamageSource.generic;
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.setEnergyUsed(1000);
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DiabloKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Binds other items to the owner's network");
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
World world = par3EntityPlayer.worldObj;
|
||||
|
||||
if (par3EntityPlayer instanceof FakePlayer || par3EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (world != null)
|
||||
{
|
||||
double posX = par3EntityPlayer.posX;
|
||||
double posY = par3EntityPlayer.posY;
|
||||
double posZ = par3EntityPlayer.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.worldObj.isRemote && !(par3EntityPlayer.getClass().equals(EntityPlayerMP.class)))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
String ownerName = itemTag.getString("ownerName");
|
||||
ItemStack[] inv = par3EntityPlayer.inventory.mainInventory;
|
||||
|
||||
for (ItemStack itemStack : inv)
|
||||
{
|
||||
if (itemStack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Item item = itemStack.getItem();
|
||||
|
||||
if (item instanceof ItemDiabloKey)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item instanceof IBindable)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(itemStack, ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
list.add(new ItemStack(ModItems.itemKeyOfDiablo));
|
||||
ItemStack boundKey = new ItemStack(ModItems.itemKeyOfDiablo);
|
||||
EnergyItems.checkAndSetItemOwner(boundKey, "Server-wide Soul Network");
|
||||
list.add(boundKey);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemRitualDiviner extends EnergyItems
|
||||
{
|
||||
private int maxMetaData;
|
||||
|
||||
public ItemRitualDiviner()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(100);
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.maxMetaData = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:RitualDiviner");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to explore new types of rituals");
|
||||
|
||||
if (this.getMaxRuneDisplacement(par1ItemStack) == 1)
|
||||
{
|
||||
par3List.add("Can place Dusk runes");
|
||||
} else
|
||||
{
|
||||
par3List.add("Can not place Dusk runes");
|
||||
}
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
String ritualID = this.getCurrentRitual(par1ItemStack);
|
||||
//TODO
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
par3List.add("RitualID: " + ritualID);
|
||||
List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(par1ItemStack));
|
||||
if (ritualList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int blankStones = 0;
|
||||
int airStones = 0;
|
||||
int waterStones = 0;
|
||||
int fireStones = 0;
|
||||
int earthStones = 0;
|
||||
int duskStones = 0;
|
||||
|
||||
for (RitualComponent rc : ritualList)
|
||||
{
|
||||
switch (rc.getStoneType())
|
||||
{
|
||||
case RitualComponent.BLANK:
|
||||
blankStones++;
|
||||
break;
|
||||
|
||||
case RitualComponent.AIR:
|
||||
airStones++;
|
||||
break;
|
||||
|
||||
case RitualComponent.WATER:
|
||||
waterStones++;
|
||||
break;
|
||||
|
||||
case RitualComponent.FIRE:
|
||||
fireStones++;
|
||||
break;
|
||||
|
||||
case RitualComponent.EARTH:
|
||||
earthStones++;
|
||||
break;
|
||||
|
||||
case RitualComponent.DUSK:
|
||||
duskStones++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
par3List.add("Blank stones: " + blankStones);
|
||||
par3List.add(EnumChatFormatting.AQUA + "Air stones: " + airStones);
|
||||
par3List.add(EnumChatFormatting.BLUE + "Water stones: " + waterStones);
|
||||
par3List.add(EnumChatFormatting.RED + "Fire stones: " + fireStones);
|
||||
par3List.add(EnumChatFormatting.DARK_GREEN + "Earth stones: " + earthStones);
|
||||
par3List.add(EnumChatFormatting.BOLD + "Dusk stones: " + duskStones);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack par1ItemStack)
|
||||
{
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
String ritualID = this.getCurrentRitual(par1ItemStack);
|
||||
if (ritualID.equals(""))
|
||||
{
|
||||
return super.getItemStackDisplayName(par1ItemStack);
|
||||
}
|
||||
return "Ritual: " + Rituals.getNameOfRitual(ritualID);
|
||||
} else
|
||||
{
|
||||
return super.getItemStackDisplayName(par1ItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
|
||||
ItemStack[] playerInventory = par2EntityPlayer.inventory.mainInventory;
|
||||
TileEntity tileEntity = par3World.getTileEntity(par4, par5, par6);
|
||||
|
||||
if (tileEntity instanceof TEMasterStone)
|
||||
{
|
||||
TEMasterStone masterStone = (TEMasterStone) tileEntity;
|
||||
List<RitualComponent> ritualList = Rituals.getRitualList(this.getCurrentRitual(par1ItemStack));
|
||||
if (ritualList == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int playerInvRitualStoneLocation = -1;
|
||||
|
||||
for (int i = 0; i < playerInventory.length; i++)
|
||||
{
|
||||
if (playerInventory[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (new ItemStack(ModBlocks.ritualStone).isItemEqual(playerInventory[i]))
|
||||
{
|
||||
playerInvRitualStoneLocation = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (RitualComponent rc : ritualList)
|
||||
{
|
||||
if (par3World.isAirBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ()))
|
||||
{
|
||||
if (playerInvRitualStoneLocation >= 0)
|
||||
{
|
||||
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(par1ItemStack))
|
||||
{
|
||||
par3World.playAuxSFX(200, par4, par5 + 1, par6, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!par2EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
par2EntityPlayer.inventory.decrStackSize(playerInvRitualStoneLocation, 1);
|
||||
}
|
||||
|
||||
par3World.setBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ(), ModBlocks.ritualStone, rc.getStoneType(), 3);
|
||||
|
||||
if (par3World.isRemote)
|
||||
{
|
||||
par3World.playAuxSFX(2005, par4, par5 + 1, par6, 0);
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
Block block = par3World.getBlock(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ());
|
||||
|
||||
if (block == ModBlocks.ritualStone)
|
||||
{
|
||||
int metadata = par3World.getBlockMetadata(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ());
|
||||
|
||||
if (metadata != rc.getStoneType())
|
||||
{
|
||||
if (rc.getStoneType() > this.maxMetaData + this.getMaxRuneDisplacement(par1ItemStack))
|
||||
{
|
||||
par3World.playAuxSFX(200, par4, par5 + 1, par6, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
par3World.setBlockMetadataWithNotify(par4 + rc.getX(), par5 + rc.getY(), par6 + rc.getZ(), rc.getStoneType(), 3);
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3World.playAuxSFX(0000, par4, par5 + 1, par6, 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
int maxRitualID = Rituals.getNumberOfRituals();
|
||||
String currentRitualID = this.getCurrentRitual(par1ItemStack);
|
||||
|
||||
this.setCurrentRitual(par1ItemStack, Rituals.getNextRitualKey(currentRitualID));
|
||||
|
||||
if (par2World.isRemote)
|
||||
{
|
||||
IChatComponent chatmessagecomponent = new ChatComponentText("Current Ritual: " + Rituals.getNameOfRitual(this.getCurrentRitual(par1ItemStack)));
|
||||
par3EntityPlayer.addChatComponentMessage(chatmessagecomponent);
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
||||
{
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
|
||||
if (player.isSneaking() && !player.isSwingInProgress)
|
||||
{
|
||||
int maxRitualID = Rituals.getNumberOfRituals();
|
||||
String currentRitualID = this.getCurrentRitual(stack);
|
||||
|
||||
this.setCurrentRitual(stack, Rituals.getPreviousRitualKey(currentRitualID));
|
||||
|
||||
if (entityLiving.worldObj.isRemote)
|
||||
{
|
||||
IChatComponent chatmessagecomponent = new ChatComponentText("Current Ritual: " + Rituals.getNameOfRitual(this.getCurrentRitual(stack)));
|
||||
player.addChatComponentMessage(chatmessagecomponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getCurrentRitual(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return par1ItemStack.stackTagCompound.getString("ritualID");
|
||||
}
|
||||
|
||||
public void setCurrentRitual(ItemStack par1ItemStack, String ritualID)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setString("ritualID", ritualID);
|
||||
}
|
||||
|
||||
public int getMaxRuneDisplacement(ItemStack par1ItemStack) //0 indicates the starting 4 runes, 1 indicates it can use Dusk runes
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return par1ItemStack.stackTagCompound.getInteger("maxRuneDisplacement");
|
||||
}
|
||||
|
||||
public void setMaxRuneDisplacement(ItemStack par1ItemStack, int displacement)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setInteger("maxRuneDisplacement", displacement);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
list.add(new ItemStack(ModItems.itemRitualDiviner));
|
||||
ItemStack duskRitualDivinerStack = new ItemStack(ModItems.itemRitualDiviner);
|
||||
((ItemRitualDiviner) duskRitualDivinerStack.getItem()).setMaxRuneDisplacement(duskRitualDivinerStack, 1);
|
||||
list.add(duskRitualDivinerStack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemSpellEffectBlock extends ItemBlock
|
||||
|
||||
{
|
||||
public ItemSpellEffectBlock(Block par1)
|
||||
{
|
||||
super(par1);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
|
||||
{
|
||||
String name = "";
|
||||
|
||||
switch (itemstack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
name = "fire";
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
name = "ice";
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
name = "wind";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
name = "earth";
|
||||
break;
|
||||
|
||||
default:
|
||||
name = "broken";
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
public int getMetadata(int par1)
|
||||
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemSpellEnhancementBlock extends ItemBlock
|
||||
|
||||
{
|
||||
public ItemSpellEnhancementBlock(Block par1)
|
||||
{
|
||||
super(par1);
|
||||
setHasSubtypes(true);
|
||||
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
|
||||
{
|
||||
String name = "";
|
||||
|
||||
switch (itemstack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
name = "power1";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
name = "power2";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
name = "power3";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
name = "power4";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
name = "power5";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
name = "cost1";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
name = "cost2";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
name = "cost3";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
name = "cost4";
|
||||
break;
|
||||
|
||||
case 9:
|
||||
name = "cost5";
|
||||
break;
|
||||
|
||||
case 10:
|
||||
name = "potency1";
|
||||
break;
|
||||
|
||||
case 11:
|
||||
name = "potency2";
|
||||
break;
|
||||
|
||||
case 12:
|
||||
name = "potency3";
|
||||
break;
|
||||
|
||||
case 13:
|
||||
name = "potency4";
|
||||
break;
|
||||
|
||||
case 14:
|
||||
name = "potency5";
|
||||
break;
|
||||
|
||||
default:
|
||||
name = "broken";
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
public int getMetadata(int par1)
|
||||
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemSpellModifierBlock extends ItemBlock
|
||||
|
||||
{
|
||||
public ItemSpellModifierBlock(Block par1)
|
||||
{
|
||||
super(par1);
|
||||
setHasSubtypes(true);
|
||||
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
|
||||
{
|
||||
String name = "";
|
||||
|
||||
switch (itemstack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
name = "default";
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
name = "offensive";
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
name = "defensive";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
name = "environmental";
|
||||
break;
|
||||
|
||||
default:
|
||||
name = "broken";
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
public int getMetadata(int par1)
|
||||
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemSpellParadigmBlock extends ItemBlock
|
||||
|
||||
{
|
||||
public ItemSpellParadigmBlock(Block par1)
|
||||
{
|
||||
super(par1);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack)
|
||||
|
||||
{
|
||||
String name = "";
|
||||
|
||||
switch (itemstack.getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
name = "projectile";
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
name = "self";
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
name = "melee";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
name = "tool";
|
||||
break;
|
||||
|
||||
default:
|
||||
name = "broken";
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.LifeEssenceNetwork;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LavaCrystal extends EnergyItems
|
||||
{
|
||||
public LavaCrystal()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setUnlocalizedName("lavaCrystal");
|
||||
setEnergyUsed(25);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:LavaCrystal");
|
||||
}
|
||||
|
||||
/*
|
||||
* Used to have the item contain itself.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
{
|
||||
syphonWhileInContainer(itemStack, this.getEnergyUsed());
|
||||
ItemStack copiedStack = itemStack.copy();
|
||||
copiedStack.setItemDamage(copiedStack.getItemDamage());
|
||||
copiedStack.stackSize = 1;
|
||||
return copiedStack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
int damage = this.getDamage(par1ItemStack);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Store life to smelt");
|
||||
par3List.add("stuff in the furnace.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEnoughEssence(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getTagCompound() != null && !(itemStack.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
String ownerName = itemStack.getTagCompound().getString("ownerName");
|
||||
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= this.getEnergyUsed())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
|
||||
public class LifeBucket extends ItemBucket
|
||||
{
|
||||
public LifeBucket(Block block)
|
||||
{
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:LifeBucket");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class MagicianBloodOrb extends EnergyBattery
|
||||
{
|
||||
public MagicianBloodOrb(int damage)
|
||||
{
|
||||
super(damage);
|
||||
orbLevel = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:MagicianBloodOrb");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class MasterBloodOrb extends EnergyBattery
|
||||
{
|
||||
public MasterBloodOrb(int damage)
|
||||
{
|
||||
super(damage);
|
||||
orbLevel = 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:MasterBloodOrb");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class OrbOfTesting extends EnergyItems
|
||||
{
|
||||
public OrbOfTesting()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(CreativeTabs.tabMisc);
|
||||
setUnlocalizedName("orbOfTesting");
|
||||
setMaxDamage(100);
|
||||
setFull3D();
|
||||
this.setEnergyUsed(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Untitled");
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (!par3EntityPlayer.shouldHeal())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed()))
|
||||
{
|
||||
par3EntityPlayer.heal(1);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReinforcedTelepositionFocus extends TelepositionFocus
|
||||
{
|
||||
public ReinforcedTelepositionFocus()
|
||||
{
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:ReinforcedTeleposerFocus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A stronger version of the focus,");
|
||||
par3List.add("using a weak shard");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SacrificialDagger extends Item
|
||||
{
|
||||
public SacrificialDagger()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setFull3D();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
if (AlchemicalWizardry.wimpySettings)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SheathedItem");
|
||||
} else
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SacrificialDagger");
|
||||
}
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
if (AlchemicalWizardry.wimpySettings)
|
||||
{
|
||||
par3List.add("A slight draining feeling tickles your fingers");
|
||||
} else
|
||||
{
|
||||
par3List.add("Just a prick of the");
|
||||
par3List.add("finger will suffice...");
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
par3EntityPlayer.setHealth(par3EntityPlayer.getHealth() - 2);
|
||||
}
|
||||
|
||||
if (par3EntityPlayer instanceof FakePlayer)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
double posX = par3EntityPlayer.posX;
|
||||
double posY = par3EntityPlayer.posY;
|
||||
double posZ = par3EntityPlayer.posZ;
|
||||
par2World.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F);
|
||||
float f = (float) 1.0F;
|
||||
float f1 = f * 0.6F + 0.4F;
|
||||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
par2World.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
|
||||
if (!par2World.isRemote && SpellHelper.isFakePlayer(par2World, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionSoulFray))
|
||||
{
|
||||
findAndFillAltar(par2World, par3EntityPlayer, 20);
|
||||
} else
|
||||
{
|
||||
findAndFillAltar(par2World, par3EntityPlayer, 200);
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.getHealth() <= 0.001f)
|
||||
{
|
||||
par3EntityPlayer.onDeath(DamageSource.generic);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public void findAndFillAltar(World world, EntityPlayer player, int amount)
|
||||
{
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
TEAltar altarEntity = getAltar(world, posX, posY, posZ);
|
||||
|
||||
if (altarEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
altarEntity.sacrificialDaggerCall(amount, false);
|
||||
altarEntity.startCycle();
|
||||
}
|
||||
|
||||
public TEAltar getAltar(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = null;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
tileEntity = world.getTileEntity(i + x, k + y, j + z);
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if ((tileEntity instanceof TEAltar))
|
||||
{
|
||||
return (TEAltar) tileEntity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack par1ItemStack)
|
||||
{
|
||||
if (AlchemicalWizardry.wimpySettings)
|
||||
{
|
||||
return "Sacrificial Orb";
|
||||
}
|
||||
return super.getItemStackDisplayName(par1ItemStack);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ScribeTool extends EnergyItems
|
||||
{
|
||||
private int meta;
|
||||
|
||||
public ScribeTool(int inkType)
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
setMaxDamage(10);
|
||||
setEnergyUsed(10);
|
||||
this.meta = inkType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("The writing is on the wall...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par1ItemStack.getItemDamage() > 0)
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
|
||||
syphonBatteries(par1ItemStack, par3EntityPlayer, this.getEnergyUsed());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return this.meta;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TelepositionFocus extends EnergyItems
|
||||
{
|
||||
private int focusLevel;
|
||||
|
||||
public TelepositionFocus(int focusLevel)
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.focusLevel = focusLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:TeleposerFocus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("An Enderpearl imbued with blood");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
par3List.add("Coords: " + itemTag.getInteger("xCoord") + ", " + itemTag.getInteger("yCoord") + ", " + itemTag.getInteger("zCoord"));
|
||||
par3List.add("Bound Dimension: " + getDimensionID(par1ItemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getDimensionID(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getInteger("dimensionId");
|
||||
}
|
||||
|
||||
public World getWorld(ItemStack itemStack)
|
||||
{
|
||||
return DimensionManager.getWorld(getDimensionID(itemStack));
|
||||
}
|
||||
|
||||
public int xCoord(ItemStack itemStack)
|
||||
{
|
||||
if (!(itemStack.stackTagCompound == null))
|
||||
{
|
||||
return itemStack.stackTagCompound.getInteger("xCoord");
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int yCoord(ItemStack itemStack)
|
||||
{
|
||||
if (!(itemStack.stackTagCompound == null))
|
||||
{
|
||||
return itemStack.stackTagCompound.getInteger("yCoord");
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int zCoord(ItemStack itemStack)
|
||||
{
|
||||
if (!(itemStack.stackTagCompound == null))
|
||||
{
|
||||
return itemStack.stackTagCompound.getInteger("zCoord");
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFocusLevel()
|
||||
{
|
||||
return this.focusLevel;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package WayofTime.alchemicalWizardry.common.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class WaterScribeTool extends ScribeTool
|
||||
{
|
||||
public WaterScribeTool()
|
||||
{
|
||||
super(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WaterScribeTool");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,383 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.energy;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.*;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
|
||||
import WayofTime.alchemicalWizardry.common.Int3;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAttunedCrystal extends Item implements IReagentManipulator
|
||||
{
|
||||
public static final int maxDistance = 5;
|
||||
|
||||
public IIcon crystalBody;
|
||||
public IIcon crystalLabel;
|
||||
|
||||
public ItemAttunedCrystal()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
Reagent reagent = this.getReagent(stack);
|
||||
|
||||
String name = super.getItemStackDisplayName(stack);
|
||||
|
||||
if (reagent != null)
|
||||
{
|
||||
name = name + " (" + reagent.name + ")";
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A tool to tune alchemy");
|
||||
par3List.add("reagent transmission");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
Reagent reagent = this.getReagent(par1ItemStack);
|
||||
if (reagent != null)
|
||||
{
|
||||
par3List.add("Currently selected reagent: " + reagent.name);
|
||||
}
|
||||
|
||||
if (this.getHasSavedCoordinates(par1ItemStack))
|
||||
{
|
||||
par3List.add("");
|
||||
Int3 coords = this.getCoordinates(par1ItemStack);
|
||||
par3List.add("Coords: " + coords.xCoord + ", " + coords.yCoord + ", " + coords.zCoord);
|
||||
par3List.add("Bound Dimension: " + getDimension(par1ItemStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.crystalBody = iconRegister.registerIcon("AlchemicalWizardry:AttunedCrystal1");
|
||||
this.crystalLabel = iconRegister.registerIcon("AlchemicalWizardry:AttunedCrystal2");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass)
|
||||
{
|
||||
switch (pass)
|
||||
{
|
||||
case 0:
|
||||
return 256 * (256 * 255 + 255) + 255;
|
||||
case 1:
|
||||
Reagent reagent = this.getReagent(stack);
|
||||
if (reagent != null)
|
||||
{
|
||||
return (reagent.getColourRed() * 256 * 256 + reagent.getColourGreen() * 256 + reagent.getColourBlue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 256 * (256 * 255 + 255) + 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses(int meta)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass)
|
||||
{
|
||||
switch (pass)
|
||||
{
|
||||
case 0:
|
||||
return this.crystalBody;
|
||||
case 1:
|
||||
return this.crystalLabel;
|
||||
}
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
this.setHasSavedCoordinates(itemStack, false);
|
||||
player.addChatComponentMessage(new ChatComponentText("Clearing saved container..."));
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
} 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 IReagentHandler))
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
IReagentHandler relay = (IReagentHandler) tile;
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN);
|
||||
if (infos != null)
|
||||
{
|
||||
List<Reagent> reagentList = new LinkedList();
|
||||
for (ReagentContainerInfo info : infos)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
ReagentStack reagentStack = info.reagent;
|
||||
if (reagentStack != null)
|
||||
{
|
||||
Reagent reagent = reagentStack.reagent;
|
||||
if (reagent != null)
|
||||
{
|
||||
reagentList.add(reagent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reagent pastReagent = this.getReagent(itemStack);
|
||||
|
||||
if (reagentList.size() <= 0)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
int reagentLocation = -1;
|
||||
|
||||
reagentLocation = reagentList.indexOf(pastReagent);
|
||||
|
||||
if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size())
|
||||
{
|
||||
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
|
||||
} else
|
||||
{
|
||||
this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (this.getHasSavedCoordinates(itemStack))
|
||||
{
|
||||
Int3 coords = this.getCoordinates(itemStack);
|
||||
int dimension = this.getDimension(itemStack);
|
||||
|
||||
if (coords == null)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Linked container is either too far or is in a different dimension."));
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
|
||||
if (!(pastTile instanceof TEReagentConduit))
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Can no longer find linked container."));
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
Reagent reagent = this.getReagent(itemStack);
|
||||
|
||||
if (reagent == null)
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
TEReagentConduit pastRelay = (TEReagentConduit) pastTile;
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
pastRelay.removeReagentDestinationViaActual(reagent, x, y, z);
|
||||
} else
|
||||
{
|
||||
if (pastRelay.addReagentDestinationViaActual(reagent, x, y, z))
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Container is now linked. Transmitting: " + reagent.name));
|
||||
} else
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Linked container has no connections remaining!"));
|
||||
}
|
||||
}
|
||||
world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
|
||||
} else
|
||||
{
|
||||
int dimension = world.provider.dimensionId;
|
||||
|
||||
this.setDimension(itemStack, dimension);
|
||||
this.setCoordinates(itemStack, new Int3(x, y, z));
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText("Linking to selected container."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public void setCoordinates(ItemStack stack, Int3 coords)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
coords.writeToNBT(tag);
|
||||
|
||||
this.setHasSavedCoordinates(stack, true);
|
||||
}
|
||||
|
||||
public void setDimension(ItemStack stack, int dimension)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger("dimension", dimension);
|
||||
}
|
||||
|
||||
public Int3 getCoordinates(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return Int3.readFromNBT(tag);
|
||||
}
|
||||
|
||||
public int getDimension(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getInteger("dimension");
|
||||
}
|
||||
|
||||
public void setHasSavedCoordinates(ItemStack stack, boolean flag)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setBoolean("hasSavedCoordinates", flag);
|
||||
}
|
||||
|
||||
public boolean getHasSavedCoordinates(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getBoolean("hasSavedCoordinates");
|
||||
}
|
||||
|
||||
public Reagent getReagent(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return ReagentRegistry.getReagentForKey(tag.getString("reagent"));
|
||||
}
|
||||
|
||||
public void setReagent(ItemStack stack, Reagent reagent)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString("reagent", ReagentRegistry.getKeyForReagent(reagent));
|
||||
}
|
||||
|
||||
public void setReagentWithNotification(ItemStack stack, Reagent reagent, EntityPlayer player)
|
||||
{
|
||||
this.setReagent(stack, reagent);
|
||||
|
||||
if (reagent != null)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Attuned Crystal now set to: " + reagent.name));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.energy;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDestinationClearer extends Item implements IReagentManipulator
|
||||
{
|
||||
public ItemDestinationClearer()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:TankClearer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to clear the destination");
|
||||
par3List.add("list for an alchemy container");
|
||||
}
|
||||
|
||||
@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 itemStack;
|
||||
} 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 TEReagentConduit))
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
TEReagentConduit relay = (TEReagentConduit) tile;
|
||||
|
||||
relay.reagentTargetList.clear();
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText("Destination list now cleared."));
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.energy;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.*;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTankSegmenter extends Item implements IReagentManipulator
|
||||
{
|
||||
public IIcon crystalBody;
|
||||
public IIcon crystalLabel;
|
||||
|
||||
public ItemTankSegmenter()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.hasSubtypes = true;
|
||||
this.maxStackSize = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
Reagent reagent = this.getReagent(stack);
|
||||
String name = super.getItemStackDisplayName(stack);
|
||||
if (reagent != null)
|
||||
{
|
||||
name = name + " (" + reagent.name + ")";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to designate which");
|
||||
par3List.add("reagents can go into a container");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
Reagent reagent = this.getReagent(par1ItemStack);
|
||||
if (reagent != null)
|
||||
{
|
||||
par3List.add("Currently selected reagent: " + reagent.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.crystalBody = iconRegister.registerIcon("AlchemicalWizardry:TankSegmenter1");
|
||||
this.crystalLabel = iconRegister.registerIcon("AlchemicalWizardry:TankSegmenter2");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack stack, int pass)
|
||||
{
|
||||
switch (pass)
|
||||
{
|
||||
case 0:
|
||||
return 256 * (256 * 255 + 255) + 255;
|
||||
case 1:
|
||||
Reagent reagent = this.getReagent(stack);
|
||||
if (reagent != null)
|
||||
{
|
||||
return (reagent.getColourRed() * 256 * 256 + reagent.getColourGreen() * 256 + reagent.getColourBlue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 256 * (256 * 255 + 255) + 255;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses(int meta)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int pass)
|
||||
{
|
||||
switch (pass)
|
||||
{
|
||||
case 0:
|
||||
return this.crystalBody;
|
||||
case 1:
|
||||
return this.crystalLabel;
|
||||
}
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@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 itemStack;
|
||||
} 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 ISegmentedReagentHandler))
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
ISegmentedReagentHandler reagentHandler = (ISegmentedReagentHandler) tile;
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
ReagentContainerInfo[] infos = reagentHandler.getContainerInfo(ForgeDirection.UNKNOWN);
|
||||
if (infos != null)
|
||||
{
|
||||
List<Reagent> reagentList = new LinkedList();
|
||||
for (ReagentContainerInfo info : infos)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
ReagentStack reagentStack = info.reagent;
|
||||
if (reagentStack != null)
|
||||
{
|
||||
Reagent reagent = reagentStack.reagent;
|
||||
if (reagent != null)
|
||||
{
|
||||
reagentList.add(reagent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reagent pastReagent = this.getReagent(itemStack);
|
||||
boolean goForNext = false;
|
||||
boolean hasFound = false;
|
||||
for (Reagent reagent : reagentList)
|
||||
{
|
||||
if (goForNext)
|
||||
{
|
||||
goForNext = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (reagent == pastReagent)
|
||||
{
|
||||
goForNext = true;
|
||||
hasFound = true;
|
||||
}
|
||||
}
|
||||
if (hasFound)
|
||||
{
|
||||
if (goForNext)
|
||||
{
|
||||
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (reagentList.size() >= 1)
|
||||
{
|
||||
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
Reagent reagent = this.getReagent(itemStack);
|
||||
if (reagent == null)
|
||||
{
|
||||
//TODO: Send message that "All are wiped"
|
||||
reagentHandler.getAttunedTankMap().clear();
|
||||
return itemStack;
|
||||
}
|
||||
int totalTankSize = reagentHandler.getNumberOfTanks();
|
||||
int numberAssigned = reagentHandler.getTanksTunedToReagent(reagent) + 1;
|
||||
|
||||
if (numberAssigned > totalTankSize)
|
||||
{
|
||||
numberAssigned = 0;
|
||||
}
|
||||
|
||||
player.addChatComponentMessage(new ChatComponentText("Tank now has " + numberAssigned + " tank(s) set to: " + reagent.name));
|
||||
|
||||
reagentHandler.setTanksTunedToReagent(reagent, numberAssigned);
|
||||
}
|
||||
} else if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.MISS)
|
||||
{
|
||||
this.setReagent(itemStack, null);
|
||||
}
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public Reagent getReagent(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return ReagentRegistry.getReagentForKey(tag.getString("reagent"));
|
||||
}
|
||||
|
||||
public void setReagent(ItemStack stack, Reagent reagent)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString("reagent", ReagentRegistry.getKeyForReagent(reagent));
|
||||
}
|
||||
|
||||
public void setReagentWithNotification(ItemStack stack, Reagent reagent, EntityPlayer player)
|
||||
{
|
||||
this.setReagent(stack, reagent);
|
||||
|
||||
if (reagent != null)
|
||||
{
|
||||
player.addChatComponentMessage(new ChatComponentText("Tank Segmenter now set to: " + reagent.name));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.forestry;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBloodFrame extends EnergyItems //implements IHiveFrame
|
||||
{
|
||||
public ItemBloodFrame()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(10);
|
||||
setEnergyUsed(3000);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Stirs bees into a frenzy.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodFrame");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par1ItemStack.getItemDamage() > 0)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() - 1);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/**TODO Bee Stuff
|
||||
@Override public float getTerritoryModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0.0001f;
|
||||
}
|
||||
|
||||
@Override public float getProductionModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public float getFloweringModifier(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override public float getGeneticDecay(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override public boolean isSealed()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean isSelfLighted()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean isSunlightSimulated()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean isHellish()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
if(EnergyItems.canSyphonInContainer(frame, getEnergyUsed()*wear))
|
||||
{
|
||||
EnergyItems.syphonWhileInContainer(frame, getEnergyUsed()*wear);
|
||||
return frame;
|
||||
}else
|
||||
{
|
||||
frame.setItemDamage(frame.getItemDamage() + wear);
|
||||
if(frame.getItemDamage()>=frame.getMaxDamage())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,408 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityPotion;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class AlchemyFlask extends Item
|
||||
{
|
||||
private int maxPotionAmount = 20;
|
||||
|
||||
public AlchemyFlask()
|
||||
{
|
||||
super();
|
||||
this.setMaxDamage(8);
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:PotionFlask");
|
||||
}
|
||||
|
||||
public static ArrayList<AlchemyPotionHelper> getEffects(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("CustomFlaskEffects"))
|
||||
{
|
||||
ArrayList<AlchemyPotionHelper> arraylist = new ArrayList();
|
||||
NBTTagList nbttaglist = par1ItemStack.getTagCompound().getTagList("CustomFlaskEffects", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
|
||||
arraylist.add(AlchemyPotionHelper.readEffectFromNBT(nbttagcompound));
|
||||
}
|
||||
return arraylist;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<PotionEffect> getPotionEffects(ItemStack par1ItemStack)
|
||||
{
|
||||
ArrayList<AlchemyPotionHelper> list = AlchemyFlask.getEffects(par1ItemStack);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
ArrayList<PotionEffect> newList = new ArrayList();
|
||||
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
newList.add(aph.getPotionEffect());
|
||||
}
|
||||
|
||||
return newList;
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEffects(ItemStack par1ItemStack, List<AlchemyPotionHelper> list)
|
||||
{
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
nbttaglist.appendTag(AlchemyPotionHelper.setEffectToNBT(aph));
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setTag("CustomFlaskEffects", nbttaglist);
|
||||
}
|
||||
|
||||
public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1);
|
||||
}
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
ArrayList<AlchemyPotionHelper> list = this.getEffects(par1ItemStack);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
PotionEffect pe = aph.getPotionEffect();
|
||||
|
||||
if (pe != null)
|
||||
{
|
||||
//if(pe.get)
|
||||
par3EntityPlayer.addPotionEffect(pe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack)
|
||||
{
|
||||
if (this.isPotionThrowable(par1ItemStack))
|
||||
{
|
||||
return EnumAction.none;
|
||||
}
|
||||
|
||||
return EnumAction.drink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par1ItemStack.getItemDamage() < par1ItemStack.getMaxDamage())
|
||||
{
|
||||
if (this.isPotionThrowable(par1ItemStack))
|
||||
{
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
EntityPotion entityPotion = this.getEntityPotion(par1ItemStack, par2World, par3EntityPlayer);
|
||||
|
||||
if (entityPotion != null)
|
||||
{
|
||||
float velocityChange = 2.0f;
|
||||
entityPotion.motionX *= velocityChange;
|
||||
entityPotion.motionY *= velocityChange;
|
||||
entityPotion.motionZ *= velocityChange;
|
||||
par2World.spawnEntityInWorld(entityPotion);
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getItemDamage() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public void setConcentrationOfPotion(ItemStack par1ItemStack, int potionID, int concentration)
|
||||
{
|
||||
ArrayList<AlchemyPotionHelper> list = this.getEffects(par1ItemStack);
|
||||
if (list != null)
|
||||
{
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
if (aph.getPotionID() == potionID)
|
||||
{
|
||||
aph.setConcentration(concentration);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.setEffects(par1ItemStack, list);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDurationFactorOfPotion(ItemStack par1ItemStack, int potionID, int durationFactor)
|
||||
{
|
||||
ArrayList<AlchemyPotionHelper> list = this.getEffects(par1ItemStack);
|
||||
if (list != null)
|
||||
{
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
if (aph.getPotionID() == potionID)
|
||||
{
|
||||
aph.setDurationFactor(durationFactor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.setEffects(par1ItemStack, list);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasPotionEffect(ItemStack par1ItemStack, int potionID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getNumberOfPotionEffects(ItemStack par1ItemStack)
|
||||
{
|
||||
if (getEffects(par1ItemStack) != null)
|
||||
{
|
||||
return getEffects(par1ItemStack).size();
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addPotionEffect(ItemStack par1ItemStack, int potionID, int tickDuration)
|
||||
{
|
||||
int i = 0;
|
||||
ArrayList<AlchemyPotionHelper> list = this.getEffects(par1ItemStack);
|
||||
if (list != null)
|
||||
{
|
||||
for (AlchemyPotionHelper aph : list)
|
||||
{
|
||||
if (aph.getPotionID() == potionID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0));
|
||||
this.setEffects(par1ItemStack, list);
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
list = new ArrayList();
|
||||
list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0));
|
||||
this.setEffects(par1ItemStack, list);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Swigs left: " + (par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage()) + "/" + par1ItemStack.getMaxDamage());
|
||||
|
||||
if (this.isPotionThrowable(par1ItemStack))
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "CAUTION: Contents are throwable");
|
||||
}
|
||||
|
||||
List list1 = AlchemyFlask.getPotionEffects(par1ItemStack);
|
||||
HashMultimap hashmultimap = HashMultimap.create();
|
||||
Iterator iterator;
|
||||
|
||||
if (list1 != null && !list1.isEmpty())
|
||||
{
|
||||
iterator = list1.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
PotionEffect potioneffect = (PotionEffect) iterator.next();
|
||||
String s = StatCollector.translateToLocal(potioneffect.getEffectName()).trim();
|
||||
Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
|
||||
Map map = potion.func_111186_k();
|
||||
|
||||
if (map != null && map.size() > 0)
|
||||
{
|
||||
Iterator iterator1 = map.entrySet().iterator();
|
||||
|
||||
while (iterator1.hasNext())
|
||||
{
|
||||
Entry entry = (Entry) iterator1.next();
|
||||
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
|
||||
AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation());
|
||||
hashmultimap.put(((IAttribute) entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1);
|
||||
}
|
||||
}
|
||||
|
||||
if (potioneffect.getAmplifier() > 0)
|
||||
{
|
||||
s = s + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim();
|
||||
}
|
||||
|
||||
if (potioneffect.getDuration() > 20)
|
||||
{
|
||||
s = s + " (" + Potion.getDurationString(potioneffect) + ")";
|
||||
}
|
||||
|
||||
if (potion.isBadEffect())
|
||||
{
|
||||
par3List.add(EnumChatFormatting.RED + s);
|
||||
} else
|
||||
{
|
||||
par3List.add(EnumChatFormatting.GRAY + s);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
String s1 = StatCollector.translateToLocal("potion.empty").trim();
|
||||
par3List.add(EnumChatFormatting.GRAY + s1);
|
||||
}
|
||||
|
||||
if (!hashmultimap.isEmpty())
|
||||
{
|
||||
par3List.add("");
|
||||
par3List.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank"));
|
||||
iterator = hashmultimap.entries().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entry entry1 = (Entry) iterator.next();
|
||||
AttributeModifier attributemodifier2 = (AttributeModifier) entry1.getValue();
|
||||
double d0 = attributemodifier2.getAmount();
|
||||
double d1;
|
||||
|
||||
if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2)
|
||||
{
|
||||
d1 = attributemodifier2.getAmount();
|
||||
} else
|
||||
{
|
||||
d1 = attributemodifier2.getAmount() * 100.0D;
|
||||
}
|
||||
|
||||
if (d0 > 0.0D)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[]{ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String) entry1.getKey())}));
|
||||
} else if (d0 < 0.0D)
|
||||
{
|
||||
d1 *= -1.0D;
|
||||
par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[]{ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String) entry1.getKey())}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPotionThrowable(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().getBoolean("throwable"))
|
||||
{
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsPotionThrowable(boolean flag, ItemStack par1ItemStack)
|
||||
{
|
||||
if (!par1ItemStack.hasTagCompound())
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setBoolean("throwable", flag);
|
||||
}
|
||||
|
||||
public EntityPotion getEntityPotion(ItemStack par1ItemStack, World worldObj, EntityLivingBase entityLivingBase)
|
||||
{
|
||||
ItemStack potionStack = new ItemStack(Items.potionitem, 1, 0);
|
||||
potionStack.setTagCompound(new NBTTagCompound());
|
||||
ArrayList<PotionEffect> potionList = this.getPotionEffects(par1ItemStack);
|
||||
|
||||
if (potionList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (PotionEffect pe : potionList)
|
||||
{
|
||||
NBTTagCompound d = new NBTTagCompound();
|
||||
d.setByte("Id", (byte) pe.getPotionID());
|
||||
d.setByte("Amplifier", (byte) pe.getAmplifier());
|
||||
d.setInteger("Duration", pe.getDuration());
|
||||
d.setBoolean("Ambient", pe.getIsAmbient());
|
||||
nbttaglist.appendTag(d);
|
||||
}
|
||||
potionStack.stackTagCompound.setTag("CustomPotionEffects", nbttaglist);
|
||||
EntityPotion entityPotion = new EntityPotion(worldObj, entityLivingBase, potionStack);
|
||||
return entityPotion;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlchemyReagent extends Item
|
||||
{
|
||||
public AlchemyReagent()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
this.setMaxStackSize(64);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
if (this == ModItems.incendium)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Incendium");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.magicales)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Magicales");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.sanctus)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Sanctus");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.aether)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Aether");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.simpleCatalyst)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SimpleCatalyst");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.crepitous)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Crepitous");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.crystallos)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Crystallos");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.terrae)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Terrae");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.aquasalus)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Aquasalus");
|
||||
return;
|
||||
}
|
||||
if (this == ModItems.tennebrae)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:Tennebrae");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class AverageLengtheningCatalyst extends LengtheningCatalyst
|
||||
{
|
||||
public AverageLengtheningCatalyst()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AverageLengtheningCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class AveragePowerCatalyst extends PowerCatalyst
|
||||
{
|
||||
public AveragePowerCatalyst()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AveragePowerCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.alchemy.ICombinationalCatalyst;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class CombinationalCatalyst extends Item implements ICombinationalCatalyst
|
||||
{
|
||||
public CombinationalCatalyst()
|
||||
{
|
||||
super();
|
||||
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:CombinationalCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class EnhancedFillingAgent extends WeakFillingAgent
|
||||
{
|
||||
public EnhancedFillingAgent()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFilledAmountForPotionNumber(int potionEffects)
|
||||
{
|
||||
Random rand = new Random();
|
||||
if (potionEffects == 0)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
{
|
||||
switch (potionEffects)
|
||||
{
|
||||
case 1:
|
||||
return 6;
|
||||
|
||||
case 2:
|
||||
return 4;
|
||||
|
||||
case 3:
|
||||
return 3;
|
||||
|
||||
case 4:
|
||||
return 2;
|
||||
|
||||
case 5:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:EnhancedFillingAgent");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class GreaterLengtheningCatalyst extends LengtheningCatalyst
|
||||
{
|
||||
public GreaterLengtheningCatalyst()
|
||||
{
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:GreaterLengtheningCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class GreaterPowerCatalyst extends PowerCatalyst
|
||||
{
|
||||
public GreaterPowerCatalyst()
|
||||
{
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:GreaterPowerCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.ICatalyst;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LengtheningCatalyst extends Item implements ICatalyst
|
||||
{
|
||||
private int catalystStrength;
|
||||
|
||||
public LengtheningCatalyst(int catalystStrength)
|
||||
{
|
||||
this.catalystStrength = catalystStrength;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCatalystLevel()
|
||||
{
|
||||
return catalystStrength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcentration()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class MundaneLengtheningCatalyst extends LengtheningCatalyst
|
||||
{
|
||||
public MundaneLengtheningCatalyst()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:MundaneLengtheningCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class MundanePowerCatalyst extends PowerCatalyst
|
||||
{
|
||||
public MundanePowerCatalyst()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:MundanePowerCatalyst");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.ICatalyst;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PowerCatalyst extends Item implements ICatalyst
|
||||
{
|
||||
private int catalystStrength;
|
||||
|
||||
public PowerCatalyst(int catalystStrength)
|
||||
{
|
||||
super();
|
||||
this.catalystStrength = catalystStrength;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCatalystLevel()
|
||||
{
|
||||
return catalystStrength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcentration()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.IBindingAgent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StandardBindingAgent extends Item implements IBindingAgent
|
||||
{
|
||||
public StandardBindingAgent()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSuccessRateForPotionNumber(int potions)
|
||||
{
|
||||
return (float) Math.pow(0.65, potions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:StandardBindingAgent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class StandardFillingAgent extends WeakFillingAgent
|
||||
{
|
||||
public StandardFillingAgent()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFilledAmountForPotionNumber(int potionEffects)
|
||||
{
|
||||
if (potionEffects == 0)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (potionEffects >= 1 && potionEffects <= 3)
|
||||
{
|
||||
return (int) (4 * (Math.pow(0.5f, potionEffects - 1) + 0.01f));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:StandardFillingAgent");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
public class WeakBindingAgent extends StandardBindingAgent
|
||||
{
|
||||
public WeakBindingAgent()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSuccessRateForPotionNumber(int potions)
|
||||
{
|
||||
return (float) Math.pow(0.4, potions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WeakBindingAgent");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.potion;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.AlchemyRecipeRegistry;
|
||||
import WayofTime.alchemicalWizardry.common.IFillingAgent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class WeakFillingAgent extends Item implements IFillingAgent
|
||||
{
|
||||
public WeakFillingAgent()
|
||||
{
|
||||
super();
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFilledAmountForPotionNumber(int potionEffects)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
||||
if (potionEffects == 0)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (potionEffects == 1 || potionEffects == 2)
|
||||
{
|
||||
if (rand.nextFloat() > 0.5f)
|
||||
{
|
||||
return (4 - potionEffects);
|
||||
} else
|
||||
{
|
||||
return 3 - potionEffects;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WeakFillingAgent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used in alchemy");
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
ItemStack[] recipe = AlchemyRecipeRegistry.getRecipeForItemStack(par1ItemStack);
|
||||
|
||||
if (recipe != null)
|
||||
{
|
||||
par3List.add(EnumChatFormatting.BLUE + "Recipe:");
|
||||
|
||||
for (ItemStack item : recipe)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("" + item.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par3List.add("-Press " + EnumChatFormatting.BLUE + "shift" + EnumChatFormatting.GRAY + " for Recipe-");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AirSigil extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
private int energyUsed;
|
||||
|
||||
public AirSigil()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
//setMaxDamage(1000);
|
||||
setEnergyUsed(50);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("I feel lighter already...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:AirSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
Vec3 vec = par3EntityPlayer.getLookVec();
|
||||
double wantedVelocity = 1.7;
|
||||
|
||||
if (par3EntityPlayer.isPotionActive(AlchemicalWizardry.customPotionBoost))
|
||||
{
|
||||
int i = par3EntityPlayer.getActivePotionEffect(AlchemicalWizardry.customPotionBoost).getAmplifier();
|
||||
wantedVelocity += (1 + i) * (0.35);
|
||||
}
|
||||
|
||||
par3EntityPlayer.motionX = vec.xCoord * wantedVelocity;
|
||||
par3EntityPlayer.motionY = vec.yCoord * wantedVelocity;
|
||||
par3EntityPlayer.motionZ = vec.zCoord * wantedVelocity;
|
||||
par2World.playSoundEffect((double) ((float) par3EntityPlayer.posX + 0.5F), (double) ((float) par3EntityPlayer.posY + 0.5F), (double) ((float) par3EntityPlayer.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (par2World.rand.nextFloat() - par2World.rand.nextFloat()) * 0.8F);
|
||||
par3EntityPlayer.fallDistance = 0;
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player,
|
||||
ItemStack thisItemStack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 50;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentContainerInfo;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBindable;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IReagentManipulator;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DivinationSigil extends Item implements ArmourUpgrade, IReagentManipulator, IBindable
|
||||
{
|
||||
public DivinationSigil()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:DivinationSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Peer into the soul to");
|
||||
par3List.add("get the current essence");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.worldObj.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
String ownerName = itemTag.getString("ownerName");
|
||||
int currentEssence = EnergyItems.getCurrentEssence(ownerName);
|
||||
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
par3EntityPlayer.addChatMessage(new ChatComponentText("Current Essence: " + EnergyItems.getCurrentEssence(ownerName) + "LP"));
|
||||
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
TileEntity tile = par2World.getTileEntity(x, y, z);
|
||||
|
||||
if (!(tile instanceof IReagentHandler))
|
||||
{
|
||||
par3EntityPlayer.addChatMessage(new ChatComponentText("Current Essence: " + EnergyItems.getCurrentEssence(ownerName) + "LP"));
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
IReagentHandler relay = (IReagentHandler) tile;
|
||||
|
||||
ReagentContainerInfo[] infoList = relay.getContainerInfo(ForgeDirection.UNKNOWN);
|
||||
if (infoList != null)
|
||||
{
|
||||
for (ReagentContainerInfo info : infoList)
|
||||
{
|
||||
if (info != null && info.reagent != null && info.reagent.reagent != null)
|
||||
{
|
||||
par3EntityPlayer.addChatComponentMessage(new ChatComponentText("Reagent: " + ReagentRegistry.getKeyForReagent(info.reagent.reagent) + ", Amount: " + info.reagent.amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 400, 9, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
||||
import WayofTime.alchemicalWizardry.common.entity.projectile.EntityBloodLightProjectile;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBloodLightSigil extends EnergyItems implements IHolding
|
||||
{
|
||||
private int tickDelay = 100;
|
||||
|
||||
public ItemBloodLightSigil()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(10);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("I see a light!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BloodLightSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
|
||||
|
||||
if (par3World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (par7 == 0 && par3World.isAirBlock(par4, par5 - 1, par6))
|
||||
{
|
||||
par3World.setBlock(par4, par5 - 1, par6, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
if (par7 == 1 && par3World.isAirBlock(par4, par5 + 1, par6))
|
||||
{
|
||||
par3World.setBlock(par4, par5 + 1, par6, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
if (par7 == 2 && par3World.isAirBlock(par4, par5, par6 - 1))
|
||||
{
|
||||
par3World.setBlock(par4, par5, par6 - 1, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
if (par7 == 3 && par3World.isAirBlock(par4, par5, par6 + 1))
|
||||
{
|
||||
par3World.setBlock(par4, par5, par6 + 1, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
if (par7 == 4 && par3World.isAirBlock(par4 - 1, par5, par6))
|
||||
{
|
||||
par3World.setBlock(par4 - 1, par5, par6, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
if (par7 == 5 && par3World.isAirBlock(par4 + 1, par5, par6))
|
||||
{
|
||||
par3World.setBlock(par4 + 1, par5, par6, ModBlocks.blockBloodLight);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed() * 5);
|
||||
|
||||
if (!par2World.isRemote)
|
||||
{
|
||||
par2World.spawnEntityInWorld(new EntityBloodLightProjectile(par2World, par3EntityPlayer, 10));
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,785 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.Int3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MaterialLiquid;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFluidSigil extends Item implements IFluidContainerItem
|
||||
{
|
||||
private int capacity = 128 * 1000;
|
||||
private static final int STATE_SYPHON = 0;
|
||||
private static final int STATE_FORCE_SYPHON = 1;
|
||||
private static final int STATE_PLACE = 2;
|
||||
private static final int STATE_INPUT_TANK = 3;
|
||||
private static final int STATE_DRAIN_TANK = 4;
|
||||
private static final int STATE_BEAST_DRAIN = 5;
|
||||
private static final int maxNumOfStates = 6;
|
||||
|
||||
public ItemFluidSigil()
|
||||
{
|
||||
super();
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A sigil with a lovely affinity for fluids");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
switch (this.getActionState(par1ItemStack))
|
||||
{
|
||||
case STATE_SYPHON:
|
||||
par3List.add("Syphoning Mode");
|
||||
break;
|
||||
case STATE_FORCE_SYPHON:
|
||||
par3List.add("Force-syphon Mode");
|
||||
break;
|
||||
case STATE_PLACE:
|
||||
par3List.add("Fluid Placement Mode");
|
||||
break;
|
||||
case STATE_INPUT_TANK:
|
||||
par3List.add("Fill Tank Mode");
|
||||
break;
|
||||
case STATE_DRAIN_TANK:
|
||||
par3List.add("Drain Tank Mode");
|
||||
break;
|
||||
case STATE_BEAST_DRAIN:
|
||||
par3List.add("Beast Mode");
|
||||
break;
|
||||
}
|
||||
|
||||
FluidStack fluid = this.getFluid(par1ItemStack);
|
||||
if (fluid != null && fluid.amount > 0)
|
||||
{
|
||||
String str = fluid.getFluid().getName();
|
||||
int amount = fluid.amount;
|
||||
|
||||
par3List.add("" + amount + "mB of " + str);
|
||||
} else
|
||||
{
|
||||
par3List.add("Empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WaterSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
int curState = this.cycleActionState(par1ItemStack);
|
||||
this.sendMessageViaState(curState, par3EntityPlayer);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
switch (this.getActionState(par1ItemStack))
|
||||
{
|
||||
case STATE_SYPHON:
|
||||
return this.fillItemFromWorld(par1ItemStack, par2World, par3EntityPlayer, false);
|
||||
case STATE_FORCE_SYPHON:
|
||||
return this.fillItemFromWorld(par1ItemStack, par2World, par3EntityPlayer, true);
|
||||
case STATE_PLACE:
|
||||
return this.emptyItemToWorld(par1ItemStack, par2World, par3EntityPlayer);
|
||||
case STATE_INPUT_TANK:
|
||||
return this.fillSelectedTank(par1ItemStack, par2World, par3EntityPlayer);
|
||||
case STATE_DRAIN_TANK:
|
||||
return this.drainSelectedTank(par1ItemStack, par2World, par3EntityPlayer);
|
||||
case STATE_BEAST_DRAIN:
|
||||
return this.fillItemFromBeastWorld(par1ItemStack, par2World, par3EntityPlayer, true);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
public int getActionState(ItemStack item)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return item.stackTagCompound.getInteger("actionState");
|
||||
}
|
||||
|
||||
public void setActionState(ItemStack item, int actionState)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
item.stackTagCompound.setInteger("actionState", actionState);
|
||||
}
|
||||
|
||||
public int cycleActionState(ItemStack item)
|
||||
{
|
||||
int state = this.getActionState(item);
|
||||
|
||||
state++;
|
||||
|
||||
if (state >= maxNumOfStates)
|
||||
{
|
||||
state = 0;
|
||||
}
|
||||
|
||||
this.setActionState(item, state);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
public void sendMessageViaState(int state, EntityPlayer player)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
ChatComponentText cmc = new ChatComponentText("");
|
||||
switch (state)
|
||||
{
|
||||
case STATE_SYPHON:
|
||||
cmc.appendText("Now in Syphoning Mode");
|
||||
break;
|
||||
case STATE_FORCE_SYPHON:
|
||||
cmc.appendText("Now in Force-syphon Mode");
|
||||
break;
|
||||
case STATE_PLACE:
|
||||
cmc.appendText("Now in Fluid Placement Mode");
|
||||
break;
|
||||
case STATE_INPUT_TANK:
|
||||
cmc.appendText("Now in Fill Tank Mode");
|
||||
break;
|
||||
case STATE_DRAIN_TANK:
|
||||
cmc.appendText("Now in Drain Tank Mode");
|
||||
break;
|
||||
case STATE_BEAST_DRAIN:
|
||||
cmc.appendText("Now in Beast Mode");
|
||||
break;
|
||||
}
|
||||
player.addChatComponentMessage(cmc);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack fillItemFromBeastWorld(ItemStack container, World world, EntityPlayer player, boolean forceFill)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return container;
|
||||
}
|
||||
int range = 5;
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
boolean flag = true;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return container;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
|
||||
if (!world.canMineBlock(player, x, y, z))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(x, y, z, movingobjectposition.sideHit, container))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
boolean[][][] boolList = new boolean[range * 2 + 1][range * 2 + 1][range * 2 + 1];
|
||||
|
||||
for (int i = 0; i < 2 * range + 1; i++)
|
||||
{
|
||||
for (int j = 0; j < 2 * range + 1; j++)
|
||||
{
|
||||
for (int k = 0; k < 2 * range + 1; k++)
|
||||
{
|
||||
boolList[i][j][k] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Int3> positionList = new ArrayList();
|
||||
|
||||
boolList[range][range][range] = true;
|
||||
positionList.add(new Int3(range, range, range));
|
||||
boolean isReady = false;
|
||||
|
||||
while (!isReady)
|
||||
{
|
||||
isReady = true;
|
||||
|
||||
for (int i = 0; i < 2 * range + 1; i++)
|
||||
{
|
||||
for (int j = 0; j < 2 * range + 1; j++)
|
||||
{
|
||||
for (int k = 0; k < 2 * range + 1; k++)
|
||||
{
|
||||
if (boolList[i][j][k])
|
||||
{
|
||||
if (i - 1 >= 0 && !boolList[i - 1][j][k])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i - 1][j][k] = true;
|
||||
positionList.add(new Int3(i - 1, j, k));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (j - 1 >= 0 && !boolList[i][j - 1][k])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i][j - 1][k] = true;
|
||||
positionList.add(new Int3(i, j - 1, k));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (k - 1 >= 0 && !boolList[i][j][k - 1])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i][j][k - 1] = true;
|
||||
positionList.add(new Int3(i, j, k - 1));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (i + 1 <= 2 * range && !boolList[i + 1][j][k])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i + 1][j][k] = true;
|
||||
positionList.add(new Int3(i + 1, j, k));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (j + 1 <= 2 * range && !boolList[i][j + 1][k])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i][j + 1][k] = true;
|
||||
positionList.add(new Int3(i, j + 1, k));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (k + 1 <= 2 * range && !boolList[i][j][k + 1])
|
||||
{
|
||||
Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
boolList[i][j][k + 1] = true;
|
||||
positionList.add(new Int3(i, j, k + 1));
|
||||
isReady = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Int3 pos : positionList)
|
||||
{
|
||||
int i = pos.xCoord;
|
||||
int j = pos.yCoord;
|
||||
int k = pos.zCoord;
|
||||
|
||||
if (!boolList[i][j][k])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (world.getBlock(x + i - range, y + j - range, z + k - range) != null && world.getBlock(x + i - range, y + j - range, z + k - range).getMaterial() instanceof MaterialLiquid)
|
||||
{
|
||||
//world.setBlockToAir(x+i-range, y+j-range, z+k-range);
|
||||
Block block = world.getBlock(x + i - range, y + j - range, z + k - range);
|
||||
if (block == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
System.out.println("x: " + (i - range) + " y: " + (j - range) + " z: " + (k - range));
|
||||
|
||||
|
||||
if (fluid == null || world.getBlockMetadata(x + i - range, y + j - range, z + k - range) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
FluidStack fillStack = new FluidStack(fluid, 1000);
|
||||
|
||||
int amount = this.fill(container, fillStack, false);
|
||||
|
||||
if ((amount > 0 && forceFill) || (amount >= 1000 && !forceFill))
|
||||
{
|
||||
{
|
||||
world.setBlockToAir(x + i - range, y + j - range, z + k - range);
|
||||
|
||||
}
|
||||
|
||||
this.fill(container, new FluidStack(fluid, 1000), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack fillItemFromWorld(ItemStack container, World world, EntityPlayer player, boolean forceFill)
|
||||
{
|
||||
float f = 1.0F;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
boolean flag = true;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return container;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!world.canMineBlock(player, i, j, k))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
if (world.getBlock(i, j, k) != null && world.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid)
|
||||
{
|
||||
Block block = world.getBlock(i, j, k);
|
||||
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||
|
||||
if (fluid == null)
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
FluidStack fillStack = new FluidStack(fluid, 1000);
|
||||
|
||||
int amount = this.fill(container, fillStack, false);
|
||||
|
||||
if ((amount > 0 && forceFill) || (amount >= 1000 && !forceFill))
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
world.setBlockToAir(i, j, k);
|
||||
}
|
||||
|
||||
this.fill(container, new FluidStack(fluid, 1000), true);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
} else
|
||||
{
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack emptyItemToWorld(ItemStack container, World world, EntityPlayer player)
|
||||
{
|
||||
FluidStack simStack = this.drain(container, 1000, false);
|
||||
|
||||
if (simStack != null && simStack.amount >= 1000)
|
||||
{
|
||||
Block fluidBlock = simStack.getFluid().getBlock();
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
boolean flag = false;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return container;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!world.canMineBlock(player, i, j, k))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 0)
|
||||
{
|
||||
--j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 1)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 2)
|
||||
{
|
||||
--k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 3)
|
||||
{
|
||||
++k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 4)
|
||||
{
|
||||
--i;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 5)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, container))
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
if (this.tryPlaceContainedLiquid(world, fluidBlock, d0, d1, d2, i, j, k) && !player.capabilities.isCreativeMode)
|
||||
{
|
||||
this.drain(container, 1000, true);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
public boolean tryPlaceContainedLiquid(World par1World, Block block, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).func_149730_j())
|
||||
{
|
||||
return false;
|
||||
} else if ((par1World.getBlock(par8, par9, par10).getMaterial() instanceof MaterialLiquid && (par1World.getBlockMetadata(par8, par9, par10) == 0)))
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
if ((block == Blocks.water || block == Blocks.flowing_water) && par1World.provider.isHellWorld)
|
||||
{
|
||||
par1World.playSoundEffect(par2 + 0.5D, par4 + 0.5D, par6 + 0.5D, "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
par1World.spawnParticle("largesmoke", (double) par8 + Math.random(), (double) par9 + Math.random(), (double) par10 + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1World.setBlock(par8, par9, par10, block, 0, 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack fillSelectedTank(ItemStack container, World world, EntityPlayer player)
|
||||
{
|
||||
FluidStack fluid = this.getFluid(container);
|
||||
|
||||
if (fluid == null)
|
||||
{
|
||||
return container;
|
||||
}
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
boolean flag = false;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return container;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
|
||||
|
||||
this.drain(container, amount, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
public ItemStack drainSelectedTank(ItemStack container, World world, EntityPlayer player)
|
||||
{
|
||||
float f = 1.0F;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f + 1.62D - (double) player.yOffset;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
boolean flag = false;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return container;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack fluidAmount = ((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), this.getCapacity(container), false);
|
||||
|
||||
int amount = this.fill(container, fluidAmount, false);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), this.getCapacity(container), true);
|
||||
|
||||
this.fill(container, fluidAmount, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
/* IFluidContainerItem */
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack container)
|
||||
{
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack container)
|
||||
{
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ItemStack container, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill)
|
||||
{
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||
{
|
||||
return Math.min(capacity, resource.amount);
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"));
|
||||
|
||||
if (stack == null || stack.amount <= 0)
|
||||
{
|
||||
return Math.min(capacity, resource.amount);
|
||||
}
|
||||
|
||||
if (!stack.isFluidEqual(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.min(capacity - stack.amount, resource.amount);
|
||||
}
|
||||
|
||||
if (container.stackTagCompound == null)
|
||||
{
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
if (!container.stackTagCompound.hasKey("Fluid"))
|
||||
{
|
||||
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
|
||||
|
||||
if (capacity < resource.amount)
|
||||
{
|
||||
fluidTag.setInteger("Amount", capacity);
|
||||
container.stackTagCompound.setTag("Fluid", fluidTag);
|
||||
return capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag("Fluid", fluidTag);
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("Fluid");
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
|
||||
|
||||
if (stack == null || stack.amount <= 0)
|
||||
{
|
||||
NBTTagCompound fluidTag1 = resource.writeToNBT(new NBTTagCompound());
|
||||
|
||||
if (capacity < resource.amount)
|
||||
{
|
||||
fluidTag1.setInteger("Amount", capacity);
|
||||
container.stackTagCompound.setTag("Fluid", fluidTag1);
|
||||
return capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag("Fluid", fluidTag1);
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
if (!stack.isFluidEqual(resource))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int filled = capacity - stack.amount;
|
||||
if (resource.amount < filled)
|
||||
{
|
||||
stack.amount += resource.amount;
|
||||
filled = resource.amount;
|
||||
} else
|
||||
{
|
||||
stack.amount = capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag("Fluid", stack.writeToNBT(fluidTag));
|
||||
return filled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid"));
|
||||
if (stack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
stack.amount = Math.min(stack.amount, maxDrain);
|
||||
if (doDrain)
|
||||
{
|
||||
if (maxDrain >= capacity)
|
||||
{
|
||||
container.stackTagCompound.removeTag("Fluid");
|
||||
|
||||
if (container.stackTagCompound.hasNoTags())
|
||||
{
|
||||
container.stackTagCompound = null;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("Fluid");
|
||||
fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - maxDrain);
|
||||
container.stackTagCompound.setTag("Fluid", fluidTag);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSeerSigil extends Item implements IHolding, ArmourUpgrade
|
||||
{
|
||||
public ItemSeerSigil()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SeerSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("When seeing all is not enough");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.worldObj.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = par1ItemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null || itemTag.getString("ownerName").equals(""))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
String ownerName = itemTag.getString("ownerName");
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilOfEnderSeverance extends EnergyItems implements IHolding
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon activeIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
public ItemSigilOfEnderSeverance()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(200);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Put those endermen in a Dire situation!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSeverance_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSeverance_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSeverance_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
List<Entity> list = SpellHelper.getEntitiesInRange(par2World, par3Entity.posX, par3Entity.posY, par3Entity.posZ, 4.5, 4.5);
|
||||
for (Entity entity : list)
|
||||
{
|
||||
if (!entity.equals(par3Entity) && entity instanceof EntityLiving)
|
||||
{
|
||||
((EntityLiving) entity).addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionPlanarBinding.id, 5, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,265 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilOfSupression extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int tickDelay = 200;
|
||||
private int radius = 5;
|
||||
private int refresh = 100;
|
||||
|
||||
public ItemSigilOfSupression()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(400);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Better than telekinesis");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSupression_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSupression_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfSupression_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (SpellHelper.isFakePlayer(par2World, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SpellHelper.isFakePlayer(par2World, (EntityPlayer) par3Entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive") && (!par2World.isRemote))
|
||||
{
|
||||
Vec3 blockVec = SpellHelper.getEntityBlockVector(par3EntityPlayer);
|
||||
int x = (int) blockVec.xCoord;
|
||||
int y = (int) blockVec.yCoord;
|
||||
int z = (int) blockVec.zCoord;
|
||||
|
||||
for (int i = -radius; i <= radius; i++)
|
||||
{
|
||||
for (int j = -radius; j <= radius; j++)
|
||||
{
|
||||
for (int k = -radius; k <= radius; k++)
|
||||
{
|
||||
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = par2World.getBlock(x + i, y + j, z + k);
|
||||
|
||||
|
||||
if (SpellHelper.isBlockFluid(block))
|
||||
{
|
||||
if (par2World.getTileEntity(x + i, y + j, z + k) != null)
|
||||
{
|
||||
par2World.setBlockToAir(x + i, y + j, z + k);
|
||||
}
|
||||
TESpectralContainer.createSpectralBlockAtLocation(par2World, x + i, y + j, z + k, refresh);
|
||||
} else
|
||||
{
|
||||
TileEntity tile = par2World.getTileEntity(x + i, y + j, z + k);
|
||||
if (tile instanceof TESpectralContainer)
|
||||
{
|
||||
((TESpectralContainer) tile).resetDuration(refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
Vec3 blockVec = SpellHelper.getEntityBlockVector(player);
|
||||
int x = (int) blockVec.xCoord;
|
||||
int y = (int) blockVec.yCoord;
|
||||
int z = (int) blockVec.zCoord;
|
||||
|
||||
for (int i = -radius; i <= radius; i++)
|
||||
{
|
||||
for (int j = -radius; j <= radius; j++)
|
||||
{
|
||||
for (int k = -radius; k <= radius; k++)
|
||||
{
|
||||
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x + i, y + j, z + k);
|
||||
|
||||
|
||||
if (SpellHelper.isBlockFluid(block))
|
||||
{
|
||||
if (world.getTileEntity(x + i, y + j, z + k) != null)
|
||||
{
|
||||
world.setBlockToAir(x + i, y + j, z + k);
|
||||
}
|
||||
TESpectralContainer.createSpectralBlockAtLocation(world, x + i, y + j, z + k, refresh);
|
||||
} else
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x + i, y + j, z + k);
|
||||
if (tile instanceof TESpectralContainer)
|
||||
{
|
||||
((TESpectralContainer) tile).resetDuration(refresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,262 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyBattery;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LavaSigil extends ItemBucket implements ArmourUpgrade
|
||||
{
|
||||
/**
|
||||
* field for checking if the bucket has been filled.
|
||||
*/
|
||||
private Block isFull = Blocks.lava;
|
||||
private int energyUsed;
|
||||
|
||||
public LavaSigil()
|
||||
{
|
||||
super(Blocks.lava);
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(1000);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:LavaSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
ItemStack copiedStack = itemStack.copy();
|
||||
copiedStack.setItemDamage(copiedStack.getItemDamage() + getEnergyUsed());
|
||||
copiedStack.stackSize = 1;
|
||||
return copiedStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Contact with liquid is");
|
||||
par3List.add("highly unrecommended.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) f;
|
||||
double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) f + 1.62D - (double) par3EntityPlayer.yOffset;
|
||||
double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) f;
|
||||
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
TileEntity tile = par2World.getTileEntity(i, j, k);
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
if (movingobjectposition.sideHit == 0)
|
||||
{
|
||||
--j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 1)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 2)
|
||||
{
|
||||
--k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 3)
|
||||
{
|
||||
++k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 4)
|
||||
{
|
||||
--i;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 5)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to place the liquid contained inside the bucket.
|
||||
*/
|
||||
public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
||||
{
|
||||
return false;
|
||||
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.lava || par1World.getBlock(par8, par9, par10) == Blocks.flowing_lava) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
par1World.setBlock(par8, par9, par10, this.isFull, 0, 3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
this.energyUsed = par1int;
|
||||
}
|
||||
|
||||
protected int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
protected boolean syphonBatteries(ItemStack ist, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
boolean usedBattery = false;
|
||||
IInventory inventory = player.inventory;
|
||||
|
||||
for (int slot = 0; slot < inventory.getSizeInventory(); slot++)
|
||||
{
|
||||
ItemStack stack = inventory.getStackInSlot(slot);
|
||||
|
||||
if (stack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (stack.getItem() instanceof EnergyBattery && !usedBattery)
|
||||
{
|
||||
if (stack.getItemDamage() <= stack.getMaxDamage() - damageToBeDone)
|
||||
{
|
||||
stack.setItemDamage(stack.getItemDamage() + damageToBeDone);
|
||||
usedBattery = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!usedBattery)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 9, true));
|
||||
player.extinguish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfElementalAffinity extends EnergyItems
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon activeIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
public SigilOfElementalAffinity()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(200);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Perfect for a fire-breathing fish");
|
||||
par3List.add("who is afraid of heights!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfTheFastMiner");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:ElementalSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:ElementalSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true));
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true));
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3EntityPlayer.fallDistance = 0;
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 0, true));
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 2, 0, true));
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,298 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfGrowth extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int tickDelay = 100;
|
||||
|
||||
public SigilOfGrowth()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(150);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Who needs a green thumb when");
|
||||
par3List.add("you have a green slate?");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:GrowthSigil_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:GrowthSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:GrowthSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par2EntityPlayer);
|
||||
|
||||
if (applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer))
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par2EntityPlayer, getEnergyUsed());
|
||||
|
||||
if (par3World.isRemote)
|
||||
{
|
||||
par3World.playAuxSFX(2005, par4, par5, par6, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par2World.isRemote)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed());
|
||||
}
|
||||
int range = 5;
|
||||
int verticalRange = 2;
|
||||
int posX = (int) Math.round(par3Entity.posX - 0.5f);
|
||||
int posY = (int) par3Entity.posY;
|
||||
int posZ = (int) Math.round(par3Entity.posZ - 0.5f);
|
||||
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
|
||||
{
|
||||
Block block = par2World.getBlock(ix, iy, iz);
|
||||
|
||||
|
||||
if (block instanceof IPlantable)
|
||||
{
|
||||
if (par2World.rand.nextInt(20) == 0)
|
||||
{
|
||||
block.updateTick(par2World, ix, iy, iz, par2World.rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player)
|
||||
{
|
||||
Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_);
|
||||
|
||||
BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (event.getResult() == Result.ALLOW)
|
||||
{
|
||||
if (!p_150919_1_.isRemote)
|
||||
{
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof IGrowable)
|
||||
{
|
||||
IGrowable igrowable = (IGrowable) block;
|
||||
|
||||
if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote))
|
||||
{
|
||||
if (!p_150919_1_.isRemote)
|
||||
{
|
||||
if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
|
||||
{
|
||||
igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int range = 5;
|
||||
int verticalRange = 2;
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
|
||||
{
|
||||
Block block = world.getBlock(ix, iy, iz);
|
||||
|
||||
|
||||
if (block instanceof IPlantable)
|
||||
{
|
||||
if (world.rand.nextInt(10) == 0)
|
||||
{
|
||||
block.updateTick(world, ix, iy, iz, world.rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfHaste extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon activeIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
public SigilOfHaste()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(250);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("One dose of caffeine later...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:HasteSigil_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:HasteSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:HasteSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1));
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1));
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionBoost.id, 3, 1, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,366 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfHolding extends EnergyItems
|
||||
{
|
||||
private int invSize = 4;
|
||||
|
||||
public static List<ItemStack> allowedSigils = new ArrayList();
|
||||
|
||||
public SigilOfHolding()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfHolding");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (!(stack.stackTagCompound == null))
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(stack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
ItemStack item = inv[stack.stackTagCompound.getInteger("selectedSlot")];
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
return item.getIconIndex();
|
||||
}
|
||||
}
|
||||
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Used to hold several Sigils!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
ItemStack[] inv = getInternalInventory(par1ItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = inv[par1ItemStack.stackTagCompound.getInteger("selectedSlot")];
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
par3List.add("Current item: " + item.getDisplayName());
|
||||
}
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
if (inv[i] != null)
|
||||
{
|
||||
par3List.add("Item in slot " + i + ": " + inv[i].getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
//TODO Might be a good idea to have this item need to be in the player's first slot
|
||||
this.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
if (this.addSigilToInventory(par1ItemStack, par3EntityPlayer))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
selectNextSlot(par1ItemStack);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
int currentSlot = this.getSelectedSlot(par1ItemStack);
|
||||
ItemStack[] inv = getInternalInventory(par1ItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
ItemStack itemUsed = inv[currentSlot];
|
||||
|
||||
if (itemUsed == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
itemUsed.getItem().onItemRightClick(itemUsed, par2World, par3EntityPlayer);
|
||||
saveInternalInventory(par1ItemStack, inv);
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
this.tickInternalInventory(par1ItemStack, par2World, par3Entity, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] getInternalInventory(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack[] inv = new ItemStack[9];
|
||||
NBTTagList tagList = itemTag.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
if (tagList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
int slot = tag.getByte("Slot");
|
||||
|
||||
if (slot >= 0 && slot < invSize)
|
||||
{
|
||||
inv[slot] = ItemStack.loadItemStackFromNBT(tag);
|
||||
}
|
||||
}
|
||||
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void saveInternalInventory(ItemStack itemStack, ItemStack[] inventory)
|
||||
{
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
ItemStack stack = inventory[i];
|
||||
|
||||
if (inventory[i] != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setByte("Slot", (byte) i);
|
||||
inventory[i].writeToNBT(tag);
|
||||
itemList.appendTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
itemTag.setTag("Inventory", itemList);
|
||||
}
|
||||
|
||||
public void tickInternalInventory(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(par1ItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
if (inv[i] == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
inv[i].getItem().onUpdate(inv[i], par2World, par3Entity, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSelectedSlot(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return itemTag.getInteger("selectedSlot");
|
||||
}
|
||||
|
||||
public void selectNextSlot(ItemStack itemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(itemStack);
|
||||
int filledSlots = 0;
|
||||
|
||||
for (int i = 0; i < invSize; i++)
|
||||
{
|
||||
if (inv[i] != null)
|
||||
{
|
||||
filledSlots++;
|
||||
} else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound itemTag = itemStack.stackTagCompound;
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (getSelectedSlot(itemStack) + 1 < filledSlots)
|
||||
{
|
||||
itemTag.setInteger("selectedSlot", itemTag.getInteger("selectedSlot") + 1);
|
||||
} else
|
||||
{
|
||||
itemTag.setInteger("selectedSlot", 0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAddedToInventory(ItemStack sigilItemStack, ItemStack addedItemStack)
|
||||
{
|
||||
ItemStack[] inv = getInternalInventory(sigilItemStack);
|
||||
|
||||
if (inv == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addedItemStack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = addedItemStack.getItem();
|
||||
int candidateSlot = -1;
|
||||
|
||||
for (int i = invSize - 1; i >= 0; i--)
|
||||
{
|
||||
ItemStack nextItem = inv[i];
|
||||
|
||||
if (nextItem == null)
|
||||
{
|
||||
candidateSlot = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item == nextItem.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (candidateSlot == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addedItemStack.getItem() instanceof IHolding)
|
||||
{
|
||||
inv[candidateSlot] = addedItemStack;
|
||||
saveInternalInventory(sigilItemStack, inv);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (ItemStack i : allowedSigils)
|
||||
{
|
||||
if (i != null && i.getItem() == item)
|
||||
{
|
||||
inv[candidateSlot] = addedItemStack;
|
||||
saveInternalInventory(sigilItemStack, inv);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addSigilToInventory(ItemStack sigilItemStack, EntityPlayer player)
|
||||
{
|
||||
ItemStack[] playerInventory = player.inventory.mainInventory;
|
||||
|
||||
for (int i = 0; i < 36; i++)
|
||||
{
|
||||
if (this.hasAddedToInventory(sigilItemStack, playerInventory[i]))
|
||||
{
|
||||
player.inventory.consumeInventoryItem(playerInventory[i].getItem());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void initiateSigilOfHolding()
|
||||
{
|
||||
allowedSigils.add(new ItemStack(ModItems.waterSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.lavaSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.voidSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.airSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.sigilOfTheFastMiner));
|
||||
allowedSigils.add(new ItemStack(ModItems.divinationSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.sigilOfElementalAffinity));
|
||||
allowedSigils.add(new ItemStack(ModItems.growthSigil));
|
||||
allowedSigils.add(new ItemStack(ModItems.sigilOfHaste));
|
||||
allowedSigils.add(new ItemStack(ModItems.sigilOfWind));
|
||||
}
|
||||
|
||||
public ItemStack getCurrentItem(ItemStack sigilItemStack)
|
||||
{
|
||||
ItemStack[] items = this.getInternalInventory(sigilItemStack);
|
||||
|
||||
if (items == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return items[this.getSelectedSlot(sigilItemStack)];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfMagnetism extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int tickDelay = 300;
|
||||
|
||||
public SigilOfMagnetism()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(50);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("I have a very magnetic personality!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfMagnetism_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfMagnetism_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfMagnetism_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, getEnergyUsed());
|
||||
}
|
||||
|
||||
int range = 5;
|
||||
int verticalRange = 5;
|
||||
float posX = Math.round(par3Entity.posX);
|
||||
float posY = (float) (par3Entity.posY - par3Entity.getEyeHeight());
|
||||
float posZ = Math.round(par3Entity.posZ);
|
||||
List<EntityItem> entities = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
|
||||
for (EntityItem entity : entities)
|
||||
{
|
||||
if (entity != null && !par2World.isRemote)
|
||||
{
|
||||
entity.onCollideWithPlayer(par3EntityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
int range = 5;
|
||||
int verticalRange = 5;
|
||||
float posX = Math.round(player.posX);
|
||||
float posY = (float) (player.posY - player.getEyeHeight());
|
||||
float posZ = Math.round(player.posZ);
|
||||
List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
|
||||
for (EntityItem entity : entities)
|
||||
{
|
||||
if (entity != null && !world.isRemote)
|
||||
{
|
||||
entity.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.tileEntity.TESpectralBlock;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfTheBridge extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
private static IIcon activeIcon;
|
||||
private static IIcon passiveIcon;
|
||||
private int tickDelay = 200;
|
||||
|
||||
public SigilOfTheBridge()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(100);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Activate to create a bridge");
|
||||
par3List.add("beneath your feet.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BridgeSigil_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:BridgeSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:BridgeSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % tickDelay);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed());
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (par2World.getWorldTime() % tickDelay == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
EnergyItems.syphonBatteries(par1ItemStack, (EntityPlayer) par3Entity, this.getLPUsed(par1ItemStack));
|
||||
this.setLPUsed(par1ItemStack, 0);
|
||||
}
|
||||
if (!par3EntityPlayer.onGround && !par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int range = 2;
|
||||
int verticalOffset = -1;
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
verticalOffset--;
|
||||
}
|
||||
|
||||
if (par2World.isRemote)
|
||||
{
|
||||
verticalOffset--;
|
||||
}
|
||||
|
||||
int posX = (int) Math.round(par3Entity.posX - 0.5f);
|
||||
int posY = (int) par3Entity.posY;
|
||||
int posZ = (int) Math.round(par3Entity.posZ - 0.5f);
|
||||
int incremented = 0;
|
||||
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
{
|
||||
Block block = par2World.getBlock(ix, posY + verticalOffset, iz);
|
||||
|
||||
if (par2World.isAirBlock(ix, posY + verticalOffset, iz))
|
||||
{
|
||||
par2World.setBlock(ix, posY + verticalOffset, iz, ModBlocks.spectralBlock, 0, 3);
|
||||
|
||||
TileEntity tile = par2World.getTileEntity(ix, posY + verticalOffset, iz);
|
||||
if (tile instanceof TESpectralBlock)
|
||||
{
|
||||
((TESpectralBlock) tile).setDuration(100);
|
||||
}
|
||||
|
||||
if (par2World.rand.nextInt(2) == 0)
|
||||
{
|
||||
incremented++;
|
||||
}
|
||||
} else if (block == ModBlocks.spectralBlock)
|
||||
{
|
||||
TileEntity tile = par2World.getTileEntity(ix, posY + verticalOffset, iz);
|
||||
if (tile instanceof TESpectralBlock)
|
||||
{
|
||||
((TESpectralBlock) tile).setDuration(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.incrimentLPUSed(par1ItemStack, incremented);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public int getLPUsed(ItemStack par1ItemStack)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return par1ItemStack.stackTagCompound.getInteger("LPUsed");
|
||||
}
|
||||
|
||||
public void incrimentLPUSed(ItemStack par1ItemStack, int addedLP)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setInteger("LPUsed", par1ItemStack.stackTagCompound.getInteger("LPUsed") + addedLP);
|
||||
}
|
||||
|
||||
public void setLPUsed(ItemStack par1ItemStack, int newLP)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
par1ItemStack.stackTagCompound.setInteger("LPUsed", newLP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
if (!player.onGround && !player.isSneaking())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int range = 2;
|
||||
int verticalOffset = -1;
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
verticalOffset--;
|
||||
}
|
||||
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
Block block = world.getBlock(ix, posY + verticalOffset, iz);
|
||||
|
||||
if (world.isAirBlock(ix, posY + verticalOffset, iz))
|
||||
{
|
||||
world.setBlock(ix, posY + verticalOffset, iz, ModBlocks.spectralBlock, 0, 3);
|
||||
|
||||
TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz);
|
||||
if (tile instanceof TESpectralBlock)
|
||||
{
|
||||
((TESpectralBlock) tile).setDuration(100);
|
||||
}
|
||||
} else if (block == ModBlocks.spectralBlock)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(ix, posY + verticalOffset, iz);
|
||||
if (tile instanceof TESpectralBlock)
|
||||
{
|
||||
((TESpectralBlock) tile).setDuration(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfTheFastMiner extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon activeIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
public SigilOfTheFastMiner()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(100);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Keep going and going and going...");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:SigilOfTheFastMiner");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:MiningSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:MiningSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true));
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 2, 1, true));
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 3, 1, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SigilOfWind extends EnergyItems implements ArmourUpgrade
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon activeIcon;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static IIcon passiveIcon;
|
||||
|
||||
public SigilOfWind()
|
||||
{
|
||||
super();
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(250);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Best not to wear a skirt.");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3List.add("Activated");
|
||||
} else
|
||||
{
|
||||
par3List.add("Deactivated");
|
||||
}
|
||||
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WindSigil_deactivated");
|
||||
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:WindSigil_activated");
|
||||
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:WindSigil_deactivated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
|
||||
{
|
||||
if (stack.stackTagCompound == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.stackTagCompound;
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (par1 == 1)
|
||||
{
|
||||
return this.activeIcon;
|
||||
} else
|
||||
{
|
||||
return this.passiveIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = par1ItemStack.stackTagCompound;
|
||||
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
|
||||
|
||||
if (tag.getBoolean("isActive"))
|
||||
{
|
||||
par1ItemStack.setItemDamage(1);
|
||||
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1));
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (!(par3Entity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
|
||||
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
par3EntityPlayer.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 2, 1));
|
||||
}
|
||||
|
||||
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionProjProt.id, 3, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.MaterialLiquid;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VoidSigil extends ItemBucket implements ArmourUpgrade
|
||||
{
|
||||
private int isFull;
|
||||
private int energyUsed;
|
||||
|
||||
public VoidSigil()
|
||||
{
|
||||
super(null);
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(50);
|
||||
isFull = 0;
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:VoidSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Better than a Swiffer!");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
ItemStack copiedStack = itemStack.copy();
|
||||
copiedStack.setItemDamage(copiedStack.getItemDamage() + getEnergyUsed());
|
||||
copiedStack.stackSize = 1;
|
||||
return copiedStack;
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
this.energyUsed = par1int;
|
||||
}
|
||||
|
||||
protected int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) f;
|
||||
double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) f + 1.62D - (double) par3EntityPlayer.yOffset;
|
||||
double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) f;
|
||||
boolean flag = this.isFull == 0;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, flag);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
FillBucketEvent event = new FillBucketEvent(par3EntityPlayer, par1ItemStack, par2World, movingobjectposition);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
TileEntity tile = par2World.getTileEntity(i, j, k);
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack amount = ((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, false);
|
||||
|
||||
if (amount != null && amount.amount > 0)
|
||||
{
|
||||
((IFluidHandler) tile).drain(ForgeDirection.getOrientation(movingobjectposition.sideHit), 1000, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.isFull == 0)
|
||||
{
|
||||
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (par2World.getBlock(i, j, k).getMaterial() instanceof MaterialLiquid)
|
||||
{
|
||||
par2World.setBlockToAir(i, j, k);
|
||||
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to place the liquid contained inside the bucket.
|
||||
*/
|
||||
public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 25;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.sigil;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WaterSigil extends ItemBucket implements ArmourUpgrade
|
||||
{
|
||||
private Block isFull = Blocks.water;
|
||||
private int energyUsed;
|
||||
|
||||
public WaterSigil()
|
||||
{
|
||||
super(Blocks.water);
|
||||
this.maxStackSize = 1;
|
||||
setEnergyUsed(100);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par1ItemStack.stackTagCompound == null)
|
||||
{
|
||||
par1ItemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:WaterSigil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
ItemStack copiedStack = itemStack.copy();
|
||||
copiedStack.setItemDamage(copiedStack.getItemDamage() + 1);
|
||||
copiedStack.stackSize = 1;
|
||||
return copiedStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Infinite water, anyone?");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
|
||||
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
float f = 1.0F;
|
||||
double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) f;
|
||||
double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) f + 1.62D - (double) par3EntityPlayer.yOffset;
|
||||
double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) f;
|
||||
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
|
||||
|
||||
if (movingobjectposition == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
} else
|
||||
{
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int i = movingobjectposition.blockX;
|
||||
int j = movingobjectposition.blockY;
|
||||
int k = movingobjectposition.blockZ;
|
||||
|
||||
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
TileEntity tile = par2World.getTileEntity(i, j, k);
|
||||
if (tile instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
int amount = ((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, false);
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
((IFluidHandler) tile).fill(ForgeDirection.getOrientation(movingobjectposition.sideHit), fluid, true);
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
{
|
||||
if (movingobjectposition.sideHit == 0)
|
||||
{
|
||||
--j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 1)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 2)
|
||||
{
|
||||
--k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 3)
|
||||
{
|
||||
++k;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 4)
|
||||
{
|
||||
--i;
|
||||
}
|
||||
|
||||
if (movingobjectposition.sideHit == 5)
|
||||
{
|
||||
++i;
|
||||
}
|
||||
|
||||
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
if (this.tryPlaceContainedLiquid(par2World, d0, d1, d2, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!par3EntityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
|
||||
{
|
||||
}
|
||||
} else
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to place the liquid contained inside the bucket.
|
||||
*/
|
||||
public boolean tryPlaceContainedLiquid(World par1World, double par2, double par4, double par6, int par8, int par9, int par10)
|
||||
{
|
||||
if (!par1World.isAirBlock(par8, par9, par10) && par1World.getBlock(par8, par9, par10).getMaterial().isSolid())
|
||||
{
|
||||
return false;
|
||||
} else if ((par1World.getBlock(par8, par9, par10) == Blocks.water || par1World.getBlock(par8, par9, par10) == Blocks.flowing_water) && par1World.getBlockMetadata(par8, par9, par10) == 0)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
if (par1World.provider.isHellWorld)
|
||||
{
|
||||
par1World.playSoundEffect(par2 + 0.5D, par4 + 0.5D, par6 + 0.5D, "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l)
|
||||
{
|
||||
par1World.spawnParticle("largesmoke", (double) par8 + Math.random(), (double) par9 + Math.random(), (double) par10 + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
} else
|
||||
{
|
||||
par1World.setBlock(par8, par9, par10, this.isFull, 0, 3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setEnergyUsed(int par1int)
|
||||
{
|
||||
this.energyUsed = par1int;
|
||||
}
|
||||
|
||||
protected int getEnergyUsed()
|
||||
{
|
||||
return this.energyUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.waterBreathing.id, 2, 9, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,802 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.spell;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmTool;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellEffect;
|
||||
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSpellMultiTool extends Item
|
||||
{
|
||||
private static final String harvestLevelSuffix = "harvestLvl";
|
||||
private static final String digLevelSuffix = "digLvl";
|
||||
private static final String tagName = "BloodMagicTool";
|
||||
private Random rand = new Random();
|
||||
|
||||
public ItemSpellMultiTool()
|
||||
{
|
||||
super();
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
this.setFull3D();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundTool");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
float damage = this.getCustomItemAttack(par1ItemStack);
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack);
|
||||
|
||||
if (parad != null)
|
||||
{
|
||||
parad.onLeftClickEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase);
|
||||
}
|
||||
|
||||
damage += parad.getAddedDamageForEntity(par2EntityLivingBase);
|
||||
|
||||
if (rand.nextFloat() < this.getCritChance(par1ItemStack))
|
||||
{
|
||||
damage *= 1.75f;
|
||||
}
|
||||
|
||||
if (par3EntityLivingBase instanceof EntityPlayer)
|
||||
{
|
||||
par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage);
|
||||
} else
|
||||
{
|
||||
par2EntityLivingBase.attackEntityFrom(DamageSource.causeMobDamage(par3EntityLivingBase), damage);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(stack);
|
||||
|
||||
if (parad != null && entity instanceof EntityLivingBase)
|
||||
{
|
||||
parad.onLeftClickEntity(stack, (EntityLivingBase) entity, player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
|
||||
World world = player.worldObj;
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
int hlvl = -1;
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
MovingObjectPosition mop = SpellHelper.raytraceFromEntity(world, player, true, 5.0D);
|
||||
|
||||
Block localBlock = world.getBlock(x, y, z);
|
||||
int localMeta = world.getBlockMetadata(x, y, z);
|
||||
String toolClass = block.getHarvestTool(meta);
|
||||
if (toolClass != null && this.getHarvestLevel(stack, toolClass) != -1)
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
int toolLevel = this.getHarvestLevel(stack, toolClass);
|
||||
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z);
|
||||
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
boolean cancelHarvest = false;
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
boolean isEffective = false;
|
||||
|
||||
String localToolClass = this.getToolClassForMaterial(localBlock.getMaterial());
|
||||
|
||||
if (localToolClass != null && this.getHarvestLevel(stack, toolClass) >= localBlock.getHarvestLevel(localMeta))
|
||||
{
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
|
||||
if (localBlock.getMaterial().isToolNotRequired())
|
||||
{
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (isEffective)
|
||||
{
|
||||
if (localBlock.removedByPlayer(world, player, x, y, z))
|
||||
{
|
||||
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
|
||||
}
|
||||
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
|
||||
|
||||
List<ItemStack> items = SpellHelper.getItemsFromBlock(world, localBlock, x, y, z, localMeta, this.getSilkTouch(stack), this.getFortuneLevel(stack));
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(stack);
|
||||
List<ItemStack> newItems = parad.handleItemList(stack, items);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
SpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f);
|
||||
}
|
||||
|
||||
world.func_147479_m(x, y, z);
|
||||
|
||||
int cost = 0;
|
||||
|
||||
cost += parad.digSurroundingArea(stack, world, player, mop, localToolClass, localHardness, toolLevel, this);
|
||||
|
||||
cost += parad.onBreakBlock(stack, world, player, localBlock, localMeta, x, y, z, ForgeDirection.getOrientation(mop.sideHit));
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
EnergyItems.syphonAndDamageWhileInContainer(stack, player, cost);
|
||||
}
|
||||
} else
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public Material[] getMaterialsForToolclass(String toolClass)
|
||||
{
|
||||
if ("pickaxe".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.circuits};
|
||||
} else if ("shovel".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay};
|
||||
} else if ("axe".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.wood, Material.vine, Material.circuits, Material.cactus};
|
||||
}
|
||||
return new Material[0];
|
||||
}
|
||||
|
||||
public String getToolClassForMaterial(Material mat)
|
||||
{
|
||||
String testString = "pickaxe";
|
||||
|
||||
Material[] matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
|
||||
testString = "shovel";
|
||||
matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
|
||||
testString = "axe";
|
||||
matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
Set<String> set = new HashSet();
|
||||
|
||||
if (this.getHarvestLevel(stack, "pickaxe") > -1)
|
||||
{
|
||||
set.add("pickaxe");
|
||||
}
|
||||
|
||||
if (this.getHarvestLevel(stack, "axe") > -1)
|
||||
{
|
||||
set.add("axe");
|
||||
}
|
||||
|
||||
if (this.getHarvestLevel(stack, "shovel") > -1)
|
||||
{
|
||||
set.add("shovel");
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
String toolClass = block.getHarvestTool(meta);
|
||||
|
||||
if (toolClass == null || toolClass.equals(""))
|
||||
{
|
||||
return 1.0f;
|
||||
}
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat(digLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
if (tag.hasKey(harvestLevelSuffix + toolClass))
|
||||
{
|
||||
return tag.getInteger(harvestLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack toolStack, World world, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(toolStack);
|
||||
int cost = parad.onUpdate(toolStack, world, par3Entity, par4, par5);
|
||||
|
||||
if (par3Entity instanceof EntityPlayer && cost > 0)
|
||||
EnergyItems.syphonAndDamageWhileInContainer(toolStack, (EntityPlayer) par3Entity, cost);
|
||||
|
||||
int duration = Math.max(this.getDuration(toolStack, world), 0);
|
||||
|
||||
if (duration <= 0 && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
int banishCost = parad.onBanishTool(toolStack, world, par3Entity, par4, par5);
|
||||
EnergyItems.syphonAndDamageWhileInContainer(toolStack, (EntityPlayer) par3Entity, banishCost);
|
||||
((EntityPlayer) par3Entity).inventory.mainInventory[par4] = this.getContainedCrystal(toolStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
par3EntityPlayer.setCurrentItemOrArmor(0, this.getContainedCrystal(par1ItemStack));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack);
|
||||
|
||||
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
|
||||
|
||||
int cost = 0;
|
||||
|
||||
if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK))
|
||||
{
|
||||
cost = parad.onRightClickBlock(par1ItemStack, par3EntityPlayer, par2World, mop);
|
||||
} else
|
||||
{
|
||||
cost = parad.onRightClickAir(par1ItemStack, par2World, par3EntityPlayer);
|
||||
}
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
EnergyItems.syphonAndDamageWhileInContainer(par1ItemStack, par3EntityPlayer, cost);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("A mace filled with ancient alchemy");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
{
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
}
|
||||
|
||||
for (String str : this.getToolListString(par1ItemStack))
|
||||
{
|
||||
par3List.add(str);
|
||||
}
|
||||
|
||||
par3List.add("");
|
||||
float damage = this.getCustomItemAttack(par1ItemStack);
|
||||
par3List.add("\u00A79+" + ((int) (damage * 10)) / 10.0f + " " + "Attack Damage");
|
||||
float critChance = ((int) (this.getCritChance(par1ItemStack) * 1000)) / 10.0f;
|
||||
par3List.add("\u00A79+" + critChance + "% " + "Crit Chance");
|
||||
}
|
||||
}
|
||||
|
||||
//--------------Custom methods--------------//
|
||||
|
||||
public void setHarvestLevel(ItemStack stack, String toolClass, int harvestLevel)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel));
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel));
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDigSpeed(ItemStack stack, String toolClass, float digSpeed)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat(digLevelSuffix + toolClass, digSpeed);
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat(digLevelSuffix + toolClass, digSpeed);
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public float getDigSpeed(ItemStack stack, String toolClass)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat(digLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemAttack(ItemStack stack, float damage)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public float getCustomItemAttack(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat("itemAttack");
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getContainedCrystal(ItemStack container)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName).getCompoundTag("heldItem");
|
||||
|
||||
return ItemStack.loadItemStackFromNBT(tag);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContainedCrystal(ItemStack container, ItemStack crystal)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
|
||||
NBTTagCompound tag = compTag.getCompoundTag("heldItem");
|
||||
|
||||
crystal.writeToNBT(tag);
|
||||
|
||||
compTag.setTag("heldItem", tag);
|
||||
container.getTagCompound().setTag(tagName, compTag);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
|
||||
NBTTagCompound tag = compTag.getCompoundTag("heldItem");
|
||||
|
||||
crystal.writeToNBT(tag);
|
||||
|
||||
compTag.setTag("heldItem", tag);
|
||||
container.getTagCompound().setTag(tagName, compTag);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(ItemStack container, World world, int duration)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
} else
|
||||
{
|
||||
World overWorld = DimensionManager.getWorld(0);
|
||||
long worldtime = overWorld.getTotalWorldTime();
|
||||
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setLong("duration", Math.max(duration + worldtime, worldtime));
|
||||
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setLong("duration", Math.max(duration + worldtime, worldtime));
|
||||
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getDuration(ItemStack container, World world)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
World overWorld = DimensionManager.getWorld(0);
|
||||
long worldtime = overWorld.getTotalWorldTime();
|
||||
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return (int) (tag.getLong("duration") - worldtime);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadParadigmIntoStack(ItemStack container, List<SpellEffect> list)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
|
||||
for (SpellEffect eff : list)
|
||||
{
|
||||
effectList.appendTag(eff.getTag());
|
||||
}
|
||||
|
||||
tagiest.setTag("Effects", effectList);
|
||||
|
||||
container.getTagCompound().setTag(tagName, tagiest);
|
||||
}
|
||||
|
||||
public SpellParadigmTool loadParadigmFromStack(ItemStack container)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
NBTTagList tagList = tagiest.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
List<SpellEffect> spellEffectList = new LinkedList();
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
|
||||
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
|
||||
if (eff != null)
|
||||
{
|
||||
spellEffectList.add(eff);
|
||||
}
|
||||
}
|
||||
|
||||
return SpellParadigmTool.getParadigmForEffectArray(spellEffectList);
|
||||
}
|
||||
|
||||
public void setSilkTouch(ItemStack stack, boolean silkTouch)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setBoolean("silkTouch", silkTouch);
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setBoolean("silkTouch", silkTouch);
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSilkTouch(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getBoolean("silkTouch");
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFortuneLevel(ItemStack stack, int fortune)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public int getFortuneLevel(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getInteger("fortuneLevel");
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getToolListString(ItemStack container)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
NBTTagList tagList = tagiest.getTagList("ToolTips", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
List<String> toolTipList = new LinkedList();
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
|
||||
String str = tag.getString("tip");
|
||||
if (str != null)
|
||||
{
|
||||
toolTipList.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
return toolTipList;
|
||||
}
|
||||
|
||||
public void setToolListString(ItemStack container, List<String> toolTipString)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
NBTTagList stringList = new NBTTagList();
|
||||
|
||||
for (String str : toolTipString)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("tip", str);
|
||||
|
||||
stringList.appendTag(tag);
|
||||
}
|
||||
|
||||
tagiest.setTag("ToolTips", stringList);
|
||||
|
||||
container.getTagCompound().setTag(tagName, tagiest);
|
||||
}
|
||||
|
||||
public void setCritChance(ItemStack container, float chance)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("critChance", Math.max(chance, 0));
|
||||
|
||||
container.stackTagCompound.setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("critChance", Math.max(chance, 0));
|
||||
|
||||
container.stackTagCompound.setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
public float getCritChance(ItemStack container)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat("critChance");
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package WayofTime.alchemicalWizardry.common.items.thaumcraft;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.IGoggles;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.nodes.IRevealer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSanguineArmour extends ItemArmor implements ArmourUpgrade, IGoggles, IVisDiscountGear, IRevealer, IRunicArmor, IRepairable
|
||||
{
|
||||
private static IIcon helmetIcon;
|
||||
private static IIcon plateIcon;
|
||||
private static IIcon leggingsIcon;
|
||||
private static IIcon bootsIcon;
|
||||
|
||||
public ItemSanguineArmour(int armorType)
|
||||
{
|
||||
super(AlchemicalWizardry.sanguineArmourArmourMaterial, 0, armorType);
|
||||
setMaxDamage(1000);
|
||||
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");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int par1)
|
||||
{
|
||||
if (this.equals(ModItems.sanguineHelmet))
|
||||
{
|
||||
return this.helmetIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.sanguineRobe))
|
||||
{
|
||||
return this.plateIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.sanguinePants))
|
||||
{
|
||||
return this.leggingsIcon;
|
||||
}
|
||||
|
||||
if (this.equals(ModItems.sanguineBoots))
|
||||
{
|
||||
return this.bootsIcon;
|
||||
}
|
||||
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
if (this == ModItems.sanguineHelmet)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/sanguineArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == ModItems.sanguineRobe || this == ModItems.sanguineBoots)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/sanguineArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == ModItems.sanguinePants)
|
||||
{
|
||||
return "alchemicalwizardry:models/armor/sanguineArmour_layer_2.png";
|
||||
} else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
int discount = 0;
|
||||
|
||||
switch (this.armorType)
|
||||
{
|
||||
case 0:
|
||||
discount = 6;
|
||||
break;
|
||||
case 1:
|
||||
discount = 3;
|
||||
break;
|
||||
case 2:
|
||||
discount = 3;
|
||||
break;
|
||||
case 3:
|
||||
discount = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (this.armorType)
|
||||
{
|
||||
case 0:
|
||||
par3List.add("A pair of goggles imbued with power");
|
||||
break;
|
||||
case 1:
|
||||
|
||||
case 2:
|
||||
|
||||
case 3:
|
||||
par3List.add("Robes imbued with forbidden power");
|
||||
}
|
||||
|
||||
par3List.add("Vis discount: " + discount + "%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyForTenSeconds()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNodes(ItemStack itemstack, EntityLivingBase player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect)
|
||||
{
|
||||
switch (this.armorType)
|
||||
{
|
||||
case 0:
|
||||
return 7;
|
||||
case 1:
|
||||
return 3;
|
||||
case 2:
|
||||
return 2;
|
||||
case 3:
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showIngamePopups(ItemStack itemstack, EntityLivingBase player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemstack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue