Examples of ItemWandCasting


Examples of thaumcraft.common.items.wands.ItemWandCasting

  private static final AspectList visUsage = new AspectList().add(Aspect.AIR, 5).add(Aspect.ENTROPY, 5);

  @Override
  public void onUsingFocusTick(ItemStack stack, EntityPlayer player, int ticks) {
    ItemWandCasting wand = (ItemWandCasting) stack.getItem();

    Vector3 target = Vector3.fromEntityCenter(player);

    final int range = 6 + EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
    final double distance = range - 1;
    if (!player.isSneaking())
      target.add(new Vector3(player.getLookVec()).multiply(distance));

    target.y += 0.5;

    List<EntityItem> entities = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(target.x - range, target.y - range, target.z - range, target.x + range, target.y + range, target.z + range));

    if (!entities.isEmpty() && wand.consumeAllVis(stack, player, getVisCost(), true, false)) {
      for (EntityItem item : entities) {
        MiscHelper.setEntityMotionFromVector(item, target, 0.3333F);
        ThaumicTinkerer.tcProxy.sparkle((float) item.posX, (float) item.posY, (float) item.posZ, 0);
      }
    }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

      return itemstack;

    Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
    int meta = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
        TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
    ItemWandCasting wand = (ItemWandCasting) itemstack.getItem();

    if (player.canPlayerEdit(mop.blockX, mop.blockY, mop.blockZ, mop.sideHit, itemstack)) {
      ItemStack stack = getPickedBlock(itemstack);
      if (stack != null) {
        if (mop.sideHit == 0)
          --mop.blockY;
        if (mop.sideHit == 1)
          ++mop.blockY;
        if (mop.sideHit == 2)
          --mop.blockZ;
        if (mop.sideHit == 3)
          ++mop.blockZ;
        if (mop.sideHit == 4)
          --mop.blockX;
        if (mop.sideHit == 5)
          ++mop.blockX;

        if (block.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
          if (!world.isRemote) {
            world.setBlock(mop.blockX, mop.blockY, mop.blockZ, ((ItemBlock) stack.getItem()).field_150939_a, stack.getItemDamage(), 1 | 2);
            block.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, itemstack);
            NBTTagCompound tileCmp = getStackTileEntity(itemstack);
            if (tileCmp != null && !tileCmp.hasNoTags()) {
              TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
              tile1.xCoord = mop.blockX;
              tile1.yCoord = mop.blockY;
              tile1.zCoord = mop.blockZ;
              world.setTileEntity(mop.blockX, mop.blockY, mop.blockZ, tile1);
            }
          } else player.swingItem();
          clearPickedBlock(itemstack);

          for (int i = 0; i < 8; i++) {
            float x = (float) (mop.blockX + Math.random());
            float y = (float) (mop.blockY + Math.random()) + 0.65F;
            float z = (float) (mop.blockZ + Math.random());
            ThaumicTinkerer.tcProxy.burst(world, x, y, z, 0.2F);
          }
          world.playSoundAtEntity(player, "thaumcraft:wand", 0.5F, 1F);
        }
      } else if (!blacklist.contains(block) && !ThaumcraftApi.portableHoleBlackList.contains(block) && block != null && block.getBlockHardness(world, mop.blockX, mop.blockY, mop.blockZ) != -1F && wand.consumeAllVis(itemstack, player, getCost(tile), true, false)) {
        if (!world.isRemote) {
          world.removeTileEntity(mop.blockX, mop.blockY, mop.blockZ);
          world.setBlock(mop.blockX, mop.blockY, mop.blockZ, Blocks.air, 0, 1 | 2);
          storePickedBlock(itemstack, block, (short) meta, tile);
        }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

  }

  public ItemStack getPickedBlock(ItemStack stack) {
    ItemStack focus;
    if (stack.getItem() instanceof ItemWandCasting) {
      ItemWandCasting wand = (ItemWandCasting) stack.getItem();
      focus = wand.getFocusItem(stack);
    } else {
      focus = stack;
    }
    return (ItemNBTHelper.getBoolean(focus, TAG_AVAILABLE, false)) ? getPickedBlockStack(stack) : null;
  }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

  }

  public ItemStack getPickedBlockStack(ItemStack stack) {
    ItemStack focus;
    if (stack.getItem() instanceof ItemWandCasting) {
      ItemWandCasting wand = (ItemWandCasting) stack.getItem();
      focus = wand.getFocusItem(stack);
    } else {
      focus = stack;
    }
    String name = ItemNBTHelper.getString(focus, TAG_BLOCK_NAME, "");
    Block block = Block.getBlockFromName(name);
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

  }

  public NBTTagCompound getStackTileEntity(ItemStack stack) {
    ItemStack focus;
    if (stack.getItem() instanceof ItemWandCasting) {
      ItemWandCasting wand = (ItemWandCasting) stack.getItem();
      focus = wand.getFocusItem(stack);
    } else {
      focus = stack;
    }
    return ItemNBTHelper.getCompound(focus, TAG_TILE_CMP, true);
  }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

    }
    return ItemNBTHelper.getCompound(focus, TAG_TILE_CMP, true);
  }

  private void storePickedBlock(ItemStack stack, Block block, short meta, TileEntity tile) {
    ItemWandCasting wand = (ItemWandCasting) stack.getItem();
    ItemStack focus = wand.getFocusItem(stack);
    String blockName = Block.blockRegistry.getNameForObject(block);
    ItemNBTHelper.setString(focus, TAG_BLOCK_NAME, blockName);
    ItemNBTHelper.setInt(focus, TAG_BLOCK_META, meta);
    NBTTagCompound cmp = new NBTTagCompound();
    if (tile != null)
      tile.writeToNBT(cmp);
    ItemNBTHelper.setCompound(focus, TAG_TILE_CMP, cmp);
    ItemNBTHelper.setBoolean(focus, TAG_AVAILABLE, true);
    wand.setFocus(stack, focus);
  }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

    ItemNBTHelper.setBoolean(focus, TAG_AVAILABLE, true);
    wand.setFocus(stack, focus);
  }

  private void clearPickedBlock(ItemStack stack) {
    ItemWandCasting wand = (ItemWandCasting) stack.getItem();
    ItemStack focus = wand.getFocusItem(stack);
    ItemNBTHelper.setBoolean(focus, TAG_AVAILABLE, false);
    wand.setFocus(stack, focus);
  }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

    super();
  }

  @Override
  public void onUsingFocusTick(ItemStack stack, EntityPlayer p, int time) {
    ItemWandCasting wand = (ItemWandCasting) stack.getItem();
    if (!wand.consumeAllVis(stack, p, visUsage, false, false) || !p.shouldHeal())
      return;

    int potency = EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));

    if (!playerHealData.containsKey(p.getGameProfile().getName()))
      playerHealData.put(p.getGameProfile().getName(), 0);

    int progress = playerHealData.get(p.getGameProfile().getName()) + 1;
    playerHealData.put(p.getGameProfile().getName(), progress);

    ThaumicTinkerer.tcProxy.sparkle((float) p.posX + p.worldObj.rand.nextFloat() - 0.5F, (float) p.posY + p.worldObj.rand.nextFloat(), (float) p.posZ + p.worldObj.rand.nextFloat() - 0.5F, 0);

    if (progress >= 30 - potency * 10 / 3) {
      playerHealData.put(p.getGameProfile().getName(), 0);

      wand.consumeAllVis(stack, p, visUsage, true, false);
      p.heal(1);
      p.worldObj.playSoundAtEntity(p, "thaumcraft:wand", 0.5F, 1F);
    }
  }
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

        return true;
    }

    @Override
    public void onUsingFocusTick(ItemStack stack, EntityPlayer p, int time) {
        ItemWandCasting wand = (ItemWandCasting) stack.getItem();
        if (!wand.consumeAllVis(stack, p, visUsage, false, false))
            return;

        MovingObjectPosition pos = BlockUtils.getTargetBlock(p.worldObj, p, false);

        if (pos != null) {
            Block block = p.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
            int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);

            ItemStack blockStack = new ItemStack(block, 1, meta);
            ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack);

            if (result != null && result.getItem() instanceof ItemBlock) {
                boolean decremented = false;

                if (playerData.containsKey(p.getGameProfile().getName())) {
                    SmeltData data = playerData.get(p.getGameProfile().getName());

                    if (data.equalPos(pos)) {
                        data.progress--;
                        decremented = true;
                        if (data.progress <= 0) {
                            if (!p.worldObj.isRemote) {
                                p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 1 | 2);
                                p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F);
                                p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F);

                                wand.consumeAllVis(stack, p, visUsage, true, false);
                                playerData.remove(p.getGameProfile().getName());
                                decremented = false;
                            }

                            for (int i = 0; i < 25; i++) {
                                double x = pos.blockX + Math.random();
                                double y = pos.blockY + Math.random();
                                double z = pos.blockZ + Math.random();

                                ThaumicTinkerer.tcProxy.wispFX2(p.worldObj, x, y, z, (float) Math.random() / 2F, 4, true, true, (float) -Math.random() / 10F);
                            }
                        }
                    }
                }

                if (!decremented) {
                    int potency = EnchantmentHelper.getEnchantmentLevel(Config.enchPotency.effectId, wand.getFocusItem(stack));
                    playerData.put(p.getGameProfile().getName(), new SmeltData(pos, 20 - Math.min(3, potency) * 5));
                } else for (int i = 0; i < 2; i++) {
                    double x = pos.blockX + Math.random();
                    double y = pos.blockY + Math.random();
                    double z = pos.blockZ + Math.random();
View Full Code Here

Examples of thaumcraft.common.items.wands.ItemWandCasting

  @Override
  public ItemStack onFocusRightClick(ItemStack stack, World world, EntityPlayer p, MovingObjectPosition pos) {
    if (Loader.isModLoaded("EnderStorage")) {
      return EnderStorageFunctions.onFocusRightClick(stack, world, p, pos);
    }
    ItemWandCasting wand = (ItemWandCasting) stack.getItem();

    if (wand.consumeAllVis(stack, p, visUsage, true, false)) {
      p.displayGUIChest(p.getInventoryEnderChest());
      world.playSoundAtEntity(p, "mob.endermen.portal", 1F, 1F);
    }

    return stack;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.