Package net.minecraft.world.chunk

Examples of net.minecraft.world.chunk.Chunk


        WorldServer worldServer = provider.getWorld();
        if (worldServer.unloaded) {
          FMLLog.warning("Failed to load chunk at " + worldServer.getDimension() + ':' + x + ',' + z + " asynchronously. The world is no longer loaded.");
          return;
        }
        Chunk chunk = provider.getChunkAt(x, z, allowGenerate, regenerate, null);
        if (chunk == null || (allowGenerate && chunk instanceof EmptyChunk)) {
          FMLLog.warning("Failed to load chunk at " + Log.name(worldServer) + ':' + x + ',' + z + " asynchronously. Provided " + chunk);
        } else {
          ChunkProviderServer.onChunkLoad(chunk, runnable);
        }
View Full Code Here


    if (entityChunkX != xPosition || entityChunkZ != zPosition) {
      if (Log.debug) {
        FMLLog.log(Log.DEBUG, new Throwable(), "Entity %s added to the wrong chunk - expected x%d z%d, got x%d z%d", par1Entity.toString(), xPosition, zPosition, entityChunkX, entityChunkZ);
      }
      if (worldObj instanceof WorldServer) {
        Chunk correctChunk = ((WorldServer) worldObj).theChunkProviderServer.getChunkIfExists(entityChunkX, entityChunkZ);
        if (correctChunk == this) {
          Log.severe("What?! This chunk isn't at the position it says it's at...: " + this + " was added at " + entityChunkX + ", " + entityChunkZ);
        } else if (correctChunk != null) {
          correctChunk.addEntity(par1Entity);
          return;
        }
      }
    }
View Full Code Here

      }
      int x = entity.chunkCoordX;
      int z = entity.chunkCoordZ;

      if (entity.addedToChunk) {
        Chunk chunk = chunkProviderServer.getChunkIfExists(x, z);
        if (chunk != null) {
          chunk.removeEntity(entity);
        }
      }

      world.onEntityRemoved(entity);
