Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.halestormxv.item;
- import java.lang.reflect.*;
- import java.util.List;
- import java.util.Random;
- import com.halestormxv.Main.handler.ExtendedPlayer;
- import com.halestormxv.entity.goldspirits.EntityAquarius;
- import com.halestormxv.entity.goldspirits.EntityAries;
- import com.halestormxv.entity.goldspirits.EntityCancer;
- import com.halestormxv.entity.goldspirits.EntityCapricorn;
- import com.halestormxv.entity.goldspirits.EntityGemini;
- import com.halestormxv.entity.goldspirits.EntityGemini2;
- import com.halestormxv.entity.goldspirits.EntityLeo;
- import com.halestormxv.entity.goldspirits.EntityLibra;
- import com.halestormxv.entity.goldspirits.EntityPisces;
- import com.halestormxv.entity.goldspirits.EntityPisces2;
- import com.halestormxv.entity.goldspirits.EntitySagittarius;
- import com.halestormxv.entity.goldspirits.EntityScorpio;
- import com.halestormxv.entity.goldspirits.EntityTaurus;
- import com.halestormxv.entity.goldspirits.EntityVirgo;
- import com.halestormxv.lib.RefStrings;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockLog;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.texture.IIconRegister;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.passive.EntityTameable;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.EnumRarity;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.util.ChatComponentTranslation;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.util.IIcon;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.World;
- public class celKey extends Item
- {
- public static final String[] celKeys = new String[] {"Aquarius", "Taurus", "Cancer", "Virgo", "Sagittarius", "Leo", "Aries", "Scorpio", "Gemini", "Capricorn", "Pisces", "Libra"};
- public static final String[] celKeys2 = new String[] {"Aquarius", "Taurus", "Cancer", "Virgo", "Sagittarius", "Leo", "Aries", "Scorpio", "Gemini", "Capricorn", "Pisces", "Libra"};
- public static Class<? extends Entity>[] entityClasses = new Class[]
- {
- EntityAquarius.class, EntityTaurus.class, EntityCancer.class, EntityVirgo.class,
- EntitySagittarius.class, EntityLeo.class, EntityAries.class, EntityScorpio.class,
- EntityGemini.class, EntityCapricorn.class, EntityPisces.class, EntityLibra.class
- };
- public static int SpiritCostBase[] = new int[]{8, 14, 11, 13, 12, 9, 6, 8, 10, 7, 9, 12};
- public static int SpiritCostFormula[] = new int[]{7, 9, 9, 12, 10, 3, 12, 6, 8, 12, 6, 5};
- public static int SpiritSummonCost;
- public int summonedAmount = 0;
- @SideOnly(Side.CLIENT)
- private IIcon[] iconID;
- public celKey()
- {
- this.setHasSubtypes(true);
- this.setMaxDamage(0);
- this.setMaxStackSize(1);
- }
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.epic;
- }
- @Override
- public boolean hasEffect(ItemStack par1ItemStack){
- return true;
- }
- @SideOnly(Side.CLIENT)
- public IIcon getIconFromDamage(int meta)
- {
- int j = MathHelper.clamp_int(meta, 0, 11);
- return this.iconID[j];
- }
- public String getUnlocalizedName(ItemStack itemstack)
- {
- int i = MathHelper.clamp_int(itemstack.getItemDamage(), 0, 11);
- return super.getUnlocalizedName() + "." + celKeys[i];
- }
- public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int meta, float p_77648_8_, float p_77648_9_, float p_77648_10_)
- {
- if (player.canPlayerEdit(x, y, z, meta, itemstack) && !world.isRemote)
- {
- try {
- Entity e = entityClasses[itemstack.getItemDamage()].getConstructor(World.class).newInstance(world);
- Entity gem2 = EntityGemini2.class.getConstructor(World.class).newInstance(world);
- Entity pis2 = EntityPisces2.class.getConstructor(World.class).newInstance(world);
- Random randCordY = new Random();
- Random randCordZ = new Random();
- int sF = SpiritCostFormula[itemstack.getItemDamage()];
- int sB = SpiritCostBase[itemstack.getItemDamage()];
- int sC = SpiritSummonCost = (int)(Math.ceil((player.experienceLevel) / sF));
- ExtendedPlayer instance = ExtendedPlayer.get(player);
- if (!itemstack.hasTagCompound())
- {
- itemstack.setTagCompound(new NBTTagCompound());
- itemstack.stackTagCompound.setString("Contract With: ", player.getDisplayName());
- itemstack.stackTagCompound.setInteger("Summoned Amount: ", summonedAmount);
- }
- else if (itemstack.hasTagCompound())
- {
- String owner = itemstack.stackTagCompound.getString("Contract With: ");
- if (!owner.equals(player.getDisplayName()))
- {
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You are not the owner of this contract!"));
- return false;
- }
- }
- if (!instance.summonedState[itemstack.getItemDamage()])
- {
- if ( (player.experienceTotal > sC) && (player.experienceLevel >= sB) )
- {
- int rY = randCordY.nextInt(3);
- int rZ = randCordZ.nextInt(3) + 1;
- e.setPosition(player.posX, player.posY + rY, player.posZ - rZ);
- ((EntityTameable) e).func_152115_b(player.getUniqueID().toString());
- if (itemstack.getItemDamage() == 8)
- {
- gem2.setPosition(player.posX + 2, player.posY + rY, player.posZ - rZ);
- ((EntityTameable) gem2).func_152115_b(player.getUniqueID().toString());
- world.spawnEntityInWorld(e); //Gemini 1 Master
- world.spawnEntityInWorld(gem2); //Gemini 2 Mirror
- }
- else if (itemstack.getItemDamage() == 10)
- {
- pis2.setPosition(player.posX + 2, player.posY + rY, player.posZ - rZ);
- ((EntityTameable) pis2).func_152115_b(player.getUniqueID().toString());
- world.spawnEntityInWorld(e); //Pisces 1 Master
- world.spawnEntityInWorld(pis2); //Pisces 2 Mirror
- }
- else
- {
- world.spawnEntityInWorld(e);
- }
- world.playSoundAtEntity(player, RefStrings.MODID + ":summon-bell", 0.7F, 1.0F);
- player.addChatComponentMessage(new ChatComponentTranslation ("Come forth "+celKeys2[itemstack.getItemDamage()] +"! I summon you!"));
- instance.setSummoned(itemstack.getItemDamage(), true);
- int newAmount = itemstack.stackTagCompound.getInteger("Summoned Amount: ") + 1;
- itemstack.stackTagCompound.setInteger("Summoned Amount: ", newAmount);
- if(sC > sB){ player.addExperienceLevel((int)-sC); return true; }else{ player.addExperienceLevel((int)-sB); return true; }
- }
- else
- {
- player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You do not have enough Celestial Power!"));
- return false;
- }
- }
- else
- {
- player.addChatComponentMessage(new ChatComponentTranslation (celKeys2[itemstack.getItemDamage()]+" is already summoned!"));
- return false;
- }
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- }
- }
- else if (itemstack.getItemDamage() > 11){};
- return false;
- }
- public void addInformation(ItemStack itemstack, EntityPlayer player,List list, boolean par4)
- {
- if (itemstack.stackTagCompound != null) {
- String owner = itemstack.stackTagCompound.getString("Contract With: ");
- int code = itemstack.stackTagCompound.getInteger("Summoned Amount: ");
- list.add((EnumChatFormatting.GREEN + "Contract With: " + owner));
- if (owner.equals(player.getDisplayName())) //player.getUniqueID().toString())
- {
- list.add(EnumChatFormatting.AQUA + "Summoned Amount: " + code);
- } else {
- list.add(EnumChatFormatting.RED + "Summoned Amount: Not Your Key");
- //+ EnumChatFormatting.OBFUSCATED + code);
- }
- }
- }
- @SideOnly(Side.CLIENT)
- public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_)
- {
- for (int i = 0; i < 12; ++i)
- {
- p_150895_3_.add(new ItemStack(p_150895_1_, 1, i));
- }
- }
- @SideOnly(Side.CLIENT)
- public void registerIcons(IIconRegister IIcon)
- {
- this.iconID = new IIcon[celKeys2.length];
- for (int i = 0; i < celKeys2.length; ++i)
- {
- this.iconID[i] = IIcon.registerIcon(RefStrings.MODID + ":celestialkey" + "_" + celKeys2[i]);
- }
- }
- }
Add Comment
Please, Sign In to add comment