Java Code Examples for net.minecraft.util.AxisAlignedBB#getBoundingBox()

The following examples show how to use net.minecraft.util.AxisAlignedBB#getBoundingBox() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TileEntityQuantumComputer.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
private Set<EntityItem> getEntityItemsInArea( AreaShape shape )
{
    AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
            (double) ( xCoord + shape.m_xMin ),
            (double) ( yCoord + shape.m_yMin ),
            (double) ( zCoord + shape.m_zMin ),
            (double) ( xCoord + shape.m_xMax + 1 ),
            (double) ( yCoord + shape.m_yMax + 1 ),
            (double) ( zCoord + shape.m_zMax + 1 )
    );

    List list = worldObj.getEntitiesWithinAABBExcludingEntity( null, aabb );
    Set<EntityItem> set = new HashSet<EntityItem>();
    for( int i = 0; i < list.size(); ++i )
    {
        Entity entity = (Entity) list.get( i );
        if( entity instanceof EntityItem && !entity.isDead )
        {
            set.add( (EntityItem) entity );
        }
    }
    return set;
}
 
Example 2
Source File: BlockWallPlate.java    From Artifacts with MIT License 6 votes vote down vote up
protected AxisAlignedBB getMetaSensitiveAABB(int x, int y, int z, int meta)
{
	float f = 0.125F;
	switch(meta) {
	case 2:
	case 10:
		return AxisAlignedBB.getBoundingBox((double)((float)x + f), (double)((float)y + f), (double)((float)(z + 1)-0.25f), (double)((float)(x + 1) - f), (double)((float)(y + 1) - f), (double)(z + 1));
		//break;
	case 3:
	case 11:
		return AxisAlignedBB.getBoundingBox((double)((float)x + f), (double)((float)y + f), (double)z, (double)((float)(x + 1) - f), (double)((float)(y + 1) - f), (double)z + 0.25D);
		//break;
	case 4:
	case 12:
		return AxisAlignedBB.getBoundingBox((double)((float)(x + 1)-0.25f), (double)((float)y + f), (double)((float)z + f), (double)(x + 1), (double)((float)(y + 1) - f), (double)((float)(z + 1) - f));
		//break;
	case 5:
	case 13:
		return AxisAlignedBB.getBoundingBox((double)x, (double)((float)y + f), (double)((float)z + f), (double)x + 0.25D, (double)((float)(y + 1) - f), (double)((float)(z + 1) - f));
		//break;
	}
	return AxisAlignedBB.getBoundingBox((double)((float)x + f), (double)y, (double)((float)z + f), (double)((float)(x + 1) - f), (double)y + 0.25D, (double)((float)(z + 1) - f));
}
 
Example 3
Source File: ProgWidgetArea.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private AxisAlignedBB getAABB(){
    ChunkPosition[] areaPoints = getAreaPoints();
    if(areaPoints[0] == null) return null;
    int minX;
    int minY;
    int minZ;
    int maxX;
    int maxY;
    int maxZ;
    if(areaPoints[1] != null) {
        minX = Math.min(areaPoints[0].chunkPosX, areaPoints[1].chunkPosX);
        minY = Math.min(areaPoints[0].chunkPosY, areaPoints[1].chunkPosY);
        minZ = Math.min(areaPoints[0].chunkPosZ, areaPoints[1].chunkPosZ);
        maxX = Math.max(areaPoints[0].chunkPosX, areaPoints[1].chunkPosX);
        maxY = Math.max(areaPoints[0].chunkPosY, areaPoints[1].chunkPosY);
        maxZ = Math.max(areaPoints[0].chunkPosZ, areaPoints[1].chunkPosZ);
    } else {
        minX = maxX = areaPoints[0].chunkPosX;
        minY = maxY = areaPoints[0].chunkPosY;
        minZ = maxZ = areaPoints[0].chunkPosZ;
    }
    return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1);
}
 
Example 4
Source File: TileEntityElevatorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
private void movePlayerDown(){
    if(!worldObj.isRemote) return;

    AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + oldExtension + 1.05F, zCoord + 1);
    List<Entity> entityList = worldObj.getEntitiesWithinAABBExcludingEntity(null, aabb);
    for(Entity entity : entityList) {
        if(entity instanceof EntityPlayer) {
            //   moveEntityToCenter(entity);
            double posX = entity.posX;
            double posZ = entity.posZ;
            if(posX >= xCoord && posX < xCoord + 1 && posZ >= zCoord && posZ < zCoord + 1) {
                entity.motionX *= 0.6;
                entity.motionZ *= 0.6;
                entity.moveEntity(0, extension - oldExtension + 0.001F, 0);
            }
        }
    }
}
 
