Package vazkii.botania.common.core.helper

Examples of vazkii.botania.common.core.helper.Vector3


      Entity item = null;
      if(targetID != -1 && player.worldObj.getEntityByID(targetID) != null) {
        Entity taritem = player.worldObj.getEntityByID(targetID);

        boolean found = false;
        Vector3 target = Vector3.fromEntityCenter(player);
        List<Entity> entities = new ArrayList<Entity>();
        int distance = 1;
        while(entities.size() == 0 && distance < 25) {
          target.add(new Vector3(player.getLookVec()).multiply(distance));

          target.y += 0.5;
          entities = player.worldObj.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(target.x - RANGE, target.y - RANGE, target.z - RANGE, target.x + RANGE, target.y + RANGE, target.z + RANGE));
          distance++;
          if(entities.contains(taritem))
            found = true;
        }

        if(found) {
          item = player.worldObj.getEntityByID(targetID);
          ItemNBTHelper.setInt(stack, TAG_TARGET, -1);
          ItemNBTHelper.setDouble(stack, TAG_DIST, -1);
          Vector3 moveVector = new Vector3(player.getLookVec().normalize());
          if(item instanceof EntityItem) {
            ((EntityItem)item).delayBeforeCanPickup = 20;
            item.motionX = moveVector.x * 1.5F;
            item.motionY = moveVector.y * 1.0F;
            item.motionZ = moveVector.z * 1.5F;
 
View Full Code Here


  @Override
  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if(!par2World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExact(par1ItemStack, par3EntityPlayer, MANA_COST, false)) {
      Block place = ModBlocks.bifrost;
      Vector3 vector = new Vector3(par3EntityPlayer.getLookVec()).normalize();

      double x = par3EntityPlayer.posX;
      double y = par3EntityPlayer.posY;
      double z = par3EntityPlayer.posZ;
View Full Code Here

    }


    if(worldObj.isRemote && manaToGet > 0 && mana >= manaToGet) {
      if(worldObj.rand.nextInt(20) == 0) {
        Vector3 vec = Vector3.fromTileEntityCenter(this);
        Vector3 endVec = vec.copy().add(0, 2.5, 0);
        Botania.proxy.lightningFX(worldObj, vec, endVec, 2F, 0x00948B, 0x00E4D7);
      }
    }

    if(cooldown > 0) {
View Full Code Here

      if(worldObj.getBlock(centerX, centerY, centerZ) != getBlockForMeta() || meta != 0 && worldObj.getBlockMetadata(centerX, centerY, centerZ) == 0) {
        activated = false;
        return;
      }

      Vector3 centerBlock = new Vector3(centerX + 0.5, centerY + 0.75 + (Math.random() - 0.5 * 0.25), centerZ + 0.5);

      if(meta == 1) {
        if(ConfigHandler.elfPortalParticlesEnabled) {
          double worldTime = (int) worldObj.getTotalWorldTime();
          worldTime += new Random(xCoord ^ yCoord ^ zCoord).nextInt(1000);
          worldTime /= 5;

          float r = 0.75F + (float) Math.random() * 0.05F;
          double x = xCoord + 0.5 + Math.cos(worldTime) * r;
          double z = zCoord + 0.5 + Math.sin(worldTime) * r;

          Vector3 ourCoords = new Vector3(x, yCoord + 0.25, z);
          centerBlock.sub(new Vector3(0, 0.5, 0));
          Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2);

          Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, -0.075F - (float) Math.random() * 0.015F);
          if(worldObj.rand.nextInt(3) == 0)
            Botania.proxy.wispFX(worldObj, x, yCoord + 0.25, z, (float) Math.random() * 0.25F, 0.75F + (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, 0.25F + (float) Math.random() * 0.1F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z);
        }
      } else {
        Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0);
        Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2);

        Block block = worldObj.getBlock(xCoord, yCoord - 1, zCoord);
        if(block == ModBlocks.flower || block == ModBlocks.shinyFlower) {
          int fmeta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord);
          float[] color = EntitySheep.fleeceColorTable[fmeta];
View Full Code Here

            }
          }

          if(didSomething) {
            if(worldObj.isRemote && ConfigHandler.chargingAnimationEnabled && worldObj.rand.nextInt(20) == 0) {
              Vector3 itemVec = Vector3.fromTileEntity(this).add(0.5, 0.5 + Math.random() * 0.3, 0.5);
              Vector3 tileVec = Vector3.fromTileEntity(this).add(0.2 + Math.random() * 0.6, 0, 0.2 + Math.random() * 0.6);
              LightningHandler.spawnLightningBolt(worldObj, outputting ? tileVec : itemVec, outputting ? itemVec : tileVec, 80, worldObj.rand.nextLong(), 0x4400799c, 0x4400C6FF);
            }
          }
        }
      }
