本文整理汇总了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));
}
}
}
示例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));
}
}
}
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
}
示例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();
}