Example 5
Source File: EntityPotionCloud.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate(){
    age++;
    radius -= 0.001D;
    if(radius <= 0.0D && !worldObj.isRemote) {
        EntityItem seed = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.POTION_PLANT_DAMAGE));
        seed.lifespan = 300;
        ItemPlasticPlants.markInactive(seed);
        worldObj.spawnEntityInWorld(seed);
        setDead();
    }
    if(age % 60 == 0) {
        motionX += (rand.nextDouble() - 0.5D) * 0.1D;
        motionY += (rand.nextDouble() - 0.6D) * 0.1D;
        motionZ += (rand.nextDouble() - 0.5D) * 0.1D;
    }
    super.onUpdate();
    moveEntity(motionX, motionY, motionZ);

    if(worldObj.isRemote) {
        int potionColor = getPotionID() < Potion.potionTypes.length && Potion.potionTypes[getPotionID()] != null ? Potion.potionTypes[getPotionID()].getLiquidColor() : 0xFFFFFF;
        for(int i = 0; i < 4; i++)
            worldObj.spawnParticle("mobSpell", posX + (rand.nextDouble() - 0.5D) * 2 * radius, posY + (rand.nextDouble() - 0.5D) * 2 * radius, posZ + (rand.nextDouble() - 0.5D) * 2 * radius, (potionColor >> 16 & 255) / 255.0F, (potionColor >> 8 & 255) / 255.0F, (potionColor >> 0 & 255) / 255.0F);
    } else if(getPotionID() >= Potion.potionTypes.length) {
        setDead();
    }

    AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(posX - radius, posY - radius, posZ - radius, posX + radius, posY + radius, posZ + radius);
    List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bbBox);
    for(EntityLivingBase entity : entities) {
        entity.addPotionEffect(new PotionEffect(getPotionID(), 200));
    }
}
 
Example 6
Source File: SemiBlockRendererHeatFrame.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render(SemiBlockHeatFrame semiBlock, float partialTick){
    GL11.glPushMatrix();
    Minecraft.getMinecraft().renderEngine.bindTexture(Textures.MODEL_HEAT_FRAME);
    int heatLevel = semiBlock.getHeatLevel();
    double[] color = TileEntityCompressedIronBlock.getColorForHeatLevel(heatLevel);
    GL11.glColor4d(color[0], color[1], color[2], 1);

    AxisAlignedBB aabb;
    if(semiBlock.getWorld() != null) {
        semiBlock.getBlock().setBlockBoundsBasedOnState(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
        aabb = semiBlock.getBlock().getSelectedBoundingBoxFromPool(semiBlock.getWorld(), semiBlock.getPos().chunkPosX, semiBlock.getPos().chunkPosY, semiBlock.getPos().chunkPosZ);
        aabb.minX -= semiBlock.getX();
        aabb.maxX -= semiBlock.getX();
        aabb.minY -= semiBlock.getY();
        aabb.maxY -= semiBlock.getY();
        aabb.minZ -= semiBlock.getZ();
        aabb.maxZ -= semiBlock.getZ();
    } else {
        aabb = AxisAlignedBB.getBoundingBox(1 / 16D, 1 / 16D, 1 / 16D, 15 / 16D, 15 / 16D, 15 / 16D);
    }
    GL11.glTranslated(aabb.minX, aabb.minY, aabb.minZ);
    GL11.glScaled(aabb.maxX - aabb.minX, aabb.maxY - aabb.minY, aabb.maxZ - aabb.minZ);
    GL11.glTranslated(0.5, -0.5, 0.5);
    model.render(null, 0, 0, 0, 0, 0, 1 / 16F);
    GL11.glPopMatrix();
    GL11.glColor4d(1, 1, 1, 1);
}
 
Example 7
Source File: TileEntityPressureChamberValve.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public double[] clearStacksInChamber(Object... stacksToClear){
    int[] stackSizes = new int[stacksToClear.length];
    for(int i = 0; i < stacksToClear.length; i++) {
        stackSizes[i] = PneumaticRecipeRegistry.getItemAmount(stacksToClear[i]);
    }
    // default the output position to the middle of the chamber.
    double[] outputPosition = new double[]{multiBlockX + multiBlockSize / 2D, multiBlockY + 1.2D, multiBlockZ + multiBlockSize / 2D};

    // get the in world EntityItems
    AxisAlignedBB bbBox = AxisAlignedBB.getBoundingBox(multiBlockX, multiBlockY, multiBlockZ, multiBlockX + multiBlockSize, multiBlockY + multiBlockSize, multiBlockZ + multiBlockSize);
    List<EntityItem> entities = worldObj.getEntitiesWithinAABB(EntityItem.class, bbBox);
    for(EntityItem entity : entities) {
        if(entity.isDead) continue;
        ItemStack entityStack = entity.getEntityItem();
        for(int l = 0; l < stacksToClear.length; l++) {
            if(PneumaticRecipeRegistry.isItemEqual(stacksToClear[l], entityStack) && stackSizes[l] > 0) {
                outputPosition[0] = entity.posX;
                outputPosition[1] = entity.posY;
                outputPosition[2] = entity.posZ;
                int removedItems = Math.min(stackSizes[l], entityStack.stackSize);
                stackSizes[l] -= removedItems;
                entityStack.stackSize -= removedItems;
                if(entityStack.stackSize <= 0) entity.setDead();
                break;
            }
        }
    }
    return outputPosition;
}
 
Example 8
Source File: BlockLightChain.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z) {
    float minX = 1;
    float minZ = 1;
    float maxX = 0;
    float maxZ = 0;
    for (Vec3 point : getAttachPoints(world, x, y, z)) {
        if (point.xCoord < minX)
            minX = (float) point.xCoord;
        if (point.zCoord < minZ)
            minZ = (float) point.zCoord;
        if (point.xCoord > maxX)
            maxX = (float) point.xCoord;
        if (point.zCoord > maxZ)
            maxZ = (float) point.zCoord;
    }

    if (maxX - minX < .125) {
        minX = .5f - .0625f;
        maxX = .5f + .0625f;
    }
    if (maxZ - minZ < .125) {
        minZ = .5f - .0625f;
        maxZ = .5f + .0625f;
    }

    return AxisAlignedBB.getBoundingBox(x + minX, y + 0, z + minZ, x + maxX, y + 1, z + maxZ);
}
 
