Package net.minecraftforge.common.util

Examples of net.minecraftforge.common.util.ForgeDirection


    MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 4.5);
    if(block == null)
      return false;

    ForgeDirection direction = ForgeDirection.getOrientation(block.sideHit);
    int fortune = EnchantmentHelper.getFortuneModifier(player);
    boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
    boolean doX = direction.offsetX == 0;
    boolean doY = direction.offsetY == 0;
    boolean doZ = direction.offsetZ == 0;
View Full Code Here


    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;
        }
      }
      break;
    }
    case MINE : {
      World world = entity.worldObj;
      int x = pos.blockX;
      int y = pos.blockY;
      int z = pos.blockZ;
      Block block = world.getBlock(x, y, z);
      TileEntity tile = world.getTileEntity(x, y, z);

      int meta = world.getBlockMetadata(x, y, z);
      float hardness = block.getBlockHardness(world, x, y, z);
      int mana = burst.getMana();

      ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
      if((coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && block != null && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
        List<ItemStack> items = new ArrayList();

        items.addAll(block.getDrops(world, x, y, z, meta, 0));

        if(!burst.hasAlreadyCollidedAt(x, y, z)) {
          if(!burst.isFake() && !entity.worldObj.isRemote) {
            world.setBlockToAir(x, y, z);
            if(ConfigHandler.blockBreakParticles)
              entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));

            for(ItemStack stack_ : items)
              world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack_));
            burst.setMana(mana - 24);
          }
        }

        dead = false;
      }
      break;
    }
    case PHANTOM : {
      if(!isManaBlock) {
        dead = false;
        burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4));
      }
      break;
    }
    case EXPLOSIVE : {
      if(!burst.isFake()) {
        ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
        if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
          entity.worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true);
      } else dead = false;
      break;
    }
    case WEIGHT : {
      if(!burst.isFake()) {
        int x = pos.blockX;
        int y = pos.blockY;
        int z = pos.blockZ;
        Block block = entity.worldObj.getBlock(x, y, z);
        Block blockBelow = entity.worldObj.getBlock(x, y - 1, z);
        if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && entity.worldObj.getTileEntity(x, y, z) == null) {
          EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, entity.worldObj.getBlockMetadata(x, y, z));
          if(!entity.worldObj.isRemote)
            entity.worldObj.spawnEntityInWorld(falling);
        }
      }
      break;
    }
    case PAINT : {
      int storedColor = getStoredColor(stack);
      if(!burst.isFake() && storedColor > -1 && storedColor < 17) {
        if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) {
          int r = 20;
          int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
          List<EntitySheep> sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r));
          for(EntitySheep sheep : sheepList) {
            if(sheep.getFleeceColor() == sheepColor)
              sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
          }
          dead = true;
        } else {
          Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
          if(paintableBlocks.contains(block)) {
            int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
            List<ChunkCoordinates> coordsToPaint = new ArrayList();
            List<ChunkCoordinates> coordsFound = new ArrayList();

            ChunkCoordinates theseCoords = new ChunkCoordinates(pos.blockX, pos.blockY, pos.blockZ);
            coordsFound.add(theseCoords);

            do {
              List<ChunkCoordinates> iterCoords = new ArrayList(coordsFound);
              for(ChunkCoordinates coords : iterCoords) {
                coordsFound.remove(coords);
                coordsToPaint.add(coords);

                for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
                  Block block_ = entity.worldObj.getBlock(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
                  int meta_ = entity.worldObj.getBlockMetadata(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
                  ChunkCoordinates coords_ = new ChunkCoordinates(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
                  if(block_ == block && meta_ == meta && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_))
                    coordsFound.add(coords_);
                }
              }
            } while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000);

            for(ChunkCoordinates coords : coordsToPaint) {
              int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor;
              int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);

              if(metaThere != placeColor) {
                if(!entity.worldObj.isRemote)
                  entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2);
                float[] color = EntitySheep.fleeceColorTable[placeColor];
                float r = color[0];
                float g = color[1];
                float b = color[2];
                for(int i = 0; i < 4; i++)
                  Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);

              }
            }
          }
        }
      }
      break;
    }
    case FIRE : {
      ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
      if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
        ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);

        int x = pos.blockX + dir.offsetX;
        int y = pos.blockY + dir.offsetY;
        int z = pos.blockZ + dir.offsetZ;

        Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
        Block blockAt_ = entity.worldObj.getBlock(x, y, z);

        if(blockAt == Blocks.portal)
          entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
        else if(blockAt_.isAir(entity.worldObj, x, y, z))
          entity.worldObj.setBlock(x, y, z, Blocks.fire);
      }

      break;
    }
    case PISTON : {
      ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
      if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) {
        ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite();
        int x = pos.blockX + dir.offsetX;
        int y = pos.blockY + dir.offsetY;
        int z = pos.blockZ + dir.offsetZ;

        if(entity.worldObj.isAirBlock(x, y, z) || entity.worldObj.getBlock(x, y, z).isReplaceable(entity.worldObj, x, y, z)) {
View Full Code Here

  }

  @Override
  public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if(ManaItemHandler.requestManaExact(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.isHellWorld) {
      ForgeDirection dir = ForgeDirection.getOrientation(par7);

      ItemStack stackToPlace = new ItemStack(Blocks.flowing_water);
      stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);

      if(stackToPlace.stackSize == 0) {
View Full Code Here

      for(int i = handlerCache.length; i-- > 0;) {
        IEnergyHandler tile = handlerCache[i];
        if (tile == null)
          continue;

        ForgeDirection from = ForgeDirection.VALID_DIRECTIONS[i];
        if(tile.receiveEnergy(from, energy, true) > 0)
          energy -= tile.receiveEnergy(from, energy * 10, false) / 10;

        if(energy <= 0)
          return 0;
View Full Code Here

        decrCoords(s);

        if(block == Blocks.piston_extension) {
          int meta = getBlockMetaAt(s);
          boolean sticky = (meta & 8) == 8;
          ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8);

          MinecraftServer server = MinecraftServer.getServer();

          if(server != null && getTimeInCoords(s) == 0) {
            String newPos;
View Full Code Here

  }

  @Override
  public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if(ManaItemHandler.requestManaExact(par1ItemStack, par2EntityPlayer, COST, false)) {
      ForgeDirection dir = ForgeDirection.getOrientation(par7);
      int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size();

      if(entities == 0) {
        ItemStack stackToPlace = new ItemStack(Blocks.dirt);
        stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
View Full Code Here

      while(rotorPosition < rotorInfo.rotorLength) {
        // Current block is a rotor
        // Get list of normals
        int bladeLength;
        ForgeDirection bladeDir;
        for(int bladeIdx = 0; bladeIdx < dirsToCheck.length; bladeIdx++) {
          bladeDir = dirsToCheck[bladeIdx];
          bladeCoord.copy(currentCoord);
          bladeCoord.translate(bladeDir);
          bladeLength = 0;
View Full Code Here

    pumpDestination = null;
    if(worldObj.isRemote || flowSetting == FluidFlow.In) {
      return;
    }

    ForgeDirection outDir = getOutwardsDir();
    if(outDir == ForgeDirection.UNKNOWN) {
      return;
    }
   
    TileEntity neighbor = worldObj.getTileEntity(xCoord + outDir.offsetX, yCoord + outDir.offsetY, zCoord + outDir.offsetZ);
View Full Code Here

    _inventories[SLOT_OUTLET] = adjacencyHelper.distribute(_inventories[SLOT_OUTLET]);
    markChunkDirty();
  }
 
  protected void checkForAdjacentInventories() {
    ForgeDirection outDir = getOutwardsDir();

    if(adjacencyHelper == null && outDir != ForgeDirection.UNKNOWN) {
      adjacencyHelper = new AdjacentInventoryHelper(outDir);
    }
View Full Code Here

    if(!this.isConnected()) { return; }

    ticksSinceLastUpdate++;
    if(ticksSinceLastUpdate < BigReactors.ticksPerRedstoneUpdate) { return; }

    ForgeDirection out = getOutwardsDir();
   
    if(redNetwork != null) {
        redNetwork.updateNetwork(worldObj, xCoord+out.offsetX, yCoord+out.offsetY, zCoord+out.offsetZ, out.getOpposite());
    }
   
    if(redNetInput != null) {
      redNetInput.onInputsChanged(worldObj, xCoord+out.offsetX, yCoord+out.offsetY, zCoord+out.offsetZ, out.getOpposite(), getOutputValues());
    }

    ticksSinceLastUpdate = 0;
  }
View Full Code Here

TOP

Related Classes of net.minecraftforge.common.util.ForgeDirection

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.