Package vazkii.botania.common.core.helper

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


  static double interpPosY;
  static double interpPosZ;

  private static Vector3 getRelativeViewVector(Vector3 pos) {
    Entity renderEntity = Minecraft.getMinecraft().renderViewEntity;
    return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
  }
View Full Code Here


    for(Segment rendersegment : bolt.segments) {
      if(rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend)
        continue;

      Vector3 playervec = getRelativeViewVector(rendersegment.startpoint.point).multiply(-1);

      double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F;

      Vector3 diff1 = playervec.copy().crossProduct(rendersegment.prevdiff).normalize().multiply(width / rendersegment.sinprev);
      Vector3 diff2 = playervec.copy().crossProduct(rendersegment.nextdiff).normalize().multiply(width / rendersegment.sinnext);

      Vector3 startvec = rendersegment.startpoint.point;
      Vector3 endvec = rendersegment.endpoint.point;

      int color = inner ? bolt.colorInner : bolt.colorOuter;
      tessellator.setColorRGBA_I(color, (int) (mainalpha * rendersegment.light * new Color(color).getAlpha()));

      tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
      tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
      tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
      tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);

      if(rendersegment.next == null) {
        Vector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().multiply(width));

        tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0);
        tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
        tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);
        tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1);
      }

      if(rendersegment.prev == null) {
        Vector3 roundend = rendersegment.startpoint.point.copy().subtract(rendersegment.diff.copy().normalize().multiply(width));

        tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
        tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0);
        tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1);
        tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
View Full Code Here

      Segment prev = null;

      for(Segment segment : oldsegments) {
        prev = segment.prev;

        Vector3 subsegment = segment.diff.copy().multiply(1F / splits);

        BoltPoint[] newpoints = new BoltPoint[splits + 1];

        Vector3 startpoint = segment.startpoint.point;
        newpoints[0] = segment.startpoint;
        newpoints[splits] = segment.endpoint;

        for(int i = 1; i < splits; i++) {
          Vector3 randoff = segment.diff.copy().perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff);
          randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2);

          Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i));

          newpoints[i] = new BoltPoint(basepoint, randoff);
        }

        for(int i = 0; i < splits; i++) {
          Segment next = new Segment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentno * splits + i, segment.splitno);
          next.prev = prev;
          if (prev != null)
            prev.next = next;

          if(i != 0 && rand.nextFloat() < splitchance) {
            Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff);
            Vector3 diff = next.diff.copy().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).multiply(splitlength);

            numsplits++;
            splitparents.put(numsplits, next.splitno);

            Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[i + 1].basepoint, newpoints[i + 1].offsetvec.copy().add(diff)), segment.light / 2F, next.segmentno, numsplits);
View Full Code Here

        calcDiff();
      }

      public Segment(Vector3 start, Vector3 end) {
        this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
      }
View Full Code Here

        diff = endpoint.point.copy().subtract(startpoint.point);
      }

      public void calcEndDiffs() {
        if(prev != null) {
          Vector3 prevdiffnorm = prev.diff.copy().normalize();
          Vector3 thisdiffnorm = diff.copy().normalize();

          prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
          sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2);
        } else {
          prevdiff = diff.copy().normalize();
          sinprev = 1;
        }

        if(next != null) {
          Vector3 nextdiffnorm = next.diff.copy().normalize();
          Vector3 thisdiffnorm = diff.copy().normalize();

          nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
          sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2);
        } else {
          nextdiff = diff.copy().normalize();
          sinnext = 1;
        }
      }
View Full Code Here

        double y = player.posY -(player.worldObj.isRemote ? 1.62 : 0) + 0.75;
        double z = player.posZ;

        List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range));
        for(EntityItem item : items) {
          MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
          if(player.worldObj.isRemote) {
            boolean red = player.worldObj.rand.nextBoolean();
            Botania.proxy.sparkleFX(player.worldObj, item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
          }
        }
View Full Code Here

      float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius);
      float yTarget = (float) y;
      float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius);

      Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget);
      Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ);
      Vector3 moveVector = targetVec.copy().sub(currentVec);

      burst.setMotion(moveVector.x, moveVector.y, moveVector.z);

      incrementOrbitTime(entity);
    }
View Full Code Here

  }

  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if(!world.isRemote && ManaItemHandler.requestManaExact(stack, player, COST * 2, false)) {
      Vector3 playerVec = Vector3.fromEntityCenter(player);
      Vector3 lookVec = new Vector3(player.getLookVec()).multiply(3);
      Vector3 placeVec = playerVec.copy().add(lookVec);

      int x = MathHelper.floor_double(placeVec.x);
      int y = MathHelper.floor_double(placeVec.y) + 1;
      int z = MathHelper.floor_double(placeVec.z);

View Full Code Here

      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);
      }

      if(item == null) {
        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.size() > 0) {
          item = entities.get(0);
          length = 5.5D;
          if(item instanceof EntityItem)
            length = 2.0D;
        }
      }

      if(ManaItemHandler.requestManaExact(stack, player, COST, true) && item != null) {
        if(item instanceof EntityItem)
          ((EntityItem)item).delayBeforeCanPickup = 5;

        if(item instanceof EntityLivingBase) {
          EntityLivingBase targetEntity = (EntityLivingBase)item;
          targetEntity.fallDistance = 0.0F;
          if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null)
            targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true));
        }

        Vector3 target3 = Vector3.fromEntityCenter(player);
        target3.add(new Vector3(player.getLookVec()).multiply(length));
        target3.y += 0.5;
        if(item instanceof EntityItem)
          target3.y += 0.25;

        for(int i = 0; i < 4; i++) {
View Full Code Here

    }
    return stack;
  }

  public static void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) {
    Vector3 entityVector = Vector3.fromEntityCenter(entity);
    Vector3 finalVector = originalPosVector.copy().subtract(entityVector);

    if(finalVector.mag() > 1)
      finalVector.normalize();

    entity.motionX = finalVector.x * modifier;
    entity.motionY = finalVector.y * modifier;
    entity.motionZ = finalVector.z * modifier;
  }
 
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.