Package net.minecraft.world.chunk

Examples of net.minecraft.world.chunk.Chunk


        EntityPlayer player = Platform.getPlayer( (WorldServer) w );
        Platform.configurePlayer( player, side, tile );

        if ( i instanceof ItemFirework )
        {
          Chunk c = w.getChunkFromBlockCoords( x, z );
          int sum = 0;
          for (List Z : c.entityLists)
            sum += Z.size();
          if ( sum > 32 )
            return input;
        }
        maxStorage = is.stackSize;
        worked = true;
        if ( type == Actionable.MODULATE )
        {
          if ( i instanceof IPlantable || i instanceof ItemSkull || i instanceof ItemReed )
          {
            boolean Worked = false;

            if ( side.offsetX == 0 && side.offsetZ == 0 )
              Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(),
                  side.offsetX, side.offsetY, side.offsetZ );

            if ( !Worked && side.offsetX == 0 && side.offsetZ == 0 )
              Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX,
                  side.offsetY, side.offsetZ );

            if ( !Worked && side.offsetY == 0 )
              Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ );

            if ( !Worked )
              i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );

            maxStorage = maxStorage - is.stackSize;
          }
          else
          {
            i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ );
            maxStorage = maxStorage - is.stackSize;
          }
        }
        else
          maxStorage = 1;
      }
      else
      {
        worked = true;
        Chunk c = w.getChunkFromBlockCoords( x, z );
        int sum = 0;
        for (List Z : c.entityLists)
          sum += Z.size();

        if ( sum < AEConfig.instance.formationPlaneEntityLimit )
View Full Code Here


    int hi_y = low_y + 32;

    Block skystone = AEApi.instance().blocks().blockSkyStone.block();

    // lower level...
    Chunk c = w.getChunkFromBlockCoords( x, z );

    for (int i = 0; i < 16; i++)
    {
      for (int j = 0; j < 16; j++)
      {
        for (int k = low_y; k < hi_y; k++)
        {
          Block blk = c.getBlock( i, k, j );
          if ( blk == skystone && c.getBlockMetadata( i, k, j ) == 0 )
          {
            return executor.submit( new CMUpdatePost( w, cx, cz, cdy, true ) );
          }
        }
      }
View Full Code Here

  }

  @Override
  public Chunk provideChunk(int x, int z)
  {
    Chunk chunk = new Chunk( w, blocks, x, z );

    byte[] biomes = chunk.getBiomeArray();
    AEConfig config = AEConfig.instance;

    for (int k = 0; k < biomes.length; ++k)
      biomes[k] = (byte) config.storageBiomeID;

    if ( !chunk.isTerrainPopulated )
    {
      chunk.isTerrainPopulated = true;
      chunk.resetRelightChecks();
    }

    return chunk;
  }
View Full Code Here

      return;
    }

    if (scan) {
      int[] coords = getCoords();
      Chunk chunk = worldObj.getChunkFromChunkCoords(coords[0], coords[1]);
      loadChunk(chunk);

      if (chunkIt > RESOLUTION_CHUNKS * RESOLUTION_CHUNKS) {
        scan = false;
        chunkIt = 0;
View Full Code Here

        while (chunks.size() < 5 && (chunkCoordIntPair = (ChunkCoordIntPair) entityPlayerMP.loadedChunks.remove(0)) != null) {
          int x = chunkCoordIntPair.chunkXPos;
          int z = chunkCoordIntPair.chunkZPos;

          Chunk chunk = entityPlayerMP.worldObj.getChunkIfExists(x, z);
          if (chunk == null) {
            continue;
          }
          synchronized (chunk) {
            if (!chunk.isTerrainPopulated) {
              unpopulatedChunks.add(chunkCoordIntPair);
              continue;
            }
          }
          chunks.add(chunk);
          tileEntities.addAll(chunk.chunkTileEntityMap.values());
        }
      }
      entityPlayerMP.loadedChunks.addAll(unpopulatedChunks);

      if (!chunks.isEmpty()) {
        netServerHandler.sendPacketToPlayer(new Packet56MapChunks(chunks));
        Iterator iterator = tileEntities.iterator();

        while (iterator.hasNext()) {
          Packet descriptionPacket;
          try {
            descriptionPacket = ((TileEntity) iterator.next()).getDescriptionPacket();
          } catch (Throwable t) {
            Log.warning("A TileEntity failed to provide a description packet", t);
            continue;
          }
          if (descriptionPacket != null) {
            netServerHandler.sendPacketToPlayer(descriptionPacket);
          }
        }

        iterator = chunks.iterator();

        while (iterator.hasNext()) {
          Chunk var10 = (Chunk) iterator.next();
          entityPlayerMP.getServerForPlayer().getEntityTracker().func_85172_a(entityPlayerMP, var10);
          try {
            MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(var10.getChunkCoordIntPair(), entityPlayerMP));
          } catch (Throwable t) {
            Log.severe("A mod failed to handle a ChunkWatch event", t);
          }
        }
      }
