Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int SpiritCostBase[] = new int[]{8, 14, 11, 13, 12, 9, 6, 8, 10, 7, 9, 12}; //Configurable
- public static int SpiritCostFormula[] = new int[]{7, 9, 9, 12, 10, 3, 12, 6, 8, 12, 6, 5}; //Configurable
- public static int SpiritSummonCost;
- 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);
- checkForGift(itemstack, player);
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment