Guest User

Untitled

a guest
Mar 16th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.22 KB | None | 0 0
  1. public static int SpiritCostBase[] = new int[]{8, 14, 11, 13, 12, 9, 6, 8, 10, 7, 9, 12}; //Configurable
  2. public static int SpiritCostFormula[] = new int[]{7, 9, 9, 12, 10, 3, 12, 6, 8, 12, 6, 5}; //Configurable
  3. public static int SpiritSummonCost;
  4.  
  5. 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_)
  6.     {
  7.         if (player.canPlayerEdit(x, y, z, meta, itemstack) && !world.isRemote)
  8.         {
  9.             try {
  10.                 Entity e = entityClasses[itemstack.getItemDamage()].getConstructor(World.class).newInstance(world);
  11.                 Entity gem2 = EntityGemini2.class.getConstructor(World.class).newInstance(world);
  12.                 Entity pis2 = EntityPisces2.class.getConstructor(World.class).newInstance(world);
  13.                 Random randCordY = new Random();
  14.                 Random randCordZ = new Random();
  15.                 int sF = SpiritCostFormula[itemstack.getItemDamage()];
  16.                 int sB = SpiritCostBase[itemstack.getItemDamage()];
  17.                 int sC = SpiritSummonCost = (int)(Math.ceil((player.experienceLevel) / sF));
  18.                 ExtendedPlayer instance = ExtendedPlayer.get(player);
  19.                 if (!itemstack.hasTagCompound())
  20.                 {
  21.                     itemstack.setTagCompound(new NBTTagCompound());
  22.                     itemstack.stackTagCompound.setString("Contract With: ", player.getDisplayName());
  23.                     itemstack.stackTagCompound.setInteger("Summoned Amount: ", summonedAmount);
  24.                 }
  25.                 else if (itemstack.hasTagCompound())
  26.                 {
  27.                     String owner = itemstack.stackTagCompound.getString("Contract With: ");
  28.                     if (!owner.equals(player.getDisplayName()))
  29.                     {
  30.                         player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You are not the owner of this contract!"));
  31.                         return false;
  32.                     }
  33.                 }
  34.                 if (!instance.summonedState[itemstack.getItemDamage()])
  35.                 {
  36.                     if ( (player.experienceTotal > sC) && (player.experienceLevel >= sB) )
  37.                     {
  38.                         int rY = randCordY.nextInt(3);
  39.                         int rZ = randCordZ.nextInt(3) + 1;
  40.                         e.setPosition(player.posX, player.posY + rY, player.posZ - rZ);
  41.                         ((EntityTameable) e).func_152115_b(player.getUniqueID().toString());
  42.                         if (itemstack.getItemDamage() == 8)
  43.                         {
  44.                             gem2.setPosition(player.posX + 2, player.posY + rY, player.posZ - rZ);
  45.                             ((EntityTameable) gem2).func_152115_b(player.getUniqueID().toString());
  46.                             world.spawnEntityInWorld(e); //Gemini 1 Master
  47.                             world.spawnEntityInWorld(gem2); //Gemini 2 Mirror
  48.                         }
  49.                         else if (itemstack.getItemDamage() == 10)
  50.                         {
  51.                             pis2.setPosition(player.posX + 2, player.posY + rY, player.posZ - rZ);
  52.                             ((EntityTameable) pis2).func_152115_b(player.getUniqueID().toString());
  53.                             world.spawnEntityInWorld(e); //Pisces 1 Master
  54.                             world.spawnEntityInWorld(pis2); //Pisces 2 Mirror
  55.                         }
  56.                         else
  57.                         {
  58.                             world.spawnEntityInWorld(e);
  59.                         }
  60.                         world.playSoundAtEntity(player, RefStrings.MODID + ":summon-bell", 0.7F, 1.0F);
  61.                         player.addChatComponentMessage(new ChatComponentTranslation ("Come forth "+celKeys2[itemstack.getItemDamage()] +"! I summon you!"));
  62.                         instance.setSummoned(itemstack.getItemDamage(), true);
  63.                         int newAmount = itemstack.stackTagCompound.getInteger("Summoned Amount: ") + 1;
  64.                         itemstack.stackTagCompound.setInteger("Summoned Amount: ", newAmount);
  65.                         checkForGift(itemstack, player);
  66.                         if(sC > sB){ player.addExperienceLevel((int)-sC); return true; }else{ player.addExperienceLevel((int)-sB); return true; }
  67.                     }
  68.                     else
  69.                     {
  70.                         player.addChatComponentMessage(new ChatComponentTranslation ("\u00A74You do not have enough Celestial Power!"));
  71.                         return false;
  72.                     }
  73.                 }
  74.                 else
  75.                 {
  76.                     player.addChatComponentMessage(new ChatComponentTranslation (celKeys2[itemstack.getItemDamage()]+" is already summoned!"));
  77.                     return false;
  78.                 }
  79.  
  80.             } catch (InstantiationException e) {
  81.                 e.printStackTrace();
  82.             } catch (IllegalAccessException e) {
  83.                 e.printStackTrace();
  84.             } catch (IllegalArgumentException e) {
  85.                 e.printStackTrace();
  86.             } catch (InvocationTargetException e) {
  87.                 e.printStackTrace();
  88.             } catch (NoSuchMethodException e) {
  89.                 e.printStackTrace();
  90.             } catch (SecurityException e) {
  91.                 e.printStackTrace();
  92.             }
  93.         }
  94.         else if (itemstack.getItemDamage() > 11){};
  95.         return false;
  96.     }
Advertisement
Add Comment
Please, Sign In to add comment