Search in sources :

Example 11 with ChunkPosition

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

the class DroneAILogistics method shouldExecute.

@Override
public boolean shouldExecute() {
    manager.clearLogistics();
    Set<ChunkPosition> area = widget.getCachedAreaSet();
    if (area.size() == 0)
        return false;
    int minX = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, minZ = Integer.MAX_VALUE, maxZ = Integer.MIN_VALUE;
    for (ChunkPosition pos : area) {
        minX = Math.min(minX, pos.chunkPosX);
        maxX = Math.max(maxX, pos.chunkPosX);
        minZ = Math.min(minZ, pos.chunkPosZ);
        maxZ = Math.max(maxZ, pos.chunkPosZ);
    }
    for (int x = minX; x < maxX + 16; x += 16) {
        for (int z = minZ; z < maxZ + 16; z += 16) {
            Chunk chunk = drone.getWorld().getChunkFromBlockCoords(x, z);
            Map<ChunkPosition, ISemiBlock> map = SemiBlockManager.getInstance(drone.getWorld()).getSemiBlocks().get(chunk);
            if (map != null) {
                for (Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) {
                    if (entry.getValue() instanceof SemiBlockLogistics && area.contains(entry.getKey())) {
                        SemiBlockLogistics logisticsBlock = (SemiBlockLogistics) entry.getValue();
                        manager.addLogisticFrame(logisticsBlock);
                    }
                }
            }
        }
    }
    curTask = null;
    return doLogistics();
}
Also used : SemiBlockLogistics(pneumaticCraft.common.semiblock.SemiBlockLogistics) ISemiBlock(pneumaticCraft.common.semiblock.ISemiBlock) ChunkPosition(net.minecraft.world.ChunkPosition) Chunk(net.minecraft.world.chunk.Chunk) Map(java.util.Map)

Example 12 with ChunkPosition

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

the class ClientSemiBlockManager method renderWorldLastEvent.

@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event) {
    Minecraft mc = FMLClientHandler.instance().getClient();
    EntityPlayer player = mc.thePlayer;
    double playerX = player.prevPosX + (player.posX - player.prevPosX) * event.partialTicks;
    double playerY = player.prevPosY + (player.posY - player.prevPosY) * event.partialTicks;
    double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * event.partialTicks;
    GL11.glPushMatrix();
    GL11.glTranslated(-playerX, -playerY, -playerZ);
    //  GL11.glEnable(GL11.GL_BLEND);
    //  GL11.glEnable(GL11.GL_LIGHTING);
    RenderHelper.enableStandardItemLighting();
    for (Map<ChunkPosition, ISemiBlock> map : SemiBlockManager.getInstance(player.worldObj).getSemiBlocks().values()) {
        for (ISemiBlock semiBlock : map.values()) {
            ISemiBlockRenderer renderer = getRenderer(semiBlock);
            if (renderer != null) {
                GL11.glPushMatrix();
                GL11.glTranslated(semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
                renderer.render(semiBlock, event.partialTicks);
                GL11.glPopMatrix();
            }
        }
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}
Also used : ISemiBlock(pneumaticCraft.common.semiblock.ISemiBlock) ChunkPosition(net.minecraft.world.ChunkPosition) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 13 with ChunkPosition

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

the class DroneEntityAIGoToLocation method shouldExecute.

/**
     * Returns whether the EntityAIBase should begin execution.
     */
@Override
public boolean shouldExecute() {
    Collections.sort(validArea, positionSorter);
    for (ChunkPosition c : validArea) {
        if (drone.getPosition().squareDistanceTo(c.chunkPosX + 0.5, c.chunkPosY + 0.5, c.chunkPosZ + 0.5) < 0.50)
            return false;
        if (drone.getPathNavigator().moveToXYZ(c.chunkPosX, c.chunkPosY, c.chunkPosZ)) {
            return !((IGotoWidget) gotoWidget).doneWhenDeparting();
        }
    }
    boolean teleport = drone.getPathNavigator().isGoingToTeleport();
    if (teleport) {
        return true;
    } else {
        for (ChunkPosition c : validArea) {
            drone.addDebugEntry("gui.progWidget.goto.debug.cantNavigate", c);
        }
        return false;
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition)

Example 14 with ChunkPosition

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

the class EntityDrone method getDugBlock.

@Override
protected ChunkPosition getDugBlock() {
    int x = dataWatcher.getWatchableObjectInt(18);
    int y = dataWatcher.getWatchableObjectInt(19);
    int z = dataWatcher.getWatchableObjectInt(20);
    return x != 0 || y != 0 || z != 0 ? new ChunkPosition(x, y, z) : null;
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) PathPoint(net.minecraft.pathfinding.PathPoint)

Example 15 with ChunkPosition

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

the class EntityDroneBase method renderExtras.

public void renderExtras(double x, double y, double z, float partialTicks) {
    ChunkPosition diggingPos = getDugBlock();
    if (diggingPos != null) {
        if (digLaser == null) {
            int color = 0xFF0000;
            digLaser = new RenderLaser(color);
        }
        digLaser.render(partialTicks, 0, getLaserOffsetY(), 0, diggingPos.chunkPosX + 0.5 - posX, diggingPos.chunkPosY + 0.45 - posY, diggingPos.chunkPosZ + 0.5 - posZ);
    }
}
Also used : ChunkPosition(net.minecraft.world.ChunkPosition) RenderLaser(pneumaticCraft.client.render.RenderLaser)

Aggregations

ChunkPosition (net.minecraft.world.ChunkPosition)94 ItemStack (net.minecraft.item.ItemStack)16 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 NBTTagList (net.minecraft.nbt.NBTTagList)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)9 TileEntity (net.minecraft.tileentity.TileEntity)9 ArrayList (java.util.ArrayList)8 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 Map (java.util.Map)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 Chunk (net.minecraft.world.chunk.Chunk)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 Stack (java.util.Stack)3 Block (net.minecraft.block.Block)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 IInventory (net.minecraft.inventory.IInventory)3 PathPoint (net.minecraft.pathfinding.PathPoint)3 Vec3 (net.minecraft.util.Vec3)3