Package net.minecraft.world

Examples of net.minecraft.world.ChunkPosition


    public static IBlockAccess getCache(Set<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();
View Full Code Here


    public static ChunkPosition getEntityLookedBlock(EntityLivingBase entity, float maxDistance){
        MovingObjectPosition hit = getEntityLookedObject(entity, maxDistance);
        if(hit == null || hit.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
            return null;
        }
        return new ChunkPosition(hit.blockX, hit.blockY, hit.blockZ);
    }
View Full Code Here

        area = widget.getArea();
        worldCache = ProgWidgetAreaItemBase.getCache(area, drone.worldObj);
        sorter = new ChunkPositionSorter(drone);
        if(area.size() > 0) {
            Iterator<ChunkPosition> iterator = area.iterator();
            ChunkPosition pos = iterator.next();
            minY = maxY = pos.chunkPosY;
            while(iterator.hasNext()) {
                pos = iterator.next();
                minY = Math.min(minY, pos.chunkPosY);
                maxY = Math.max(maxY, pos.chunkPosY);
View Full Code Here

    /**
     * Returns whether the EntityAIBase should begin execution.
     */
    @Override
    public boolean shouldExecute(){
        ChunkPosition bestPos = null;
        int startY = curY;
        boolean firstRun = true;
        while(bestPos == null && (curY != startY && order != ProgWidgetDigAndPlace.EnumOrder.CLOSEST || firstRun)) {
            firstRun = false;
            for(ChunkPosition pos : area) {
View Full Code Here

        curTooltip.add("Area type: " + type);
    }

    private ChunkPosition[] getAreaPoints(){
        ChunkPosition c1 = x1 != 0 || y1 != 0 || z1 != 0 ? new ChunkPosition(x1, y1, z1) : null;
        ChunkPosition c2 = x2 != 0 || y2 != 0 || z2 != 0 ? new ChunkPosition(x2, y2, z2) : null;
        if(c1 == null && c2 == null) {
            return new ChunkPosition[]{null, null};
        } else if(c1 == null) {
            return new ChunkPosition[]{c2, null};
        } else if(c2 == null) {
View Full Code Here

        switch(type){
            case FILL:
                for(int x = minX; x <= maxX; x++) {
                    for(int y = maxY; y >= minY; y--) {
                        for(int z = minZ; z <= maxZ; z++) {
                            area.add(new ChunkPosition(x, y, z));
                        }
                    }
                }
                break;
            case FRAME:
                for(int x = minX; x <= maxX; x++) {
                    for(int y = minY; y <= maxY; y++) {
                        for(int z = minZ; z <= maxZ; z++) {
                            int axisRight = 0;
                            if(x == minX || x == maxX) axisRight++;
                            if(y == minY || y == maxY) axisRight++;
                            if(z == minZ || z == maxZ) axisRight++;
                            if(axisRight > 1) {
                                area.add(new ChunkPosition(x, y, z));
                            }
                        }
                    }
                }
                break;
            case WALL:
                for(int x = minX; x <= maxX; x++) {
                    for(int y = minY; y <= maxY; y++) {
                        for(int z = minZ; z <= maxZ; z++) {
                            if(x == minX || x == maxX || y == minY || y == maxY || z == minZ || z == maxZ) {
                                area.add(new ChunkPosition(x, y, z));
                            }
                        }
                    }
                }
                break;
            case SPHERE:
                double radius = areaPoints[1] != null ? PneumaticCraftUtils.distBetween(areaPoints[0], areaPoints[1]) : 0;
                minX = (int)(areaPoints[0].chunkPosX - radius - 1);
                minY = (int)(areaPoints[0].chunkPosY - radius - 1);
                minZ = (int)(areaPoints[0].chunkPosZ - radius - 1);
                maxX = (int)(areaPoints[0].chunkPosX + radius + 1);
                maxY = (int)(areaPoints[0].chunkPosY + radius + 1);
                maxZ = (int)(areaPoints[0].chunkPosZ + radius + 1);
                for(int x = minX; x <= maxX; x++) {
                    for(int y = minY; y <= maxY; y++) {
                        for(int z = minZ; z <= maxZ; z++) {
                            if(PneumaticCraftUtils.distBetween(areaPoints[0], x + 0.5, y + 0.5, z + 0.5) <= radius) {
                                area.add(new ChunkPosition(x, y, z));
                            }
                        }
                    }
                }
                break;
            case LINE:
                if(areaPoints[1] != null) {
                    Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
                    lineVec.xCoord /= 10;
                    lineVec.yCoord /= 10;
                    lineVec.zCoord /= 10;
                    double curX = areaPoints[0].chunkPosX + 0.5;
                    double curY = areaPoints[0].chunkPosY + 0.5;
                    double curZ = areaPoints[0].chunkPosZ + 0.5;
                    double totalDistance = 0;
                    double maxDistance = PneumaticCraftUtils.distBetween(areaPoints[0], areaPoints[1]);
                    while(totalDistance <= maxDistance) {
                        totalDistance += 0.1;
                        curX += lineVec.xCoord;
                        curY += lineVec.yCoord;
                        curZ += lineVec.zCoord;
                        ChunkPosition pos = new ChunkPosition((int)curX, (int)curY, (int)curZ);
                        if(!area.contains(pos)) area.add(pos);
                    }
                }
                break;
            case X_WALL:
                if(areaPoints[1] != null) {
                    Vec3 lineVec = Vec3.createVectorHelper(0, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
                    lineVec.yCoord /= 10;
                    lineVec.zCoord /= 10;
                    double curY = areaPoints[0].chunkPosY + 0.5;
                    double curZ = areaPoints[0].chunkPosZ + 0.5;
                    double totalDistance = 0;
                    double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosY - areaPoints[1].chunkPosY, 2) + Math.pow(areaPoints[0].chunkPosZ - areaPoints[1].chunkPosZ, 2));
                    while(totalDistance <= maxDistance) {
                        totalDistance += 0.1;
                        curY += lineVec.yCoord;
                        curZ += lineVec.zCoord;
                        for(int i = minX; i <= maxX; i++) {
                            ChunkPosition pos = new ChunkPosition(i, (int)curY, (int)curZ);
                            if(!area.contains(pos)) area.add(pos);
                        }
                    }
                }
                break;
            case Y_WALL:
                if(areaPoints[1] != null) {
                    Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, 0, areaPoints[1].chunkPosZ - areaPoints[0].chunkPosZ).normalize();
                    lineVec.xCoord /= 10;
                    lineVec.zCoord /= 10;
                    double curX = areaPoints[0].chunkPosX + 0.5;
                    double curZ = areaPoints[0].chunkPosZ + 0.5;
                    double totalDistance = 0;
                    double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosX - areaPoints[1].chunkPosX, 2) + Math.pow(areaPoints[0].chunkPosZ - areaPoints[1].chunkPosZ, 2));
                    while(totalDistance <= maxDistance) {
                        totalDistance += 0.1;
                        curX += lineVec.xCoord;
                        curZ += lineVec.zCoord;
                        for(int i = minY; i <= maxY; i++) {
                            ChunkPosition pos = new ChunkPosition((int)curX, i, (int)curZ);
                            if(!area.contains(pos)) area.add(pos);
                        }
                    }
                }
                break;
            case Z_WALL:
                if(areaPoints[1] != null) {
                    Vec3 lineVec = Vec3.createVectorHelper(areaPoints[1].chunkPosX - areaPoints[0].chunkPosX, areaPoints[1].chunkPosY - areaPoints[0].chunkPosY, 0).normalize();
                    lineVec.xCoord /= 10;
                    lineVec.yCoord /= 10;
                    double curX = areaPoints[0].chunkPosX + 0.5;
                    double curY = areaPoints[0].chunkPosY + 0.5;
                    double totalDistance = 0;
                    double maxDistance = Math.sqrt(Math.pow(areaPoints[0].chunkPosX - areaPoints[1].chunkPosX, 2) + Math.pow(areaPoints[0].chunkPosY - areaPoints[1].chunkPosY, 2));
                    while(totalDistance <= maxDistance) {
                        totalDistance += 0.1;
                        curX += lineVec.xCoord;
                        curY += lineVec.yCoord;
                        for(int i = minZ; i <= maxZ; i++) {
                            ChunkPosition pos = new ChunkPosition((int)curX, (int)curY, i);
                            if(!area.contains(pos)) area.add(pos);
                        }
                    }
                }
                break;
View Full Code Here

    @Override
    public void fromBytes(ByteBuf buffer){
        super.fromBytes(buffer);
        area = new ChunkPosition[buffer.readInt()];
        for(int i = 0; i < area.length; i++) {
            area[i] = new ChunkPosition(buffer.readInt(), buffer.readInt(), buffer.readInt());
        }
    }
View Full Code Here

        for(int i = 0; i == 0 || worldObj.getBlock(xCoord, yCoord + i, zCoord) == Blockss.elevatorFrame; i++) {
            boolean registeredThisFloor = false;
            for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
                if(dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
                    if(worldObj.getBlock(xCoord + dir.offsetX, yCoord + i + 2, zCoord + dir.offsetZ) == Blockss.elevatorCaller) {
                        callerList.add(new ChunkPosition(xCoord + dir.offsetX, yCoord + i + 2, zCoord + dir.offsetZ));
                        if(!registeredThisFloor) floorList.add(i);
                        registeredThisFloor = true;
                    }
                }
            }
View Full Code Here

                    if(PneumaticCraftUtils.getProtectingSecurityStations(worldObj, xCoord, yCoord, zCoord, player, false) == 0) {
                        if(redstoneMode == 0) {
                            return true;
                        } else {
                            ((BlockPneumaticDoor)Blockss.pneumaticDoor).isTrackingPlayerEye = true;
                            ChunkPosition lookedPosition = PneumaticCraftUtils.getEntityLookedBlock(player, range * 1.41F); //max range = range * sqrt(2).
                            ((BlockPneumaticDoor)Blockss.pneumaticDoor).isTrackingPlayerEye = false;
                            if(lookedPosition != null) {
                                if(lookedPosition.equals(new ChunkPosition(xCoord, yCoord, zCoord))) {
                                    return true;
                                } else {
                                    if(door != null) {
                                        if(lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord, door.zCoord))) return true;
                                        if(lookedPosition.equals(new ChunkPosition(door.xCoord, door.yCoord + (door.getBlockMetadata() < 6 ? 1 : -1), door.zCoord))) return true;
                                    }
                                }
                            }
                        }
                    }
View Full Code Here

    public ChunkPosition getTargetedBlock(){
        int x = dataWatcher.getWatchableObjectInt(14);
        int y = dataWatcher.getWatchableObjectInt(15);
        int z = dataWatcher.getWatchableObjectInt(16);
        return x != 0 || y != 0 || z != 0 ? new ChunkPosition(x, y, z) : null;
    }
View Full Code Here

TOP

Related Classes of net.minecraft.world.ChunkPosition

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.