Package net.minecraft.world.chunk

Examples of net.minecraft.world.chunk.Chunk


  @Override
  public TileEntity getBlockTileEntity(int x, int y, int z) {
    if (y < 0 || y >= 256) {
      return null;
    } else {
      Chunk chunk = this.getChunkFromChunkCoords(x >> 4, z >> 4);
      return chunk == null ? null : chunk.getChunkBlockTileEntity(x & 15, y, z & 15);
    }
  }
View Full Code Here


  @Declare
  public TileEntity getTEWithoutLoad(int x, int y, int z) {
    if (y < 0 || y >= 256) {
      return null;
    } else {
      Chunk chunk = ((ChunkProviderServer) this.chunkProvider).getChunkIfExists(x >> 4, z >> 4);
      return chunk == null ? null : chunk.getChunkBlockTileEntity(x & 15, y, z & 15);
    }
  }
View Full Code Here

    }
  }

  @Override
  public void updateEntityWithOptionalForce(Entity entity, boolean notForced) {
    Chunk chunk = entity.chunk;
    if (notForced && chunk != null) {
      if (chunk.partiallyUnloaded) {
        chunk.removeEntity(entity);
        entity.addedToChunk = false;
        return;
      } else if (chunk.queuedUnload) {
        return;
      }
    }
    int x = MathHelper.floor_double(entity.posX);
    int z = MathHelper.floor_double(entity.posZ);
    boolean periodicUpdate = forcedUpdateCount++ % 32 == 0;
    Boolean isForced_ = entity.isForced;
    if (isForced_ == null || periodicUpdate) {
      entity.isForced = isForced_ = getPersistentChunks().containsKey(new ChunkCoordIntPair(x >> 4, z >> 4));
    }
    boolean isForced = isForced_;
    Boolean canUpdate_ = entity.canUpdate;
    if (canUpdate_ == null || periodicUpdate) {
      byte range = isForced ? (byte) 0 : 48;
      entity.canUpdate = canUpdate_ = !notForced || this.checkChunksExist(x - range, 0, z - range, x + range, 0, z + range);
    } else if (canUpdate_) {
      entity.canUpdate = canUpdate_ = !notForced || chunk != null || chunkExists(x >> 4, z >> 4);
    }
    boolean canUpdate = canUpdate_;
    if (canUpdate) {
      entity.lastTickPosX = entity.posX;
      entity.lastTickPosY = entity.posY;
      entity.lastTickPosZ = entity.posZ;
      entity.prevRotationYaw = entity.rotationYaw;
      entity.prevRotationPitch = entity.rotationPitch;

      if (notForced && entity.addedToChunk) {
        if (entity.ridingEntity != null) {
          entity.updateRidden();
        } else {
          ++entity.ticksExisted;
          entity.onUpdate();
        }
      }

      this.theProfiler.startSection("chunkCheck");

      if (Double.isNaN(entity.posX) || Double.isInfinite(entity.posX)) {
        entity.posX = entity.lastTickPosX;
      }

      if (Double.isNaN(entity.posY) || Double.isInfinite(entity.posY)) {
        entity.posY = entity.lastTickPosY;
      }

      if (Double.isNaN(entity.posZ) || Double.isInfinite(entity.posZ)) {
        entity.posZ = entity.lastTickPosZ;
      }

      if (Double.isNaN((double) entity.rotationPitch) || Double.isInfinite((double) entity.rotationPitch)) {
        entity.rotationPitch = entity.prevRotationPitch;
      }

      if (Double.isNaN((double) entity.rotationYaw) || Double.isInfinite((double) entity.rotationYaw)) {
        entity.rotationYaw = entity.prevRotationYaw;
      }

      int cX = MathHelper.floor_double(entity.posX) >> 4;
      int cY = MathHelper.floor_double(entity.posY) >> 4;
      int cZ = MathHelper.floor_double(entity.posZ) >> 4;

      if (!entity.addedToChunk || entity.chunkCoordX != cX || entity.chunkCoordY != cY || entity.chunkCoordZ != cZ) {
        synchronized (entity) {
          if (entity.addedToChunk) {
            if (chunk == null) {
              chunk = getChunkIfExists(entity.chunkCoordX, entity.chunkCoordZ);
            }
            if (chunk != null) {
              chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
            }
          }

          chunk = getChunkIfExists(cX, cZ);
          if (chunk != null) {
            entity.addedToChunk = true;
            chunk.addEntity(entity);
          } else {
            entity.addedToChunk = false;
          }
          entity.chunk = chunk;
        }
View Full Code Here

    int ystart = ((minY - 1) < 0) ? 0 : (minY - 1);
    for (int chunkx = (minX >> 4); chunkx <= ((maxX - 1) >> 4); chunkx++) {
      int cx = chunkx << 4;
      for (int chunkz = (minZ >> 4); chunkz <= ((maxZ - 1) >> 4); chunkz++) {
        Chunk chunk = this.getChunkIfExists(chunkx, chunkz);
        if (chunk == null) {
          continue;
        }
        // Compute ranges within chunk
        int cz = chunkz << 4;
        int xstart = (minX < cx) ? cx : minX;
        int xend = (maxX < (cx + 16)) ? maxX : (cx + 16);
        int zstart = (minZ < cz) ? cz : minZ;
        int zend = (maxZ < (cz + 16)) ? maxZ : (cz + 16);
        // Loop through blocks within chunk
        for (int x = xstart; x < xend; x++) {
          for (int z = zstart; z < zend; z++) {
            for (int y = ystart; y < maxY; y++) {
              int blkid = chunk.getBlockID(x - cx, y, z - cz);
              if (blkid > 0) {
                Block block = Block.blocksList[blkid];
                if (block != null) {
                  block.addCollisionBoxesToList(this, x, y, z, par2AxisAlignedBB, collidingBoundingBoxes, par1Entity);
                }
View Full Code Here

    int ystart = ((minY - 1) < 0) ? 0 : (minY - 1);
    for (int chunkx = (minX >> 4); chunkx <= ((maxX - 1) >> 4); chunkx++) {
      int cx = chunkx << 4;
      for (int chunkz = (minZ >> 4); chunkz <= ((maxZ - 1) >> 4); chunkz++) {
        Chunk chunk = this.getChunkIfExists(chunkx, chunkz);
        if (chunk == null) {
          continue;
        }
        // Compute ranges within chunk
        int cz = chunkz << 4;
        // Compute ranges within chunk
        int xstart = (minX < cx) ? cx : minX;
        int xend = (maxX < (cx + 16)) ? maxX : (cx + 16);
        int zstart = (minZ < cz) ? cz : minZ;
        int zend = (maxZ < (cz + 16)) ? maxZ : (cz + 16);
        // Loop through blocks within chunk
        for (int x = xstart; x < xend; x++) {
          for (int z = zstart; z < zend; z++) {
            for (int y = ystart; y < maxY; y++) {
              int blkid = chunk.getBlockID(x - cx, y, z - cz);
              if (blkid > 0) {
                Block block = Block.blocksList[blkid];
                if (block != null) {
                  block.addCollisionBoxesToList(this, x, y, z, par2AxisAlignedBB, collidingBoundingBoxes, par1Entity);
                }
View Full Code Here

    int minZ = MathHelper.floor_double((par2AxisAlignedBB.minZ - COLLISION_RANGE) / 16.0D);
    int maxZ = MathHelper.floor_double((par2AxisAlignedBB.maxZ + COLLISION_RANGE) / 16.0D);

    for (int x = minX; x <= maxX; ++x) {
      for (int z = minZ; z <= maxZ; ++z) {
        Chunk chunk = getChunkIfExists(x, z);
        if (chunk != null) {
          limit = chunk.getEntitiesWithinAABBForEntity(par1Entity, par2AxisAlignedBB, entitiesWithinAABBExcludingEntity, entitySelector, limit);
        }
      }
    }

    return entitiesWithinAABBExcludingEntity;
View Full Code Here

      for (Entity entity : unloadedEntitySet) {
        var3 = entity.chunkCoordX;
        var13 = entity.chunkCoordZ;

        if (entity.addedToChunk) {
          Chunk chunk = getChunkIfExists(var3, var13);
          if (chunk != null) {
            chunk.removeEntity(entity);
          }
        }

        onEntityRemoved(entity);
      }
      unloadedEntitySet.clear();
      theProfiler.endStartSection("entities");
      for (var1 = 0; var1 < loadedEntityList.size(); ++var1) {
        weatherEffect = (Entity) loadedEntityList.get(var1);

        if (weatherEffect.ridingEntity != null) {
          if (!weatherEffect.ridingEntity.isDead && weatherEffect.ridingEntity.riddenByEntity == weatherEffect) {
            continue;
          }

          weatherEffect.ridingEntity.riddenByEntity = null;
          weatherEffect.ridingEntity = null;
        }

        theProfiler.startSection("tick");

        if (!weatherEffect.isDead) {
          try {
            updateEntity(weatherEffect);
          } catch (Throwable var7) {
            var4 = CrashReport.makeCrashReport(var7, "Ticking entity");
            var5 = var4.makeCategory("Entity being ticked");
            weatherEffect.addEntityCrashInfo(var5);

            throw new ReportedException(var4);
          }
        }

        theProfiler.endSection();
        theProfiler.startSection("remove");

        if (weatherEffect.isDead) {
          var3 = weatherEffect.chunkCoordX;
          var13 = weatherEffect.chunkCoordZ;

          if (weatherEffect.addedToChunk) {
            Chunk chunk = getChunkIfExists(var3, var13);
            if (chunk != null) {
              chunk.removeEntity(weatherEffect);
            }
          }

          loadedEntityList.remove(var1--);
          onEntityRemoved(weatherEffect);
        }

        theProfiler.endSection();
      }
      theProfiler.endStartSection("tileEntities");
      scanningTileEntities = true;

      Iterator var14 = loadedTileEntityList.iterator();

      while (var14.hasNext()) {
        TileEntity var9 = (TileEntity) var14.next();

        if (!var9.isInvalid() && var9.hasWorldObj() && blockExists(var9.xCoord, var9.yCoord, var9.zCoord)) {
          try {
            var9.updateEntity();
          } catch (Throwable var8) {
            var4 = CrashReport.makeCrashReport(var8, "Ticking tile entity");
            var5 = var4.makeCategory("Tile entity being ticked");
            var9.func_85027_a(var5);

            throw new ReportedException(var4);
          }
        }

        if (var9.isInvalid()) {
          var14.remove();

          Chunk var11 = getChunkIfExists(var9.xCoord >> 4, var9.zCoord >> 4);

          if (var11 != null) {
            var11.cleanChunkBlockTileEntity(var9.xCoord & 15, var9.yCoord, var9.zCoord & 15);
          }
        }
      }
    }

    theProfiler.endStartSection("removingTileEntities");

    final List loadedTileEntityList = this.loadedTileEntityList;
    if (loadedTileEntityList instanceof LoadedTileEntityList) {
      ((LoadedTileEntityList) loadedTileEntityList).manager.batchRemoveTileEntities(tileEntityRemovalSet);
    } else {
      if (!warnedWrongList && loadedTileEntityList.getClass() != ArrayList.class) {
        Log.severe("TickThreading's replacement loaded tile entity list has been replaced by one from another mod!\n" +
            "Class: " + loadedTileEntityList.getClass() + ", toString(): " + loadedTileEntityList);
        warnedWrongList = true;
      }
      for (TileEntity tile : tileEntityRemovalSet) {
        tile.onChunkUnload();
      }
      loadedTileEntityList.removeAll(tileEntityRemovalSet);
      tileEntityRemovalSet.clear();
    }

    scanningTileEntities = false;

    theProfiler.endStartSection("pendingTileEntities");

    if (!addedTileEntityList.isEmpty()) {
      for (TileEntity te : (Iterable<TileEntity>) addedTileEntityList) {
        if (te.isInvalid()) {
          Chunk var15 = getChunkIfExists(te.xCoord >> 4, te.zCoord >> 4);

          if (var15 != null) {
            var15.cleanChunkBlockTileEntity(te.xCoord & 15, te.yCoord, te.zCoord & 15);
          }
        } else {
          if (!loadedTileEntityList.contains(te)) {
            loadedTileEntityList.add(te);
          }
View Full Code Here

  }

  @Override
  @Declare
  public Chunk getChunkIfExists(int x, int z) {
    Chunk chunk = chunkProvider.provideChunk(x, z);
    return chunk == emptyChunk ? null : chunk;
  }
View Full Code Here

  public void setBlockTileEntity(int x, int y, int z, TileEntity tileEntity) {
    if (tileEntity == null || tileEntity.isInvalid()) {
      return;
    }

    Chunk chunk = getChunkFromChunkCoords(x >> 4, z >> 4);
    if (chunk != null) {
      chunk.setChunkBlockTileEntity(x & 15, y, z & 15, tileEntity);
    }

    if (tileEntity.canUpdate()) {
      loadedTileEntityList.add(tileEntity);
    }
View Full Code Here

    if (tileEntity.canUpdate()) {
      (scanningTileEntities ? addedTileEntityList : loadedTileEntityList).add(tileEntity);
    }

    Chunk chunk = getChunkFromChunkCoords(x >> 4, z >> 4);
    if (chunk != null) {
      chunk.setChunkBlockTileEntityWithoutValidate(x & 15, y, z & 15, tileEntity);
    }
  }
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.