Examples of Vector3


Examples of thaumcraft.codechicken.lib.vec.Vector3

    public Beam(World par1World, EntityLivingBase par2EntityLivingBase, int potency) {
      super(par1World, par2EntityLivingBase);

      this.potency = potency;
      setProjectileVelocity(motionX / 10, motionY / 10, motionZ / 10);
      movementVector = new Vector3(motionX, motionY, motionZ);
    }
View Full Code Here

Examples of thaumcraft.codechicken.lib.vec.Vector3

        if ((MinecraftServer.getServer().isPVPEnabled() || !(movingobjectposition.entityHit instanceof EntityPlayer)) && movingobjectposition.entityHit != getThrower() && getThrower() instanceof EntityPlayer && !movingobjectposition.entityHit.worldObj.isRemote)
          movingobjectposition.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) getThrower()), 8 + potency);
        return;
      }

      Vector3 movementVec = new Vector3(motionX, motionY, motionZ);
      ForgeDirection dir = ForgeDirection.getOrientation(movingobjectposition.sideHit);
      Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();

      movementVector = normalVector.multiply(-2 * movementVec.dotProduct(normalVector)).add(movementVec);

      motionX = movementVector.x;
      motionY = movementVector.y;
      motionZ = movementVector.z;
    }
View Full Code Here

Examples of thaumcraft.codechicken.lib.vec.Vector3

    }

    List<Entity> entitiesAtEnd = getEntitiesAtPoint(endCoords);
    List<Entity> entitiesAtTarget = getEntitiesAtPoint(targetCoords);

    Vector3 targetToEnd = asVector(targetCoords, endCoords);
    Vector3 endToTarget = asVector(endCoords, targetCoords);

    for (Entity entity : entitiesAtEnd)
      moveEntity(entity, endToTarget);
    for (Entity entity : entitiesAtTarget)
      moveEntity(entity, targetToEnd);
View Full Code Here

Examples of thaumcraft.codechicken.lib.vec.Vector3

  private List<Entity> getEntitiesAtPoint(ChunkCoordinates coords) {
    return worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1));
  }

  private Vector3 asVector(ChunkCoordinates source, ChunkCoordinates target) {
    return new Vector3(target.posX, target.posY, target.posZ).subtract(new Vector3(source.posX, source.posY, source.posZ));
  }
View Full Code Here

Examples of thaumcraft.codechicken.lib.vec.Vector3

        double z2 = entity.posZ;

        float distanceSqrd = blue ? (float) ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)) : 1.1F;

        if (distanceSqrd > 1) {
          MiscHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), speedMod * 0.25F);
          ThaumicTinkerer.tcProxy.sparkle((float) x2, (float) y2, (float) z2, blue ? 2 : 4);
        }
      }
    }
  }
View Full Code Here

