Package buildcraft.api.core

Examples of buildcraft.api.core.Position


    super.writeToNBT(nbttagcompound);

    if (origin.isSet() && origin.vectO.getMarker(worldObj) == this) {
      NBTTagCompound vectO = new NBTTagCompound();

      new Position(origin.vectO.getMarker(worldObj)).writeToNBT(vectO);
      nbttagcompound.setTag("vectO", vectO);

      for (int i = 0; i < 3; ++i) {
        if (origin.vect[i].isSet()) {
          NBTTagCompound vect = new NBTTagCompound();
          new Position(origin.vect[i].x, origin.vect[i].y, origin.vect[i].z).writeToNBT(vect);
          nbttagcompound.setTag("vect" + i, vect);
        }
      }

    }
View Full Code Here


  public double x = 0;
  public double y = 0;
  public double z = 0;

  public Position translate (Position p) {
    Position p2 = new Position (p);

    p2.x = p.x + x;
    p2.y = p.y + y;
    p2.z = p.z + z;
View Full Code Here

  public void eventHandler(PipeEventItem.DropItem event) {
    if (container.getWorldObj().isRemote) {
      return;
    }
   
    Position p = new Position(container.xCoord, container.yCoord,
        container.zCoord, event.direction);
    p.moveForwards(1.0);

    ItemStack stack = event.entity.getEntityItem();
    EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(),
        (int) p.x, (int) p.y, (int) p.z).get();
   
    switch (event.direction) {
      case DOWN:
        player.rotationPitch = 90;
        player.rotationYaw = 0;
        break;
      case UP:
        player.rotationPitch = 270;
        player.rotationYaw = 0;
        break;
      case NORTH:
        player.rotationPitch = 0;
        player.rotationYaw = 180;
        break;
      case SOUTH:
        player.rotationPitch = 0;
        player.rotationYaw = 0;
        break;
      case WEST:
        player.rotationPitch = 0;
        player.rotationYaw = 90;
        break;
      case EAST:
        player.rotationPitch = 0;
        player.rotationYaw = 270;
        break;
      case UNKNOWN:
        break;
    }
   
    /**
     * Check if there's a handler for this item type.
     */
   
    for (IStripesHandler handler : PipeManager.stripesHandlers) {
      if (handler.getType() == StripesHandlerType.ITEM_USE
          && handler.shouldHandle(stack)) {
        if (handler.handle(getWorld(), (int) p.x, (int) p.y, (int) p.z,
            event.direction, stack, player, this)) {
          return;
        }
      }
    }

    /**
     * Special, generic actions not handled by the handler.
     */
   
    if (convertPipe(transport, event.item)) {
      int moves = 0;
      while (stack.stackSize > 0) {
        if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) != Blocks.air) {
          break;
        }
        stack.getItem().onItemUse(new ItemStack(stack.getItem(), 1, stack.getItemDamage()),
            player, getWorld(), (int) p.x, (int) p.y, (int) p.z, 1, 0, 0, 0
          );
        stack.stackSize--;
        p.moveForwards(1.0);
        moves++;
      }
      if (getWorld().getBlock((int) p.x, (int) p.y, (int) p.z) != Blocks.air) {
        p.moveBackwards(1.0);
        stack.stackSize++;
        getWorld().setBlockToAir((int) p.x, (int) p.y, (int) p.z);
      }
     
      BuildCraftTransport.pipeItemsStripes.onItemUse(new ItemStack(
View Full Code Here

    }
  }
 
  @Override
  public void dropItem(ItemStack itemStack, ForgeDirection direction) {
    Position p = new Position(container.xCoord, container.yCoord,
        container.zCoord, direction);
    p.moveForwards(1.0);

    itemStack.tryPlaceItemIntoWorld(CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld()).get(),
        getWorld(), (int) p.x, (int) p.y, (int) p.z, 1, 0.0f, 0.0f,
        0.0f);
  }
View Full Code Here

    }

    ForgeDirection o = getOpenOrientation();

    if (o != ForgeDirection.UNKNOWN) {
      Position p = new Position(container.xCoord, container.yCoord,
          container.zCoord, o);
      p.moveForwards(1.0);

      if (!BlockUtil.isUnbreakableBlock(getWorld(), (int) p.x, (int) p.y, (int) p.z)) {
        Block block = getWorld().getBlock((int) p.x, (int) p.y, (int) p.z);
        int metadata = getWorld().getBlockMetadata((int) p.x, (int) p.y, (int) p.z);
       
View Full Code Here

    if (container != null && !container.getWorldObj().isRemote) {
      if (getItemStack().stackSize <= 0) {
        return null;
      }

      Position motion = new Position(0, 0, 0, output);
      motion.moveForwards(0.1 + getSpeed() * 2F);

      ItemStack stack = getItemStack();
      EntityItem entity = new EntityItem(container.getWorldObj(), xCoord, yCoord, zCoord, getItemStack());
      entity.lifespan = BuildCraftCore.itemLifespan;
      entity.delayBeforeCanPickup = 10;
View Full Code Here

      sendNetworkUpdate();
    }

    if (laser == null && direction != ForgeDirection.UNKNOWN) {
      laser = new LaserData();
      laser.head = new Position(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F);
      laser.tail = new Position(xCoord + 0.5F + direction.offsetX * 0.5F,
          yCoord + 0.5F + direction.offsetY * 0.5F,
          zCoord + 0.5F + direction.offsetZ * 0.5F);
      laser.isVisible = true;
      sendNetworkUpdate();
    }
View Full Code Here

      return 0;
    }

    if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof PipeTransportItems && isPipeConnected(from)) {
      if (doAdd) {
        Position itemPos = new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, from.getOpposite());
        itemPos.moveBackwards(0.4);

        TravelingItem pipedItem = TravelingItem.make(itemPos.x, itemPos.y, itemPos.z, payload);
        pipedItem.color = color;
        ((PipeTransportItems) pipe.transport).injectItem(pipedItem, itemPos.orientation);
      }
View Full Code Here

      // the below computation is an approximation of the distance to
      // travel for the object. It really follows a sinus, but we compute
      // the size of a triangle for simplification.

      Position middle = new Position();
      middle.x = (destination.x + origin.x) / 2;
      middle.y = (destination.y + origin.y) / 2;
      middle.z = (destination.z + origin.z) / 2;

      Position top = new Position ();
      top.x = middle.x;
      top.y = middle.y + maxHeight;
      top.z = middle.z;

      Position originToTop = new Position ();
      originToTop.x = top.x - origin.x;
      originToTop.y = top.y - origin.y;
      originToTop.z = top.z - origin.z;

      Position destinationToTop = new Position ();
      destinationToTop.x = destination.x - origin.x;
      destinationToTop.y = destination.y - origin.y;
      destinationToTop.z = destination.z - origin.z;

      Position distance = new Position();

      double d1 = Math.sqrt(originToTop.x * originToTop.x + originToTop.y
          * originToTop.y + originToTop.z * originToTop.z);

      double d2 = Math.sqrt(destinationToTop.x * destinationToTop.x + destinationToTop.y
View Full Code Here

      initialized = true;
    }
  }

  public Position getDisplayPosition (double time) {
    Position result = new Position ();

    result.x = origin.x + vx * time;
    result.y = origin.y + vy * time + Math.sin(time / maxLifetime * Math.PI) * maxHeight;
    result.z = origin.z + vz * time;

 
View Full Code Here

TOP

Related Classes of buildcraft.api.core.Position

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.