Example 9
Source File: BlockQBlock.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void addCollisionBoxesToList( World world, int x, int y, int z, AxisAlignedBB bigBox, List list, Entity entity )
{
    // Determine if solid
    boolean solid = false;
    int type = getImpostorType( world, x, y, z );
    if( type > 0 )
    {
        // Solid blocks are solid to everyone
        solid = true;
    }
    else if( entity instanceof EntityPlayer )
    {
        // Air blocks are solid to people with goggles on
        EntityPlayer player = (EntityPlayer) entity;
        if( QCraft.isPlayerWearingQuantumGoggles( player ) )
        {
            solid = true;
        }
    }

    // Add AABB if so
    if( solid )
    {
        AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
                (double) x, (double) y, (double) z,
                (double) x + 1.0, (double) y + 1.0, (double) z + 1.0
        );
        if( aabb != null && aabb.intersectsWith( bigBox ) )
        {
            list.add( aabb );
        }
    }
}
 
Example 10
Source File: TileEntitySelector.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
public ItemSlot(int absSlot, double size, double x, double y) {
	this.slot = absSlot;
	this.size = size;
	this.x = x;
	this.y = y;
	this.box = AxisAlignedBB.getBoundingBox(x - size, 1 - size, y - size, x + size, 1 + size, y + size);
}
 
Example 11
Source File: AltAxisAlignedBB.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public AxisAlignedBB contract(double par1, double par3, double par5) {
    double var7 = this.minX + par1;
    double var9 = this.minY + par3;
    double var11 = this.minZ + par5;
    double var13 = this.maxX - par1;
    double var15 = this.maxY - par3;
    double var17 = this.maxZ - par5;
    AltAxisAlignedBB.getAABBPool();
    return AxisAlignedBB.getBoundingBox(var7, var9, var11, var13, var15, var17);
}
 
Example 12
Source File: TileEntityAssemblyController.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox(){
    return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
}
 
Example 13
Source File: BlockSpikes.java    From Artifacts with MIT License 4 votes vote down vote up
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
   {
       float f = 0.0625F;
       return AxisAlignedBB.getBoundingBox((double)((float)par2), (double)par3, (double)((float)par4), (double)((float)(par2 + 1)), (double)(par3 + 1 - f), (double)((float)(par4 + 1)));
   }
 
Example 14
Source File: TileEntitySentryTurret.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private AxisAlignedBB getTargetingBoundingBox(){
    return AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + range + 1, yCoord + range + 1, zCoord + range + 1);
}
 
Example 15
Source File: SlimeBlock.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
	float f = 0.125F;
	return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1 - f, z + 1);
}
 
Example 16
Source File: TileEntityOmnidirectionalHopper.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static List<EntityItem> getNeighborItems(TileEntity te, ForgeDirection inputDir){
    AxisAlignedBB box = AxisAlignedBB.getBoundingBox(te.xCoord + inputDir.offsetX, te.yCoord + inputDir.offsetY, te.zCoord + inputDir.offsetZ, te.xCoord + inputDir.offsetX + 1, te.yCoord + inputDir.offsetY + 1, te.zCoord + inputDir.offsetZ + 1);
    return te.getWorldObj().getEntitiesWithinAABB(EntityItem.class, box);
}
 
Example 17
Source File: TileEntityHeatSink.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox(){
    return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
}
 
Example 18
Source File: TileEntityEndRod.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
	return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
}
 
Example 19
Source File: TileEntityPneumaticDoor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox(){
    return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1);
}
 
Example 20
Source File: BlockConcrete.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
    float f = 0.125F;
    return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1) - f), (par4 + 1));
}