Examples of universalelectricity.api.vector.Vector3

  {
    super.updateEntity();

    if (this.anchor == null)
    {
      this.anchor = new Vector3();
    }

    if (this.getMode() != null && Settings.ENABLE_MANIPULATOR)
    {
      /**
       * Manipulator activated and passed all checks. Actually moving the blocks now.
       */
      if (!this.worldObj.isRemote)
      {
        if (this.manipulationVectors != null && this.manipulationVectors.size() > 0 && !this.isCalculatingManipulation)
        {
          /**
           * This section is called when blocks set events are set and animation packets
           * are to be sent.
           */
          NBTTagCompound nbt = new NBTTagCompound();
          NBTTagList nbtList = new NBTTagList();

          // Number of blocks we're actually moving.
          int i = 0;

          for (Vector3 position : this.manipulationVectors)
          {
            if (this.moveBlock(position) && this.isBlockVisibleByPlayer(position) && i < Settings.MAX_FORCE_FIELDS_PER_TICK)
            {
              nbtList.appendTag(position.writeToNBT(new NBTTagCompound()));
              i++;
            }
          }

          if (i > 0)
          {
            queueEvent(new DelayedEvent(this, getMoveTime())
            {
              @Override protected void onEvent()
              {
                moveEntities();
                PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(TileForceManipulator.this, TilePacketType.FIELD.ordinal()));
              }
            });

            nbt.setByte("type", (byte) 2);
            nbt.setTag("list", nbtList);

            if (!this.isTeleport())
            {
              PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 1, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);

              if (this.getModuleCount(ModularForceFieldSystem.itemModuleSilence) <= 0)
              {
                this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "fieldmove", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
              }

              if (this.doAnchor)
              {
                this.anchor = this.anchor.translate(this.getDirection());
              }
            }
            else
            {
              PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 2, this.getMoveTime(), this.getAbsoluteAnchor().translate(0.5), this.getTargetPosition().translate(0.5).writeToNBT(new NBTTagCompound()), false, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
              this.moveTime = this.getMoveTime();
            }
          }
          else
          {
            this.markFailMove = true;
          }

          this.manipulationVectors = null;
          this.onInventoryChanged();
        }
      }

      /**
       * While the field is being TELEPORTED ONLY.
       */
      if (this.moveTime > 0)
      {
        if (this.isTeleport() && this.requestFortron(this.getFortronCost(), true) >= this.getFortronCost())
        {
          if (this.getModuleCount(ModularForceFieldSystem.itemModuleSilence) <= 0 && this.ticks % 10 == 0)
          {
            int moveTime = this.getMoveTime();
            this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "fieldmove", 1.5f, 0.5f + 0.8f * (moveTime - this.moveTime) / moveTime);
          }

          if (--this.moveTime == 0)
          {
            this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "teleport", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
          }
        }
        else
        {
          this.markFailMove = true;
        }
      }

      /**
       * Force Manipulator activated, try start moving...
       */
      if (isActive())
      {
        markActive = true;
      }

      if (ticks % 20 == 0 && markActive)
      {
        if (moveTime <= 0 && requestFortron(this.getFortronCost(), false) > 0)
        {
          if (!worldObj.isRemote)
          {
            requestFortron(getFortronCost(), true);
            // Start multi-threading calculations
            (new ManipulatorCalculationThread(this)).start();
          }

          moveTime = 0;
        }

        if (!worldObj.isRemote)
        {
          setActive(false);
        }

        markActive = false;
      }

      /**
       * Render preview
       */
      if (!this.worldObj.isRemote)
      {
        if (!this.isCalculated)
        {
          this.calculateForceField();
        }

        // Manipulation area preview
        if (this.ticks % 120 == 0 && !this.isCalculating && Settings.HIGH_GRAPHICS && this.delayedEvents.size() <= 0 && this.displayMode > 0)
        {
          NBTTagCompound nbt = new NBTTagCompound();
          NBTTagList nbtList = new NBTTagList();

          int i = 0;
          for (Vector3 position : this.getInteriorPoints())
          {
            if (this.isBlockVisibleByPlayer(position) && (this.displayMode == 2 || !this.worldObj.isAirBlock(position.intX(), position.intY(), position.intZ()) && i < Settings.MAX_FORCE_FIELDS_PER_TICK))
            {
              i++;
              nbtList.appendTag(new Vector3(position).writeToNBT(new NBTTagCompound()));
            }
          }

          nbt.setByte("type", (byte) 1);
          nbt.setTag("list", nbtList);

          if (this.isTeleport())
          {
            Vector3 targetPosition;
            if (getTargetPosition().world == null)
            {
              targetPosition = new Vector3(getTargetPosition());
            }
            else
            {
              targetPosition = getTargetPosition();
            }

            PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 2, 60, getAbsoluteAnchor().translate(0.5), targetPosition.translate(0.5).writeToNBT(new NBTTagCompound()), true, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
          }
          else
          {
            PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 1, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
          }
        }
      }

      if (this.markFailMove)
      {
        this.moveTime = 0;
        delayedEvents.clear();
        this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "powerdown", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
        PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.RENDER.ordinal()), this.worldObj, new Vector3(this), PACKET_DISTANCE);
        this.markFailMove = false;

        /**
         * Send failed positions to client to inform them WHICH blocks are causing the field
         * to fail.
         */
        NBTTagCompound nbt = new NBTTagCompound();
        NBTTagList nbtList = new NBTTagList();

        for (Vector3 position : this.failedPositions)
        {
          nbtList.appendTag(position.writeToNBT(new NBTTagCompound()));
        }

        nbt.setByte("type", (byte) 1);
        nbt.setTag("list", nbtList);

        this.failedPositions.clear();
        PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 3, nbt), this.worldObj, new Vector3(this), PACKET_DISTANCE);
      }
    }
    else if (!worldObj.isRemote && isActive())
    {
      setActive(false);
View Full Code Here

Examples of universalelectricity.core.vector.Vector3

        super.updateEntity();
       
        if (!this.worldObj.isRemote)
        {
            ForgeDirection inputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() + 2);
            TileEntity inputTile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection);
           
            if (inputTile instanceof INetworkProvider)
                this.network = ((INetworkProvider) inputTile).getNetwork();
            else
                this.network = null;
        }
       
        if (this.inventory[0] != null && this.energyStored < this.getMaxEnergyStored())
        {
            if (this.inventory[0].getItem() instanceof IItemElectric)
            {
                this.setEnergyStored(this.getEnergyStored() + (PowerUtils.UE.discharge(this.inventory[0], PowerConversionUtils.INSTANCE.new UEElectricPack((this.getMaxEnergyStored() - this.getEnergyStored()) / this.getVoltage(), this.getVoltage()), 2).toUEWatts()));
            }
            else if (this.inventory[0].getItem() instanceof IElectricItem)
            {
                this.setEnergyStored(this.getEnergyStored() + (PowerUtils.IC2.discharge(this.inventory[0], PowerConversionUtils.INSTANCE.new UEElectricPack((this.getMaxEnergyStored() - this.getEnergyStored()) / this.getVoltage(), this.getVoltage()), 2).toUEWatts()));
            }
           
        }
       
        if (this.energyStored >= WATTS_PER_TICK - .0500F)
        {
            // The left slot contains the item to be processed
            if (this.inventory[1] != null && this.canDraw() && (this.processTicks == 0 || this.baseID != this.inventory[1].itemID
                || this.baseMeta != this.inventory[1].getItemDamage()))
            {
                this.baseID = this.inventory[1].itemID;
                this.baseMeta = this.inventory[1].getItemDamage();
                this.processTicks = this.getDrawingTime();
                this.recipeTicks = this.getDrawingTime();
            }
           
            // Checks if the item can be processed and if the drawing time left is
            // greater than 0, if so, then draw the item.
            if (this.canDraw() && this.processTicks > 0)
            {
                this.processTicks--;
               
                // When the item is finished drawing
                if (this.processTicks < 1)
                {
                    this.drawItem();
                    this.processTicks = 0;
                }
                this.energyStored -= WATTS_PER_TICK;
            }
            else
            {
                this.processTicks = 0;
            }
        }
       
        if (!this.worldObj.isRemote)
        {
            if (this.ticks % 3 == 0 && this.playersUsing > 0)
            {
                PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
            }
        }
       
        this.energyStored = Math.min(this.energyStored, this.getMaxEnergyStored());
        this.energyStored = Math.max(this.energyStored, 0f);
View Full Code Here

Examples of universalelectricity.core.vector.Vector3

    @Override
    public void openChest()
    {
        if (!this.worldObj.isRemote)
        {
            PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 15);
        }
        this.playersUsing++;
    }
View Full Code Here

Examples of universalelectricity.core.vector.Vector3

    {
        super.updateEntity();
       
        if (!this.worldObj.isRemote && this.ticks % 3 == 0)
        {
            TileEntity inputTile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), this.input);
           
            // Check if requesting power on output
            TileEntity outputTile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), this.output);
           
            this.inputNetwork = ElectricityHelper.getNetworkFromTileEntity(inputTile, this.input);
            this.outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, this.output);
           
            PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
        }
        this.produceUE(this.output);
    }
View Full Code Here

Examples of universalelectricity.core.vector.Vector3

    {
        if (this.output != dir)
        {
            this.input = dir;
            if (!this.worldObj.isRemote)
                PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
            this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
            this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, ElectricExpansionItems.blockTransformer.blockID);
        }
    }
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.