當前位置: 首頁>>代碼示例>>Java>>正文


Java AxisAlignedBB類代碼示例

本文整理匯總了Java中net.minecraft.util.math.AxisAlignedBB的典型用法代碼示例。如果您正苦於以下問題:Java AxisAlignedBB類的具體用法?Java AxisAlignedBB怎麽用?Java AxisAlignedBB使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AxisAlignedBB類屬於net.minecraft.util.math包,在下文中一共展示了AxisAlignedBB類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSize

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
/**
 * Sets the width and height of the entity.
 */
protected void setSize(float width, float height)
{
    if (width != this.width || height != this.height)
    {
        float f = this.width;
        this.width = width;
        this.height = height;

        if (this.width < f)
        {
            double d0 = (double)width / 2.0D;
            this.setEntityBoundingBox(new AxisAlignedBB(this.posX - d0, this.posY, this.posZ - d0, this.posX + d0, this.posY + (double)this.height, this.posZ + d0));
            return;
        }

        AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
        this.setEntityBoundingBox(new AxisAlignedBB(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ, axisalignedbb.minX + (double)this.width, axisalignedbb.minY + (double)this.height, axisalignedbb.minZ + (double)this.width));

        if (this.width > f && !this.firstUpdate && !this.world.isRemote)
        {
            this.moveEntity(MoverType.SELF, (double)(f - this.width), 0.0D, (double)(f - this.width));
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:Entity.java

示例2: doSplash

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
private void doSplash() {
	AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
	List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);

	if (!list.isEmpty()) {
		Tuple<List<BrewEffect>, List<PotionEffect>> tuple = BrewUtils.deSerialize(NBTHelper.fixNBT(getBrew()));

		for (EntityLivingBase entity : list) {
			double distance = this.getDistanceSq(entity);

			if (distance < 16.0D) {
				for (BrewEffect effect : tuple.getFirst()) {
					BrewStorageHandler.addEntityBrewEffect(entity, effect.copy());
				}

				for (PotionEffect potioneffect : tuple.getSecond()) {
					entity.addPotionEffect(new PotionEffect(potioneffect));
				}
			}
		}
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:23,代碼來源:EntityBrew.java

示例3: drawSelectionBox

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
public static void drawSelectionBox(EntityPlayer player, AxisAlignedBB box, float partialTicks, float r, float g, float b, float a) {
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.glLineWidth(2.0F);
    GlStateManager.disableTexture2D();
    GlStateManager.depthMask(false);

    double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
    RenderGlobal.drawSelectionBoundingBox(box.expandXyz(0.0020000000949949026D).offset(-d0, -d1, -d2), r, g, b, a);

    GlStateManager.depthMask(true);
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
 
開發者ID:McJty,項目名稱:Lector,代碼行數:17,代碼來源:RenderHelper.java

示例4: checkNoEntityCollision

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
/**
 * Returns true if there are no solid, live entities in the specified AxisAlignedBB, excluding the given entity
 */
public boolean checkNoEntityCollision(AxisAlignedBB bb, @Nullable Entity entityIn)
{
    List<Entity> list = this.getEntitiesWithinAABBExcludingEntity((Entity)null, bb);

    for (int i = 0; i < list.size(); ++i)
    {
        Entity entity = (Entity)list.get(i);

        if (!entity.isDead && entity.preventEntitySpawning && entity != entityIn && (entityIn == null || entity.isRidingSameEntity(entityIn)))
        {
            return false;
        }
    }

    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:20,代碼來源:World.java

示例5: dispenseArmor

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.splitStack(1);
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        return stack;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:ItemArmor.java

示例6: findNearestEntityWithinAABB

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
@Nullable
public <T extends Entity> T findNearestEntityWithinAABB(Class <? extends T > entityType, AxisAlignedBB aabb, T closestTo)
{
    List<T> list = this.<T>getEntitiesWithinAABB(entityType, aabb);
    T t = null;
    double d0 = Double.MAX_VALUE;

    for (int i = 0; i < list.size(); ++i)
    {
        T t1 = list.get(i);

        if (t1 != closestTo && EntitySelectors.NOT_SPECTATING.apply(t1))
        {
            double d1 = closestTo.getDistanceSqToEntity(t1);

            if (d1 <= d0)
            {
                t = t1;
                d0 = d1;
            }
        }
    }

    return t;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:26,代碼來源:World.java

示例7: getKnotForPosition

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
@Nullable
public static EntityLeashKnot getKnotForPosition(World worldIn, BlockPos pos)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (EntityLeashKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityLeashKnot.class, new AxisAlignedBB((double)i - 1.0D, (double)j - 1.0D, (double)k - 1.0D, (double)i + 1.0D, (double)j + 1.0D, (double)k + 1.0D)))
    {
        if (entityleashknot.getHangingPosition().equals(pos))
        {
            return entityleashknot;
        }
    }

    return null;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:18,代碼來源:EntityLeashKnot.java

示例8: blockESPBox

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
public static void blockESPBox(IBlockPos IBlockPos, float red, float green, float blue) {
	RenderUtils.fixDarkLight();
	GlStateManager.resetColor();
	double x = IBlockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX;
	double y = IBlockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY;
	double z = IBlockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ;
	GL11.glBlendFunc(770, 771);
	GL11.glEnable(3042);
	GL11.glLineWidth(1.0F);
	GL11.glDisable(3553);
	GL11.glDisable(2929);
	GL11.glDepthMask(false);
	GL11.glColor4f(red, green, blue, 0.15F);
	drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D), 0.0F, 1.0F, 0.0F, 0.15F);
	GL11.glColor4d(0.0D, 0.0D, 0.0D, 0.5D);
	drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0D, y + 1.0D, z + 1.0D));
	GL11.glEnable(3553);
	GL11.glEnable(2929);
	GL11.glDepthMask(true);
	GL11.glDisable(3042);
	GlStateManager.resetColor();
}
 
開發者ID:Moudoux,項目名稱:EMC,代碼行數:23,代碼來源:RenderUtils.java

示例9: attachToNearbyEntities

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
private void attachToNearbyEntities()
{
    if(isAttachedToEntity() || item || attachmentCounter > 0)
        return;
    
    for(Entity entity : world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB(-10, -10, -10, 10, 10, 10).offset(posX, posY, posZ)))
    {            
        AxisAlignedBB bb = entity.getEntityBoundingBox();
        if(bb != null && 
                entity.width >= 0.3)
        {
            if(tryAttach(entity, 0.4, 0.2))
                return;
        }
    }
}
 
開發者ID:TheCBProject,項目名稱:WirelessRedstone,代碼行數:17,代碼來源:EntityWirelessTracker.java

示例10: transposeItems

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
private void transposeItems() {
	boolean impulse = false;
	if(world.isAirBlock(pos.offset(getFacingLazy().getOpposite()))) {
		applyGravity(attractInverse, true);
		impulse = true;
	}
	if(world.isAirBlock(pos.offset(getFacingLazy()))) {
		if(impulse) {
			Vector3 spawn = Vector3.create(getPos().offset(getFacingLazy())).add(0.5D);
			getItemsFiltered(new AxisAlignedBB(getPos()).grow(0.5D)).forEach(entity -> {
				impulseEntityItem(spawn, entity);
			});
		}
		applyGravity(repulseInverse, false);
	}
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:17,代碼來源:TileVacuumConveyor.java

示例11: addCollisionBoxToList

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
@Override
@SuppressWarnings("deprecation")
public void addCollisionBoxToList (IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
    if (!p_185477_7_)
        state = getActualState(state, worldIn, pos);

    addCollisionBoxToList(pos, entityBox, collidingBoxes, CENTER_AABB);
    if (state.getValue(NORTH) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB);
    if (state.getValue(EAST) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
    if (state.getValue(SOUTH) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB);
    if (state.getValue(WEST) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
    if (state.getValue(UP) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, UP_AABB);
    if (state.getValue(DOWN) != Connection.NONE)
        addCollisionBoxToList(pos, entityBox, collidingBoxes, DOWN_AABB);
}
 
開發者ID:jaquadro,項目名稱:GardenStuff,代碼行數:21,代碼來源:BlockLattice.java

示例12: rayTraceAABB

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
@Nullable
public static RayTraceResult rayTraceAABB(AxisAlignedBB box, BlockPos pos, Vec3d start, Vec3d end) {
	double x = pos.getX();
	double y = pos.getY();
	double z = pos.getZ();
	Vec3d a = start.subtract(x, y, z);
	Vec3d b = end.subtract(x, y, z);
	RayTraceResult result = box.calculateIntercept(a, b);
	if(result != null && result.typeOfHit == RayTraceResult.Type.BLOCK) {
		return result;
	}
	return null;
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:14,代碼來源:RayTraceHelper.java

示例13: doBlockCollisions

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
protected void doBlockCollisions()
{
    AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
    BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D);
    BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos1 = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.maxX - 0.001D, axisalignedbb.maxY - 0.001D, axisalignedbb.maxZ - 0.001D);
    BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos2 = BlockPos.PooledMutableBlockPos.retain();

    if (this.world.isAreaLoaded(blockpos$pooledmutableblockpos, blockpos$pooledmutableblockpos1))
    {
        for (int i = blockpos$pooledmutableblockpos.getX(); i <= blockpos$pooledmutableblockpos1.getX(); ++i)
        {
            for (int j = blockpos$pooledmutableblockpos.getY(); j <= blockpos$pooledmutableblockpos1.getY(); ++j)
            {
                for (int k = blockpos$pooledmutableblockpos.getZ(); k <= blockpos$pooledmutableblockpos1.getZ(); ++k)
                {
                    blockpos$pooledmutableblockpos2.setPos(i, j, k);
                    IBlockState iblockstate = this.world.getBlockState(blockpos$pooledmutableblockpos2);

                    try
                    {
                        iblockstate.getBlock().onEntityCollidedWithBlock(this.world, blockpos$pooledmutableblockpos2, iblockstate, this);
                    }
                    catch (Throwable throwable)
                    {
                        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block");
                        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with");
                        CrashReportCategory.addBlockInfo(crashreportcategory, blockpos$pooledmutableblockpos2, iblockstate);
                        throw new ReportedException(crashreport);
                    }
                }
            }
        }
    }

    blockpos$pooledmutableblockpos.release();
    blockpos$pooledmutableblockpos1.release();
    blockpos$pooledmutableblockpos2.release();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:39,代碼來源:Entity.java

示例14: getBoundingBox

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
    switch (((EnumFacing)state.getValue(FACING)).getAxis())
    {
        case X:
        default:
            return END_ROD_EW_AABB;

        case Z:
            return END_ROD_NS_AABB;

        case Y:
            return END_ROD_VERTICAL_AABB;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:16,代碼來源:BlockEndRod.java

示例15: renderOffsetAABB

import net.minecraft.util.math.AxisAlignedBB; //導入依賴的package包/類
private static void renderOffsetAABB(AxisAlignedBB aabb, double x, double y, double z) {
    BufferBuilder wr = Tessellator.getInstance().getBuffer();
    wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_NORMAL);
    wr.setTranslation(x, y, z);

    wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 0, -1).endVertex();
    wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex();
    wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, 0, -1).endVertex();

    wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex();
    wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, 0, 1).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex();
    wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 0, 1).endVertex();

    wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex();
    wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(0, -1, 0).endVertex();
    wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex();
    wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(0, -1, 0).endVertex();

    wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(0, 1, 0).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex();
    wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(0, 1, 0).endVertex();

    wr.pos(aabb.minX, aabb.minY, aabb.maxZ).normal(-1, 0, 0).endVertex();
    wr.pos(aabb.minX, aabb.maxY, aabb.maxZ).normal(-1, 0, 0).endVertex();
    wr.pos(aabb.minX, aabb.maxY, aabb.minZ).normal(-1, 0, 0).endVertex();
    wr.pos(aabb.minX, aabb.minY, aabb.minZ).normal(-1, 0, 0).endVertex();

    wr.pos(aabb.maxX, aabb.minY, aabb.minZ).normal(1, 0, 0).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.minZ).normal(1, 0, 0).endVertex();
    wr.pos(aabb.maxX, aabb.maxY, aabb.maxZ).normal(1, 0, 0).endVertex();
    wr.pos(aabb.maxX, aabb.minY, aabb.maxZ).normal(1, 0, 0).endVertex();
    wr.setTranslation(0.0D, 0.0D, 0.0D);
    Tessellator.getInstance().draw();
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:38,代碼來源:SemiBlockRendererLogistics.java


注:本文中的net.minecraft.util.math.AxisAlignedBB類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。