View Full Code Here

        double x = pos.hitVec.xCoord - xCoord - 0.5;
        double y = pos.hitVec.yCoord - yCoord - 0.5;
        double z = pos.hitVec.zCoord - zCoord - 0.5;

        if(pos.sideHit != 0 && pos.sideHit != 1) {
          Vector3 clickVector = new Vector3(x, 0, z);
          Vector3 relative = new Vector3(-0.5, 0, 0);
          double angle = Math.acos(clickVector.dotProduct(relative) / (relative.mag() * clickVector.mag())) * 180D / Math.PI;

          rotationX = (float) angle + 180F;
          if(clickVector.z < 0)
            rotationX = 360 - rotationX;
        }
View Full Code Here

    return true;
  }

  @Override
  public boolean bindTo(EntityPlayer player, ItemStack wand, int x, int y, int z, int side) {
    Vector3 thisVec = Vector3.fromTileEntityCenter(this);
    Vector3 blockVec = new Vector3(x + 0.5, y + 0.5, z + 0.5);

    AxisAlignedBB axis = player.worldObj.getBlock(x, y, z).getCollisionBoundingBoxFromPool(player.worldObj, x, y, z);
    if(axis == null)
      axis = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);

    if(!blockVec.isInside(axis))
      blockVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2);

    Vector3 diffVec =  blockVec.copy().sub(thisVec);
    Vector3 diffVec2D = new Vector3(diffVec.x, diffVec.z, 0);
    Vector3 rotVec = new Vector3(0, 1, 0);
    double angle = rotVec.angle(diffVec2D) / Math.PI * 180.0;

    if(blockVec.x < thisVec.x)
      angle = -angle;

    rotationX = (float) angle + 90;

    rotVec = new Vector3(diffVec.x, 0, diffVec.z);
    angle = diffVec.angle(rotVec) * 180F / Math.PI;
    if(blockVec.y < thisVec.y)
      angle = -angle;
    rotationY = (float) angle;

View Full Code Here

    switch(stack.getItemDamage()) {
    case BOUNCE : {
      if(!isManaBlock && pos.entityHit == null) {
        ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
        if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) {
          Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
          ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
          Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();
          Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);

          burst.setMotion(movementVec.x, movementVec.y, movementVec.z);
          dead = false;
        }
      }
View Full Code Here

                IManaReceiver receiver = (IManaReceiver) tile;

                ChunkCoordinates srcCoords = burst.getBurstSourceChunkCoordinates();

                if(MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, srcCoords.posX, srcCoords.posY, srcCoords.posZ) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
                  Vector3 burstVec = Vector3.fromEntity(entity);
                  Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
                  Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);

                  Vector3 normalMotionVec = motionVec.copy().normalize();
                  Vector3 magnetVec = tileVec.sub(burstVec).normalize();
                  Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1);

                  Vector3 finalMotionVec = motionVec.sub(differenceVec);
                  if(!magnetized) {
                    finalMotionVec.multiply(0.75);
                    entity.getEntityData().setBoolean("Botania:Magnetized", true);
                    entity.getEntityData().setInteger("Botania:MagnetizedX", tile.xCoord);
                    entity.getEntityData().setInteger("Botania:MagnetizedY", tile.yCoord);
                    entity.getEntityData().setInteger("Botania:MagnetizedZ", tile.zCoord);
                  }
View Full Code Here

  protected void damageEntity(DamageSource par1DamageSource, float par2) {
    super.damageEntity(par1DamageSource, par2);

    Entity attacker = par1DamageSource.getEntity();
    if(attacker != null) {
      Vector3 thisVector = Vector3.fromEntityCenter(this);
      Vector3 playerVector = Vector3.fromEntityCenter(attacker);
      Vector3 motionVector = thisVector.copy().sub(playerVector).copy().normalize().multiply(0.75);

      if(getHealth() > 0) {
        motionX = -motionVector.x;
        motionY = 0.5;
        motionZ = -motionVector.z;
View Full Code Here

TOP

Related Classes of vazkii.botania.common.core.helper.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.