Search in sources :

Example 6 with ChunkCache

use of net.minecraft.world.ChunkCache in project PneumaticCraft by MineMaarten.

the class AchievementHandler method checkFor9x9.

public static void checkFor9x9(EntityPlayer player, int x, int y, int z) {
    ChunkCache cache = new ChunkCache(player.worldObj, x - 8, y, z - 8, x + 8, y, z + 8, 0);
    ForgeDirection[] dirs = { ForgeDirection.NORTH, ForgeDirection.WEST };
    for (ForgeDirection dir : dirs) {
        int wallLength = 1;
        int minX = x;
        int minZ = z;
        int maxX = x;
        int maxZ = z;
        int newX = x + dir.offsetX;
        int newZ = z + dir.offsetZ;
        while (wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) {
            wallLength++;
            minX = Math.min(minX, newX);
            minZ = Math.min(minZ, newZ);
            maxX = Math.max(maxX, newX);
            maxZ = Math.max(maxZ, newZ);
            newX += dir.offsetX;
            newZ += dir.offsetZ;
        }
        newX = x - dir.offsetX;
        newZ = z - dir.offsetZ;
        while (wallLength < 9 && cache.getBlock(newX, y, newZ) == Blocks.cobblestone) {
            wallLength++;
            minX = Math.min(minX, newX);
            minZ = Math.min(minZ, newZ);
            maxX = Math.max(maxX, newX);
            maxZ = Math.max(maxZ, newZ);
            newX -= dir.offsetX;
            newZ -= dir.offsetZ;
        }
        if (wallLength == 9) {
            if (checkFor9x9(cache, x, y, z, minX, minZ, maxX, maxZ)) {
                giveAchievement(player, "dw9x9");
                return;
            }
        }
    }
}
Also used : ChunkCache(net.minecraft.world.ChunkCache) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 7 with ChunkCache

use of net.minecraft.world.ChunkCache in project PneumaticCraft by MineMaarten.

the class ProgWidgetAreaItemBase method getCache.

public static IBlockAccess getCache(Collection<ChunkPosition> area, World world) {
    if (area.size() == 0)
        return world;
    int minX, minY, minZ, maxX, maxY, maxZ;
    Iterator<ChunkPosition> iterator = area.iterator();
    ChunkPosition p = iterator.next();
    minX = maxX = p.chunkPosX;
    minY = maxY = p.chunkPosY;
    minZ = maxZ = p.chunkPosZ;
    while (iterator.hasNext()) {
        p = iterator.next();
        minX = Math.min(minX, p.chunkPosX);
        minY = Math.min(minY, p.chunkPosY);
        minZ = Math.min(minZ, p.chunkPosZ);
        maxX = Math.max(maxX, p.chunkPosX);
        maxY = Math.max(maxY, p.chunkPosY);
        maxZ = Math.max(maxZ, p.chunkPosZ);
    }
    return new ChunkCache(world, minX, minY, minZ, maxX, maxY, maxZ, 0);
}
Also used : ChunkCache(net.minecraft.world.ChunkCache) ChunkPosition(net.minecraft.world.ChunkPosition)

Example 8 with ChunkCache

use of net.minecraft.world.ChunkCache in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsObject method updateChunkCache.

public void updateChunkCache() {
    BlockPos min = new BlockPos(collisionBB.minX, Math.max(collisionBB.minY, 0), collisionBB.minZ);
    BlockPos max = new BlockPos(collisionBB.maxX, Math.min(collisionBB.maxY, 255), collisionBB.maxZ);
    surroundingWorldChunksCache = new ChunkCache(worldObj, min, max, 0);
}
Also used : ChunkCache(net.minecraft.world.ChunkCache) VWChunkCache(ValkyrienWarfareBase.Relocation.VWChunkCache) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

ChunkCache (net.minecraft.world.ChunkCache)8 BlockPos (net.minecraft.util.math.BlockPos)3 MutableBlockPos (net.minecraft.util.math.BlockPos.MutableBlockPos)2 IBlockAccess (net.minecraft.world.IBlockAccess)2 Vector (ValkyrienWarfareBase.API.Vector)1 VWChunkCache (ValkyrienWarfareBase.Relocation.VWChunkCache)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 ArrayList (java.util.ArrayList)1 BlockPostBase (mods.railcraft.common.blocks.aesthetics.post.BlockPostBase)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 VertexFormat (net.minecraft.client.renderer.vertex.VertexFormat)1 IInventory (net.minecraft.inventory.IInventory)1 PathEntity (net.minecraft.pathfinding.PathEntity)1 PathFinderDrone (net.minecraft.pathfinding.PathFinderDrone)1 PathPoint (net.minecraft.pathfinding.PathPoint)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 ChunkPosition (net.minecraft.world.ChunkPosition)1 Chunk (net.minecraft.world.chunk.Chunk)1