View Full Code Here

            toRemove.add(e);
            duplicateEntities++;
            fixed++;
          } else if (e instanceof IProjectile || e instanceof EntityCreature || e instanceof EntityMob) {
            synchronized (e) {
              Chunk chunk = world.getChunkIfExists(e.chunkCoordX, e.chunkCoordZ);
              if (chunk == null || !chunk.entityLists[e.chunkCoordY].contains(e)) {
                unloaded.add(e);
                unloadedEntities++;
              }
            }
          }
        }
        for (Entity e : unloaded) {
          remove(e);
        }
        entityList.removeAll(toRemove);
      }
    }

    {
      Set<TileEntity> contained = new HashSet<TileEntity>();
      Set<TileEntity> toRemove = new ContainedRemoveSet<TileEntity>();
      List<TileEntity> copy = new ArrayList<TileEntity>(tileEntityList.size());
      synchronized (tileEntityLock) {
        for (TileEntity te : tileEntityList) {
          copy.add(te);
          if (add(te, false)) {
            missingTiles++;
            fixed++;
          }
          if (!contained.add(te)) {
            toRemove.add(te);
            duplicateTiles++;
            fixed++;
          }
        }
        tileEntityList.removeAll(toRemove);
      }

      for (TileEntity te : copy) {
        Chunk chunk;
        boolean invalid = te.isInvalid();
        if (te.yCoord < 0 || te.yCoord > 255) {
          sb.append("TileEntity ").append(Log.toString(te)).append(" has an invalid y coordinate.\n");
          invalid = true;
        }
        if (invalid || (chunk = chunkProviderServer.getChunkIfExists(te.xCoord >> 4, te.zCoord >> 4)) == null || chunk.getChunkBlockTileEntity(te.xCoord & 15, te.yCoord, te.zCoord & 15) != te) {
          if (invalid) {
            invalidTiles++;
            sb.append("Removed ").append(Log.toString(te)).append(" as it is invalid.\n");
          } else {
            unloadedTiles++;
View Full Code Here

      }

      int cX = chunkCoordIntPair.chunkXPos;
      int cZ = chunkCoordIntPair.chunkZPos;

      Chunk chunk = chunkProviderServer.getChunkFastUnsafe(cX, cZ);
      if (chunk == null || !chunk.isTerrainPopulated || chunk.partiallyUnloaded || chunk.queuedUnload) {
        continue;
      }

      int xPos = cX * 16;
      int zPos = cZ * 16;
      this.moodSoundAndLightCheck(xPos, zPos, chunk);
      chunk.updateSkylight();
      int var8;
      int var9;
      int var10;
      int var11;

      if (isRaining && isThundering && provider.canDoLightning(chunk) && rand.nextInt(100000) == 0) {
        updateLCG = updateLCG * 1664525 + 1013904223;
        var8 = updateLCG >> 2;
        var9 = xPos + (var8 & 15);
        var10 = zPos + (var8 >> 8 & 15);
        var11 = this.getPrecipitationHeight(var9, var10);

        if (this.canLightningStrikeAt(var9, var11, var10)) {
          this.addWeatherEffect(new EntityLightningBolt(this, (double) var9, (double) var11, (double) var10));
        }
      }

      int blockID;

      if (provider.canDoRainSnowIce(chunk) && rand.nextInt(16) == 0) {
        updateLCG = updateLCG * 1664525 + 1013904223;
        var8 = updateLCG >> 2;
        var9 = var8 & 15;
        var10 = var8 >> 8 & 15;
        var11 = this.getPrecipitationHeight(var9 + xPos, var10 + zPos);

        if (this.isBlockFreezableNaturally(var9 + xPos, var11 - 1, var10 + zPos)) {
          this.setBlock(var9 + xPos, var11 - 1, var10 + zPos, Block.ice.blockID);
        }

        if (isRaining) {
          if (this.canSnowAt(var9 + xPos, var11, var10 + zPos)) {
            this.setBlock(var9 + xPos, var11, var10 + zPos, Block.snow.blockID);
          }

          BiomeGenBase var12 = this.getBiomeGenForCoords(var9 + xPos, var10 + zPos);

          if (var12.canSpawnLightningBolt()) {
            blockID = this.getBlockIdWithoutLoad(var9 + xPos, var11 - 1, var10 + zPos);

            if (blockID > 0) {
              Block.blocksList[blockID].fillWithRain(this, var9 + xPos, var11 - 1, var10 + zPos);
            }
          }
        }
      }

      ExtendedBlockStorage[] var19 = chunk.getBlockStorageArray();
      var9 = var19.length;

      for (var10 = 0; var10 < var9; ++var10) {
        ExtendedBlockStorage ebs = var19[var10];

View Full Code Here

      }
    }
  }

  private boolean noUpdateRequired() {
    Chunk chunk = this.chunk;
    if (chunk == null || !chunk.isTerrainPopulated || playersInChunk.isEmpty()) {
      return true;
    }
    if (chunk.partiallyUnloaded) {
      this.loaded = false;
View Full Code Here

          Log.warning("numberOfTilesToUpdate set too high. Got " + numberOfTilesToUpdate + " should be <= " + locationOfBlockChange.length);
          numberOfTilesToUpdate = locationOfBlockChange.length;
        }

        WorldServer worldServer = thePlayerManager.getWorldServer();
        Chunk chunk = this.chunk;
        if (numberOfTilesToUpdate == 1) {
          int x = chunkLocation.chunkXPos * 16 + (locationOfBlockChange[0] >> 12 & 15);
          int y = locationOfBlockChange[0] & 255;
          int z = chunkLocation.chunkZPos * 16 + (locationOfBlockChange[0] >> 8 & 15);
          sendToAllPlayersWatchingChunk(new Packet53BlockChange(x, y, z, worldServer));

          TileEntity tileEntity = chunk.getChunkBlockTileEntity(locationOfBlockChange[0] >> 12 & 15, locationOfBlockChange[0] & 255, locationOfBlockChange[0] >> 8 & 15);
          if (tileEntity != null) {
            tilesToUpdate.add(tileEntity);
          }
        } else {
          if (numberOfTilesToUpdate >= ForgeDummyContainer.clumpingThreshold) {
            sendToAllPlayersWatchingChunk(new Packet51MapChunk(chunk, false, flagsYAreasToUpdate));
          } else {
            sendToAllPlayersWatchingChunk(new Packet52MultiBlockChange(chunkLocation.chunkXPos, chunkLocation.chunkZPos, locationOfBlockChange, numberOfTilesToUpdate, worldServer));
          }

          for (int i = 0; i < numberOfTilesToUpdate; ++i) {
            TileEntity tileEntity = chunk.getChunkBlockTileEntity(locationOfBlockChange[i] >> 12 & 15, locationOfBlockChange[i] & 255, locationOfBlockChange[i] >> 8 & 15);
            if (tileEntity != null) {
              tilesToUpdate.add(tileEntity);
            }
          }
        }
View Full Code Here

            int entityX = entity.chunkCoordX;
            int entityZ = entity.chunkCoordZ;

            synchronized (entity) {
              if (entity.addedToChunk) {
                Chunk chunk = entity.chunk;
                if (chunk == null) {
                  chunkProvider.getChunkIfExists(entityX, entityZ);
                }
                if (chunk != null) {
                  chunk.removeEntity(entity);
                }
              }
            }

            entitiesIterator.remove();
View Full Code Here

  private void invalidate(TileEntity tileEntity) {
    int xPos = tileEntity.xCoord;
    int zPos = tileEntity.zCoord;
    manager.removed(tileEntity);
    Chunk chunk = world.getChunkIfExists(xPos >> 4, zPos >> 4);
    if (chunk != null) {
      chunk.cleanChunkBlockTileEntity(xPos, tileEntity.yCoord, zPos);
    }
  }
View Full Code Here

  @Override
  @Declare
  public int getBlockIdWithoutLoad(int x, int y, int z) {
    if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000 && y >= 0 && y < 256) {
      try {
        Chunk chunk = getChunkIfExists(x >> 4, z >> 4);
        return chunk == null ? -1 : chunk.getBlockID(x & 15, y, z & 15);
      } catch (Throwable t) {
        Log.severe("Exception getting block ID in " + Log.pos(this, x, y, z), t);
      }
    }
    return 0;
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.