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

The following examples show how to use net.minecraft.util.math.AxisAlignedBB#offset() . 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: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos)
{
    AxisAlignedBB bounds = getContent().selectionBounds.get(getSubtype(state)).orElse(null);
    if (bounds == DEFAULT_AABB_MARKER)
        return super.getSelectedBoundingBox(state, worldIn, pos);
    else
        return bounds != null ? bounds.offset(pos) : null;
}
 
Example 2
Source File: NaiveVoxelFieldAABBMaker.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public AxisAlignedBB makeVoxelFieldAABB() {
    if (voxelCount == 0) {
        return null;
    }
    AxisAlignedBB inLocal = new AxisAlignedBB(minCoords, maxCoords);
    return inLocal.offset(centerPos);
}
 
Example 3
Source File: MobileAABB.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public boolean intersects(AxisAlignedBB aabb) {

	//if(chunk == null || true)
	//	return super.intersectsWith(aabb);

	boolean collides = false;

	double diffX = 0;//((this.maxX - this.minX) - chunk.sizeX)/2f;
	double diffZ = 0;//((this.maxX - this.minX) - chunk.sizeX)/2f;

	out:
		for(int x = 0; x < chunk.blocks.length; x++) {
			for(int y = 0; y < chunk.blocks[0].length; y++) {
				for(int z = 0; z < chunk.blocks[0][0].length; z++) {
					Block block = chunk.blocks[x][y][z];

					if(!block.getDefaultState().getMaterial().isSolid())
						continue;

					AxisAlignedBB bb = block.getDefaultState().getCollisionBoundingBox(chunk.world, new BlockPos(x,y,z));

					if(bb == null)
						continue;




					bb = bb.offset(this.minX + x + diffX, this.minY + y, this.minZ + z + diffZ);
					if(bb.intersects(aabb)) {
						collides = true;
						break out;
					}
				}
			}
		}

	return collides;
}
 
Example 4
Source File: SmallVesselHighlightHandler.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void drawBlockHighlightEvent(DrawBlockHighlightEvent evt) 
{
	RayTraceResult target = evt.getTarget();
	if(target.typeOfHit != RayTraceResult.Type.BLOCK)
		return;

	World world = evt.getPlayer().world;
	EntityPlayer player = evt.getPlayer();
	IBlockState state = world.getBlockState(target.getBlockPos());

	double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * evt.getPartialTicks();
	double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * evt.getPartialTicks();
	double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * evt.getPartialTicks();

	double hitX = Math.round((target.hitVec.xCoord - target.getBlockPos().getX())*100)/100.0d;
	double hitY = Math.round((target.hitVec.yCoord - target.getBlockPos().getY())*100)/100.0d;
	double hitZ = Math.round((target.hitVec.zCoord - target.getBlockPos().getZ())*100)/100.0d;

	AxisAlignedBB box = null;
	int index = getIndex(hitX, hitZ);

	if((state.getBlock() == TFCBlocks.SmallVessel) || (target.sideHit == EnumFacing.UP && player.getHeldItemMainhand().getItem() == TFCItems.PotteryVessel && 
			state.getBlock().isSideSolid(state, world, target.getBlockPos(), EnumFacing.UP) && player.isSneaking() && player.getHeldItemMainhand().getItemDamage() == 1))
	{

		GlStateManager.enableBlend();
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
		GlStateManager.disableCull();

		if(index == 0)
			box = aabb0.offset(target.getBlockPos());
		else if(index == 1)
			box = aabb1.offset(target.getBlockPos());
		else if(index == 2)
			box = aabb2.offset(target.getBlockPos());
		else
			box = aabb3.offset(target.getBlockPos());

		if(state.getBlock() != TFCBlocks.SmallVessel)
			box = box.offset(0, 1, 0);

		GlStateManager.enableTexture2D();
		Core.bindTexture(selectTex);
		drawFace(box.expand(0.002F, 0.002F, 0.002F).offset(-posX, -posY, -posZ), new float[]{1f,1f,1f, 1f}, EnumFacing.UP);

		GlStateManager.disableTexture2D();
		GlStateManager.enableCull();
		GlStateManager.disableBlend();
	}
}
 
Example 5
Source File: BuildersWandRenderer.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void renderStackedArea(Area3D area, EntityPlayer player, BlockPosEU posStart, BlockPosEU posEnd, float partialTicks)
{
    if (posStart == null || posEnd == null)
    {
        return;
    }

    int xp = area.getXPos();
    int yp = area.getYPos();
    int zp = area.getZPos();
    int xn = area.getXNeg();
    int yn = area.getYNeg();
    int zn = area.getZNeg();
    int sx = Math.abs(posEnd.getX() - posStart.getX()) + 1;
    int sy = Math.abs(posEnd.getY() - posStart.getY()) + 1;
    int sz = Math.abs(posEnd.getZ() - posStart.getZ()) + 1;
    AxisAlignedBB originalBox = createEnclosingAABB(posStart, posEnd, player, partialTicks);

    GlStateManager.glLineWidth(2.0f);

    // Non-empty area on at least one axis
    if ((xp + xn + yp + yn + zp + zn) != 0)
    {
        for (int y = -yn; y <= yp; y++)
        {
            for (int x = -xn; x <= xp; x++)
            {
                for (int z = -zn; z <= zp; z++)
                {
                    AxisAlignedBB aabb = originalBox.offset(x * sx, y * sy, z * sz);

                    if (x != 0 || y != 0 || z != 0)
                    {
                        RenderGlobal.drawSelectionBoundingBox(aabb, 1f, 1f, 1f, 0xCC / 255f);
                    }
                    else
                    {
                        RenderGlobal.drawSelectionBoundingBox(aabb, 0.5f, 1f, 0.5f, 0xCC / 255f);
                    }
                }
            }
        }
    }
}
 
Example 6
Source File: BlockUtils.java    From OpenModsLib with MIT License 4 votes vote down vote up
public static AxisAlignedBB aabbOffset(BlockPos pos, AxisAlignedBB aabb) {
	return aabb.offset(pos.getX(), pos.getY(), pos.getZ());
}