Package universalelectricity.api.vector

Examples of universalelectricity.api.vector.Vector3


      {
        NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack);

        if (nbt != null)
        {
          Vector3 point1 = new Vector3(nbt.getCompoundTag(NBT_POINT_1));
          Vector3 point2 = new Vector3(nbt.getCompoundTag(NBT_POINT_2));

          if (nbt.hasKey(NBT_POINT_1) && nbt.hasKey(NBT_POINT_2) && !point1.equals(point2))
          {
            if (point1.distance(point2) < Settings.MAX_FORCE_FIELD_SCALE)
            {
              // Clear NBT Data
              nbt.removeTag(NBT_POINT_1);
              nbt.removeTag(NBT_POINT_2);

              Vector3 midPoint = new Vector3();
              midPoint.x = (point1.x + point2.x) / 2;
              midPoint.y = (point1.y + point2.y) / 2;
              midPoint.z = (point1.z + point2.z) / 2;
              midPoint = midPoint.floor();

              // Center the two coords to origin.
              point1.subtract(midPoint);
              point2.subtract(midPoint);

              Vector3 minPoint = new Vector3(Math.min(point1.x, point2.x), Math.min(point1.y, point2.y), Math.min(point1.z, point2.z));
              Vector3 maxPoint = new Vector3(Math.max(point1.x, point2.x), Math.max(point1.y, point2.y), Math.max(point1.z, point2.z));

              NBTTagCompound saveNBT = NBTUtility.loadData(this.getSaveDirectory(), NBT_FILE_SAVE_PREFIX + getModeID(itemStack));

              if (saveNBT == null)
              {
                saveNBT = new NBTTagCompound();
              }

              NBTTagList list;

              if (saveNBT.hasKey(NBT_FIELD_BLOCK_LIST))
              {
                list = (NBTTagList) saveNBT.getTag(NBT_FIELD_BLOCK_LIST);
              }
              else
              {
                list = new NBTTagList();
              }

              for (int x = minPoint.intX(); x <= maxPoint.intX(); x++)
              {
                for (int y = minPoint.intY(); y <= maxPoint.intY(); y++)
                {
                  for (int z = minPoint.intZ(); z <= maxPoint.intZ(); z++)
                  {
                    Vector3 position = new Vector3(x, y, z);
                    Vector3 targetCheck = midPoint.clone().translate(position);
                    int blockID = targetCheck.getBlockID(world);

                    if (blockID > 0)
                    {
                      if (!nbt.getBoolean(NBT_MODE))
                      {
                        NBTTagCompound vectorTag = new NBTTagCompound();
                        position.writeToNBT(vectorTag);
                        vectorTag.setInteger(NBT_FIELD_BLOCK_ID, blockID);
                        vectorTag.setInteger(NBT_FIELD_BLOCK_METADATA, targetCheck.getBlockMetadata(world));
                        list.appendTag(vectorTag);
                      }
                      else
                      {
                        for (int i = 0; i < list.tagCount(); i++)
                        {
                          Vector3 vector = new Vector3((NBTTagCompound) list.tagAt(i));

                          if (vector.equals(position))
                          {
                            list.removeTag(i);
                          }
                        }
                      }
View Full Code Here


    {
      NBTTagCompound nbt = NBTUtility.getNBTTagCompound(itemStack);

      if (nbt != null)
      {
        Vector3 point1 = new Vector3(nbt.getCompoundTag(NBT_POINT_1));

        if (!nbt.hasKey(NBT_POINT_1) || point1.equals(new Vector3(0, 0, 0)))
        {
          nbt.setCompoundTag(NBT_POINT_1, new Vector3(x, y, z).writeToNBT(new NBTTagCompound()));
          entityPlayer.addChatMessage("Set point 1: " + x + ", " + y + ", " + z + ".");
        }
        else
        {
          nbt.setCompoundTag(NBT_POINT_2, new Vector3(x, y, z).writeToNBT(new NBTTagCompound()));
          entityPlayer.addChatMessage("Set point 2: " + x + ", " + y + ", " + z + ".");
        }

      }
    }
View Full Code Here

        {
          int directionalDisplacementScale = directionalDisplacement * (i + 1);

          for (Vector3 originalFieldBlock : this.getFieldBlocks(projector, itemStack))
          {
            Vector3 newFieldBlock = originalFieldBlock.clone().translate(new Vector3(direction).scale(directionalDisplacementScale));
            fieldMap.put(newFieldBlock, fieldMap.get(originalFieldBlock));
          }
        }
      }
    }
View Full Code Here

        NBTTagList nbtTagList = nbt.getTagList(NBT_FIELD_BLOCK_LIST);

        for (int i = 0; i < nbtTagList.tagCount(); i++)
        {
          NBTTagCompound vectorTag = (NBTTagCompound) nbtTagList.tagAt(i);
          Vector3 position = new Vector3(vectorTag);

          if (scale > 0)
          {
            position.scale(scale);
          }

          int[] blockInfo = new int[] { vectorTag.getInteger(NBT_FIELD_BLOCK_ID), vectorTag.getInteger(NBT_FIELD_BLOCK_METADATA) };

          if (position != null)
View Full Code Here

      World world = ((TileEntity) projector).worldObj;

      if (projector.getMode() instanceof ItemModeCustom && !(projector.getModuleCount(ModularForceFieldSystem.itemModuleCamouflage) > 0))
      {
        HashMap<Vector3, int[]> fieldBlocks = ((ItemModeCustom) projector.getMode()).getFieldBlockMap(projector, projector.getModeStack());
        Vector3 fieldCenter = new Vector3((TileEntity) projector).translate(projector.getTranslation());
        Vector3 relativePosition = position.clone().subtract(fieldCenter);
        relativePosition.rotate(-projector.getRotationYaw(), -projector.getRotationPitch());
        blockInfo = fieldBlocks.get(relativePosition.round());
      }

      // Search nearby inventories to extract blocks.
      for (int dir = 0; dir < 6; dir++)
      {
        ForgeDirection direction = ForgeDirection.getOrientation(dir);
        TileEntity tileEntity = VectorHelper.getTileEntityFromSide(((TileEntity) projector).worldObj, new Vector3((TileEntity) projector), direction);

        if (tileEntity instanceof IInventory)
        {
          IInventory inventory = ((IInventory) tileEntity);
View Full Code Here

  @Override
  public Set<Vector3> getExteriorPoints(IFieldInteraction projector)
  {
    Set<Vector3> fieldBlocks = new HashSet<Vector3>();
    Vector3 posScale = projector.getPositiveScale();
    Vector3 negScale = projector.getNegativeScale();

    for (float x = -negScale.intX(); x <= posScale.intX(); x += 0.5f)
    {
      for (float z = -negScale.intZ(); z <= posScale.intZ(); z += 0.5f)
      {
        for (float y = -negScale.intY(); y <= posScale.intY(); y += 0.5f)
        {
          if (y == -negScale.intY() || y == posScale.intY() || x == -negScale.intX() || x == posScale.intX() || z == -negScale.intZ() || z == posScale.intZ())
          {
            fieldBlocks.add(new Vector3(x, y, z));
          }
        }
      }
    }
    return fieldBlocks;
View Full Code Here

  @Override
  public Set<Vector3> getInteriorPoints(IFieldInteraction projector)
  {
    Set<Vector3> fieldBlocks = new HashSet<Vector3>();
    Vector3 posScale = projector.getPositiveScale();
    Vector3 negScale = projector.getNegativeScale();

    for (float x = -negScale.intX(); x <= posScale.intX(); x += 0.5f)
    {
      for (float z = -negScale.intZ(); z <= posScale.intZ(); z += 0.5f)
      {
        for (float y = -negScale.intY(); y <= posScale.intY(); y += 0.5f)
        {
          fieldBlocks.add(new Vector3(x, y, z));
        }
      }
    }

    return fieldBlocks;
View Full Code Here

    for (ForgeDirection direction : this.getOutputDirections())
    {
      if (this.energy.getEnergy() > 0)
      {
        TileEntity tileEntity = new Vector3(this).translate(direction).getTileEntity(this.worldObj);

        if (tileEntity != null)
        {
          long used = CompatibilityModule.receiveEnergy(tileEntity, direction.getOpposite(), energy.extractEnergy(energy.getEnergy(), false), true);
          totalUsed += this.energy.extractEnergy(used, true);
View Full Code Here

    if (tileEntity != null && itemStack != null)
    {
      /** Try to put items into a chest. */
      if (tileEntity instanceof TileMultiBlockPart)
      {
        Vector3 mainBlockPosition = ((TileMultiBlockPart) tileEntity).getMainBlock();

        if (mainBlockPosition != null)
        {
          if (!(mainBlockPosition.getTileEntity(this.worldObj) instanceof TileMultiBlockPart))
          {
            return tryPlaceInPosition(itemStack, mainBlockPosition, direction);
          }
        }
      }
      else if (tileEntity instanceof TileEntityChest)
      {
        TileEntityChest[] chests = { (TileEntityChest) tileEntity, null };

        /** Try to find a double chest. */
        for (int i = 2; i < 6; i++)
        {
          ForgeDirection searchDirection = ForgeDirection.getOrientation(i);
          Vector3 searchPosition = position.clone();
          searchPosition.translate(searchDirection);

          if (searchPosition.getTileEntity(this.worldObj) != null)
          {
            if (searchPosition.getTileEntity(this.worldObj).getClass() == chests[0].getClass())
            {
              chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj);
              break;
            }
          }
        }

View Full Code Here

    {
      for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
      {
        if (itemStack != null)
        {
          itemStack = this.tryPlaceInPosition(itemStack, new Vector3(this).translate(direction), direction);
        }
      }

      if (itemStack != null)
      {
View Full Code Here

TOP

Related Classes of universalelectricity.api.vector.Vector3

Copyright © 2018 www.massapicom. 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.