View Full Code Here

      }
    }
  }

  private int getTopBlock(World world, int x, int z) {
    Chunk chunk = world.getChunkFromBlockCoords(x, z);
    int y = chunk.getTopFilledSegment() + 15;

    int trimmedX = x & 15;
    int trimmedZ = z & 15;

    for (; y > 0; --y) {
      Block block = chunk.getBlock(trimmedX, y, trimmedZ);

      if (block.isAir(world, x, y, z)) {
        continue;
      }
View Full Code Here

  public static int getEntityCount(WorldServer server, Class oClass) {
    return server.countEntities(oClass);
  }

  private static int getPseudoRandomHeightValue(int wX, int wZ, WorldServer worldServer, boolean surface, int gapChance) {
    Chunk chunk = worldServer.getChunkIfExists(wX >> 4, wZ >> 4);
    if (chunk == null) {
      return -1;
    }
    int x = wX & 15;
    int z = wZ & 15;
    int height = chunk.getHeightValue(x, z);
    if (surface) {
      return height;
    }
    boolean inGap = false;
    int lastGap = 0;
    for (int y = 1; y < height; y++) {
      int blockId = chunk.getBlockID(x, y, z);
      if (blockId == 0) {
        if (!inGap) {
          inGap = true;
          if (gapChance++ % 3 == 0) {
            return y;
View Full Code Here

        long key = key_;
        int x = (int) key;
        int z = (int) (key >> 32);
        chunkCoordIntPair.chunkXPos = x;
        chunkCoordIntPair.chunkZPos = z;
        Chunk chunk = (Chunk) chunks.getValueByKey(key);
        if (chunk == null) {
          continue;
        }
        synchronized (chunk) {
          if (chunk.partiallyUnloaded || !chunk.queuedUnload || unloadingChunks.containsItem(key)) {
            continue;
          }
          if (persistentChunks.containsKey(chunkCoordIntPair) || playerManager.getOrCreateChunkWatcher(x, z, false) != null || !fireBukkitUnloadEvent(chunk)) {
            chunk.queuedUnload = false;
            continue;
          }
          if (lastChunk == chunk) {
            lastChunk = null;
          }
          chunk.partiallyUnloaded = true;
          chunk.onChunkUnloadTT();
          chunk.pendingBlockUpdates = world.getPendingBlockUpdates(chunk, false);
          loadedChunks.remove(chunk);
          chunks.remove(key);
          synchronized (unloadingChunks) {
            unloadingChunks.put(key, chunk);
View Full Code Here

      }
    }
  }

  private boolean finalizeUnload(long key) {
    Chunk chunk;
    synchronized (unloadingChunks) {
      // Don't remove here, as the chunk should be in the unloadingChunks map so that getChunkIfExists will still return it if used by a mod during chunk saving.
      chunk = (Chunk) unloadingChunks.getValueByKey(key);
    }
    if (chunk == null) {
View Full Code Here

  public boolean unloadChunk(int x, int z) {
    if (world.getPersistentChunks().keySet().contains(new ChunkCoordIntPair(x, z))) {
      return false;
    }
    long hash = key(x, z);
    Chunk chunk = (Chunk) chunks.getValueByKey(hash);
    if (chunk == null) {
      return false;
    }
    chunk.queuedUnload = true;
    return unloadStage0.add(hash);
View Full Code Here

TOP

Related Classes of net.minecraft.world.chunk.Chunk

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.