Package net.minecraft.util

Examples of net.minecraft.util.ChunkCoordinates


  public ChunkCoordinates getPoolCoords(ItemStack stack) {
    int x = ItemNBTHelper.getInt(stack, TAG_POS_X, 0);
    int y = ItemNBTHelper.getInt(stack, TAG_POS_Y, -1);
    int z = ItemNBTHelper.getInt(stack, TAG_POS_Z, 0);
    return new ChunkCoordinates(x, y, z);
  }
View Full Code Here


  public IManaPool getManaPool(ItemStack stack) {
    MinecraftServer server = MinecraftServer.getServer();
    if(server == null)
      return new DummyPool();

    ChunkCoordinates coords = getPoolCoords(stack);
    if(coords.posY == -1)
      return null;

    int dim = getDimension(stack);
    World world = null;
View Full Code Here

                  int yp = y + j;
                  int zp = z + l;
                  Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp);

                  if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp)))
                    validPositions.add(new ChunkCoordinates(xp, yp + 1, zp));
                }

            scanned = true;
          }


          if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
            Block blockToPlace = null;
            if(stackItem instanceof ItemBlock)
              blockToPlace = ((ItemBlock) stackItem).field_150939_a;
            else if(stackItem instanceof ItemReed)
              blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM);
            if(blockToPlace != null) {
              if(blockToPlace instanceof ISpecialFlower)
                return;

              ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
              if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
                supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
                if(ConfigHandler.blockBreakParticles)
                  supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12));
                validPositions.remove(coords);
View Full Code Here

    return swapper;
  }

  private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) {
    switch(meta) {
    case 1 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z),  Blocks.dirt, 2);
    case 2 : return new BlockSwapper(world, new ChunkCoordinates(x, y, z),  Blocks.mycelium, 0);
    default : return new BlockSwapper(world, new ChunkCoordinates(x, y, z),  Blocks.grass, 0);
    }
  }
View Full Code Here

                  int x1 = x + k;
                  int z1 = z + l;
                  Block block1 = world.getBlock(x1, y, z1);
                  int meta1 = world.getBlockMetadata(x1, y, z1);
                  if(block1 == Blocks.dirt && meta1 == 0)
                    validCoords.add(new ChunkCoordinates(x1, y, z1));
                }

              if(!validCoords.isEmpty() && !world.isRemote) {
                ChunkCoordinates coords = validCoords.get(rand.nextInt(validCoords.size()));
                world.setBlock(coords.posX, coords.posY, coords.posZ, blockToSet, metaToSet, 1 | 2);
              }
            }
          }
        }
View Full Code Here

  public ChunkCoordinates getBinding() {
    if(receiver == null)
      return null;

    TileEntity tile = (TileEntity) receiver;
    return new ChunkCoordinates(tile.xCoord, tile.yCoord, tile.zCoord);
  }
View Full Code Here

    EntityThrowable entity = (EntityThrowable) burst;

    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;
        }
      }
      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;
View Full Code Here

                    continue;
                }

                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);
View Full Code Here

                  int y_ = y + dir.offsetY;
                  int z_ = z + dir.offsetZ;

                  Block block_ = par2World.getBlock(x_, y_, z_);
                  if(block_.isAir(par2World, x_, y_, z_) || block_.isReplaceable(par2World, x_, y_, z_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.double_plant) {
                    airBlocks.add(new ChunkCoordinates(x_, y_, z_));
                    hasAir = true;
                  }
                }

                if(hasAir) {
View Full Code Here

  public ChunkCoordinates getSource() {
    int x = dataWatcher.getWatchableObjectInt(23);
    int y = dataWatcher.getWatchableObjectInt(24);
    int z = dataWatcher.getWatchableObjectInt(25);
    return new ChunkCoordinates(x, y, z);
  }
View Full Code Here

TOP

Related Classes of net.minecraft.util.ChunkCoordinates

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.