net.minecraft.util.math.AxisAlignedBB Java Examples

The following examples show how to use net.minecraft.util.math.AxisAlignedBB. 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: CivilizationHandlers.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void harvestDrops(HarvestDropsEvent event) {
	if (!ToroQuestConfiguration.cropsAffectRep) {
		return;
	}
	if (isCrop(event.getState().getBlock())) {
		BlockPos pos = event.getPos();
		AxisAlignedBB bb = new AxisAlignedBB(pos);
		List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, bb);
		if (players != null && players.size() > 0) {
			for (EntityPlayer player : players) {
				adjustPlayerRep(player, pos.getX() / 16, pos.getZ() / 16, -getFarmRepAmount(event.getWorld().rand));
			}
		}
	}
}
 
Example #2
Source File: RulerRenderer.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderPositions(EntityPlayer clientPlayer, BlockPosEU posStart, BlockPosEU posEnd, int color, float partialTicks)
{
    GlStateManager.glLineWidth(2.0f);

    for (int a = 0; a < 3; a++)
    {
        List<BlockPosEU> column = this.positions.get(a);

        if (column != null)
        {
            final int size = column.size();

            for (int i = 0; i < size; i++)
            {
                BlockPosEU pos = column.get(i);
                //if (pos.equals(posStart) == false && (posEnd == null || posEnd.equals(pos) == false))
                {
                    AxisAlignedBB aabb = BuildersWandRenderer.createAABB(pos.getX(), pos.getY(), pos.getZ(), 0, partialTicks, clientPlayer);
                    RenderGlobal.drawSelectionBoundingBox(aabb, ((color >>> 16) & 0xFF) / 255f, ((color >>> 8) & 0xFF) / 255f, (color & 0xFF) / 255f, 1.0f);
                }
            }
        }
    }
}
 
Example #3
Source File: GTItemEchotron.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean onItemActive(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean selected) {
	if (worldIn.getTotalWorldTime() % 100 == 0) {
		entityIn.playSound(GTSounds.SONAR, 1.0F, 1.0F);
		AxisAlignedBB area = new AxisAlignedBB(entityIn.getPosition()).grow(16);
		List<Entity> list = entityIn.world.getEntitiesInAABBexcluding(entityIn, area, null);
		if (!list.isEmpty()) {
			for (Entity thing : list) {
				if (thing instanceof EntityLiving) {
					((EntityLivingBase) thing).addPotionEffect(new PotionEffect(MobEffects.GLOWING, 80, 0, false, false));
				}
				if (thing instanceof EntityPlayer) {
					((EntityPlayer) thing).addPotionEffect(new PotionEffect(MobEffects.GLOWING, 80, 0, false, false));
				}
			}
		}
		return true;
	}
	return false;
}
 
Example #4
Source File: EntityAINearestAttackableTargetBounded.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public boolean shouldExecute() {
  if (targetChance > 0 && taskOwner.getRNG().nextInt(targetChance) != 0) {
    return false;
  } else {
    double horizDist = getTargetDistance();
    double vertDist = getVerticalDistance();
    
    AxisAlignedBB bb = taskOwner.getEntityBoundingBox().expand(horizDist, vertDist, horizDist);
    List<T> list = taskOwner.getEntityWorld().<T> getEntitiesWithinAABB(targetClass, bb,
        Predicates.<T> and(targetEntitySelector, EntitySelectors.NOT_SPECTATING));
    Collections.sort(list, sorter);

    if (list.isEmpty()) {
      return false;
    } else {
      this.targetEntity = list.get(0);
      return true;
    }
  }
}
 
Example #5
Source File: BlockMapleSpile.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
  public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  {
     switch (state.getValue(FACING)) {
case EAST:
	return AABB_E;
case NORTH:
	return AABB_N;
case SOUTH:
	return AABB_S;
case WEST:
	return AABB_W;
default:
	break;
}
     return AABB_N;
  }
 
Example #6
Source File: ShipTransformationManager.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
/**
 * Keeps the Ship in the world border
 */
private void forceShipIntoWorldBorder() {
    WorldBorder border = parent.world().getWorldBorder();
    AxisAlignedBB shipBB = parent.getShipBoundingBox();

    if (shipBB.maxX > border.maxX()) {
        parent.getWrapperEntity().posX += border.maxX() - shipBB.maxX;
    }
    if (shipBB.minX < border.minX()) {
        parent.getWrapperEntity().posX += border.minX() - shipBB.minX;
    }
    if (shipBB.maxZ > border.maxZ()) {
        parent.getWrapperEntity().posZ += border.maxZ() - shipBB.maxZ;
    }
    if (shipBB.minZ < border.minZ()) {
        parent.getWrapperEntity().posZ += border.minZ() - shipBB.minZ;
    }
}
 
Example #7
Source File: PotionPhase.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
public BlockPos getBottomBlock(@Nonnull Entity entity) {
	boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer) entity).isSpectator());
	if (isSpectator) return null;
	AxisAlignedBB bb = entity.getEntityBoundingBox();
	int mX = MathHelper.floor(bb.minX);
	int mY = MathHelper.floor(bb.minY);
	int mZ = MathHelper.floor(bb.minZ);
	for (int y2 = mY; y2 < bb.maxY; y2++) {
		for (int x2 = mX; x2 < bb.maxX; x2++) {
			for (int z2 = mZ; z2 < bb.maxZ; z2++) {
				BlockPos tmp = new BlockPos(x2, y2, z2);
				if (!entity.world.isAirBlock(tmp)) return tmp;
			}
		}
	}

	return null;
}
 
Example #8
Source File: GTUtility.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Pushes entities away from target within an area, code adapted from
 * EE/ProjectE.
 */
public static void repelEntitiesInAABBFromPoint(World world, AxisAlignedBB boundingbox, double x, double y,
		double z) {
	List<Entity> list = world.getEntitiesWithinAABB(Entity.class, boundingbox);
	if (list.isEmpty()) {
		return;
	}
	for (Entity entity : list) {
		if ((entity instanceof EntityLiving) || (entity instanceof IProjectile)) {
			if (entity instanceof EntityArrow && ((EntityArrow) entity).onGround) {
				continue;
			}
			if (entity instanceof EntityArmorStand) {
				continue;
			}
			Vec3d p = new Vec3d(x, y, z);
			Vec3d t = new Vec3d(entity.posX, entity.posY, entity.posZ);
			double distance = p.distanceTo(t) + 0.1D;
			Vec3d r = new Vec3d(t.x - p.x, t.y - p.y, t.z - p.z);
			entity.motionX += r.x / 1.5D / distance;
			entity.motionY += r.y / 1.5D / distance;
			entity.motionZ += r.z / 1.5D / distance;
		}
	}
}
 
Example #9
Source File: RayTraceUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static boolean traceToSelectionBoxCorner(SelectionBox box, Corner corner, Vec3d start, Vec3d end)
{
    BlockPos pos = (corner == Corner.CORNER_1) ? box.getPos1() : (corner == Corner.CORNER_2) ? box.getPos2() : null;

    if (pos != null)
    {
        AxisAlignedBB bb = PositionUtils.createAABBForPosition(pos);
        RayTraceResult hit = bb.calculateIntercept(start, end);

        if (hit != null)
        {
            double dist = hit.hitVec.distanceTo(start);

            if (closestCornerDistance < 0 || dist < closestCornerDistance)
            {
                closestCornerDistance = dist;
                closestCorner = new RayTraceWrapper(box, corner, hit.hitVec);
            }

            return true;
        }
    }

    return false;
}
 
Example #10
Source File: SealableBlockHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
/**
 * Checks if a block is full sized based off of block bounds. This
 * is not a perfect check as mods may have a full size. However,
 * have a 3D model that doesn't look a full block in size. There
 * is no way around this other than to make a black list check.
 *
 * @param block - block to compare
 * @return true if full block
 */
public static boolean isFullBlock(IBlockAccess world, BlockPos pos, IBlockState state)
{
	AxisAlignedBB bb = state.getCollisionBoundingBox((World) world, pos);
	
   	if(bb == null)
   		return false;
	
       int minX = (int) (bb.minX * 100);
       int minY = (int) (bb.minY * 100);
       int minZ = (int) (bb.minZ * 100);
       int maxX = (int) (bb.maxX * 100);
       int maxY = (int) (bb.maxY * 100);
       int maxZ = (int) (bb.maxZ * 100);

       return minX == 0 && minY == 0 && minZ == 0 && maxX == 100 && maxY == 100 && maxZ == 100;
}
 
Example #11
Source File: BlockBackpack.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
	TileEntity entity = source.getTileEntity(pos);
	EnumFacing facing = (entity instanceof TileEntityBackpack)
		? ((TileEntityBackpack)entity).facing
		: EnumFacing.NORTH;
	return _boundsFromFacing[facing.ordinal() - 2];
}
 
Example #12
Source File: EntityDireWolf.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@Override
public void setPosition(double x, double y, double z) {
  posX = x;
  posY = y;
  posZ = z;
  //Correct misalignment of bounding box    
  double hw = width / 2.0F;
  double hd = hw * 2.25;
  float f1 = height;

  setEntityBoundingBox(new AxisAlignedBB(
      x - hw, y, z - hd,
      x + hw, y + f1, z + hd));

}
 
Example #13
Source File: AxisAlignedBBDeserializerTest.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_fromTo_with_offset()
{
    AxisAlignedBB bb = gson.fromJson("{ \"from\": [1,2,3], \"to\": [4,5.5,6], \"offset\": [1,2,3] }", AxisAlignedBB.class);

    assertEquals(2, bb.minX, 0.001);
    assertEquals(4, bb.minY, 0.001);
    assertEquals(6, bb.minZ, 0.001);
    assertEquals(5, bb.maxX, 0.001);
    assertEquals(7.5, bb.maxY, 0.001);
    assertEquals(9, bb.maxZ, 0.001);
}
 
Example #14
Source File: RenderUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void renderAreaOutline(BlockPos pos1, BlockPos pos2, float lineWidth,
        Color4f colorX, Color4f colorY, Color4f colorZ, Entity renderViewEntity, float partialTicks)
{
    GlStateManager.glLineWidth(lineWidth);

    AxisAlignedBB aabb = createEnclosingAABB(pos1, pos2, renderViewEntity, partialTicks);
    drawBoundingBoxEdges(aabb, colorX, colorY, colorZ);
}
 
Example #15
Source File: MobEspHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onEnable()
{
	MinecraftForge.EVENT_BUS.register(this);
	
	mobBox = GL11.glGenLists(1);
	GL11.glNewList(mobBox, GL11.GL_COMPILE);
	GL11.glBegin(GL11.GL_LINES);
	AxisAlignedBB bb = new AxisAlignedBB(-0.5, 0, -0.5, 0.5, 1, 0.5);
	RenderUtils.drawOutlinedBox(bb);
	GL11.glEnd();
	GL11.glEndList();
}
 
Example #16
Source File: AnvilHighlightHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static void drawOutlinedBox(AxisAlignedBB aabb)
{
	Tessellator tessellator = Tessellator.getInstance();
	VertexBuffer buffer = tessellator.getBuffer();
	buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
	buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
	buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
	buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
	buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
	buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();

	buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();

	buffer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex();
	buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();

	buffer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex();
	buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();

	buffer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex();
	buffer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex();

	buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();

	buffer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex();
	buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();

	buffer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex();
	buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();

	buffer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex();
	buffer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex();

	tessellator.draw();
}
 
Example #17
Source File: BlockWaterHyacinth.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void addCollisionBoxToList(IBlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) {
    if (!(entityIn instanceof EntityBoat)) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, box);
    }
}
 
Example #18
Source File: RenderUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates an AABB for rendering purposes, which is offset by the render view entity's movement and current partialTicks
 */
public static AxisAlignedBB createEnclosingAABB(BlockPos pos1, BlockPos pos2, Entity renderViewEntity, float partialTicks)
{
    int minX = Math.min(pos1.getX(), pos2.getX());
    int minY = Math.min(pos1.getY(), pos2.getY());
    int minZ = Math.min(pos1.getZ(), pos2.getZ());
    int maxX = Math.max(pos1.getX(), pos2.getX()) + 1;
    int maxY = Math.max(pos1.getY(), pos2.getY()) + 1;
    int maxZ = Math.max(pos1.getZ(), pos2.getZ()) + 1;

    return createAABB(minX, minY, minZ, maxX, maxY, maxZ, 0, partialTicks, renderViewEntity);
}
 
Example #19
Source File: Core.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static ArrayList<BlockPos> getBlockPosInAABB(AxisAlignedBB aabb)
{
	ArrayList<BlockPos> out = new ArrayList<BlockPos>();
	for(int x = (int) aabb.minX; x < aabb.maxX; x++)
	{
		for(int y = (int) aabb.minY; y < aabb.maxY; y++)
		{
			for(int z = (int) aabb.minZ; z < aabb.maxZ; z++)
			{
				out.add(new BlockPos(x, y, z));
			}
		}
	}
	return out;
}
 
Example #20
Source File: SimpleQuickShipAccess.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public Iterator<ShipHolder> getShipsIntersectingWith(AxisAlignedBB playerBB) {
    List<ShipHolder> ships = new ArrayList<>();
    for (ShipHolder shipHolder : ships) {
        if (shipHolder.getShip() != null) {
            // TODO: Finish me
        }
    }
    return ships.iterator();
}
 
Example #21
Source File: EntityUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the index of the BB in the given list that the given vectors are currently pointing at.
 * @return the list index of the pointed box, or null of no hit was detected
 */
@Nullable
public static <T> T getPointedBox(Vec3d eyesVec, Vec3d lookVec, double reach, Map<T, AxisAlignedBB> boxMap)
{
    Vec3d lookEndVec = eyesVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
    double distance = reach;
    T key = null;

    for (Map.Entry<T, AxisAlignedBB> entry : boxMap.entrySet())
    {
        AxisAlignedBB bb = entry.getValue();
        RayTraceResult rayTrace = bb.calculateIntercept(eyesVec, lookEndVec);

        if (bb.contains(eyesVec))
        {
            if (distance >= 0.0D)
            {
                distance = 0.0D;
                key = entry.getKey();
            }
        }
        else if (rayTrace != null)
        {
            double distanceTmp = eyesVec.distanceTo(rayTrace.hitVec);

            if (distanceTmp < distance)
            {
                distance = distanceTmp;
                key = entry.getKey();
            }
        }
    }

    return key;
}
 
Example #22
Source File: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
    if (getContent().collisionBounds == null)
        return null;

    AxisAlignedBB bounds = getContent().collisionBounds.get(getSubtype(state)).orElse(null);
    if (bounds == DEFAULT_AABB_MARKER)
        return super.getCollisionBoundingBox(state, worldIn, pos);
    else
        return bounds;
}
 
Example #23
Source File: ChunkLogger.java    From ForgeHax with MIT License 5 votes vote down vote up
ChunkData(SPacketChunkData packet) {
  pos = new ChunkPos(packet.getChunkX(), packet.getChunkZ());
  bbox =
      new AxisAlignedBB(pos.getXStart(), 0, pos.getZStart(), pos.getXEnd(), 255, pos.getZEnd());
  isFullChunk = packet.isFullChunk();
  update(packet);
}
 
Example #24
Source File: GTBlockSuperconductorCable.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
	TileEntity tile = world.getTileEntity(pos);
	if (!(tile instanceof GTTileBaseSuperconductorCable)) {
		return new AxisAlignedBB(0.25D, 0.25D, 0.25D, 0.75D, 0.75D, 0.75D);
	} else {
		GTTileBaseSuperconductorCable cable = (GTTileBaseSuperconductorCable) tile;
		double thickness = this.size / 32.0D;
		double minX = 0.5D - thickness;
		double minY = 0.5D - thickness;
		double minZ = 0.5D - thickness;
		double maxX = 0.5D + thickness;
		double maxY = 0.5D + thickness;
		double maxZ = 0.5D + thickness;
		if (cable.connection.contains(EnumFacing.WEST)) {
			minX = 0.0D;
		}
		if (cable.connection.contains(EnumFacing.DOWN)) {
			minY = 0.0D;
		}
		if (cable.connection.contains(EnumFacing.NORTH)) {
			minZ = 0.0D;
		}
		if (cable.connection.contains(EnumFacing.EAST)) {
			maxX = 1.0D;
		}
		if (cable.connection.contains(EnumFacing.UP)) {
			maxY = 1.0D;
		}
		if (cable.connection.contains(EnumFacing.SOUTH)) {
			maxZ = 1.0D;
		}
		return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
	}
}
 
Example #25
Source File: RenderUtils.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
public static void drawSolidBox(AxisAlignedBB bb)
{
	GL11.glVertex3d(bb.minX, bb.minY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ);
	GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ);
	
	GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ);
	GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ);
	
	GL11.glVertex3d(bb.minX, bb.minY, bb.minZ);
	GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ);
	
	GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ);
	GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ);
	
	GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ);
	GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ);
	GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ);
	GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ);
	
	GL11.glVertex3d(bb.minX, bb.minY, bb.minZ);
	GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ);
	GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ);
	GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ);
}
 
Example #26
Source File: WorldPhysicsCollider.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
private boolean handleLikelyCollision(BlockPos inWorldPos, BlockPos inLocalPos,
    IBlockState inWorldState,
    IBlockState inLocalState) {
    // System.out.println("Handling a likely collision");
    AxisAlignedBB inLocalBB = new AxisAlignedBB(inLocalPos.getX(), inLocalPos.getY(),
        inLocalPos.getZ(),
        inLocalPos.getX() + 1, inLocalPos.getY() + 1, inLocalPos.getZ() + 1);
    AxisAlignedBB inGlobalBB = new AxisAlignedBB(inWorldPos.getX(), inWorldPos.getY(),
        inWorldPos.getZ(),
        inWorldPos.getX() + 1, inWorldPos.getY() + 1, inWorldPos.getZ() + 1);

    // This changes the box bounding box to the real bounding box, not sure if this
    // is better or worse for this mod
    // List<AxisAlignedBB> colBB = worldObj.getCollisionBoxes(inLocalBB);
    // inLocalBB = colBB.get(0);

    Polygon shipInWorld = new Polygon(inLocalBB,
        parent.getShipTransformationManager().getCurrentPhysicsTransform(),
        TransformType.SUBSPACE_TO_GLOBAL);
    Polygon worldPoly = new Polygon(inGlobalBB);
    PhysPolygonCollider collider = new PhysPolygonCollider(shipInWorld, worldPoly,
        parent.getShipTransformationManager().normals);
    if (!collider.seperated) {
        return handleActualCollision(collider, inWorldPos, inLocalPos, inWorldState,
            inLocalState);
    }

    return false;
}
 
Example #27
Source File: TileRocketBuilder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);

	stats.readFromNBT(nbt);

	prevProgress = progress = nbt.getInteger("scanTime");
	totalProgress = nbt.getInteger("scanTotalBlocks");
	status = ErrorCodes.values()[nbt.getInteger("status")];

	building = nbt.getBoolean("building");
	if(nbt.hasKey("bb")) {

		NBTTagCompound tag = nbt.getCompoundTag("bb");
		bbCache = new AxisAlignedBB(tag.getDouble("minX"), 
				tag.getDouble("minY"), tag.getDouble("minZ"),
				tag.getDouble("maxX"), tag.getDouble("maxY"), tag.getDouble("maxZ"));

	}

	blockPos.clear();
	if(nbt.hasKey("infrastructureLocations")) {
		int array[] = nbt.getIntArray("infrastructureLocations");

		for(int counter = 0; counter < array.length; counter += 3) {
			blockPos.add(new HashedBlockPosition(array[counter], array[counter+1], array[counter+2]));
		}
	}
}
 
Example #28
Source File: TileStationBuilder.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void scanRocket(World world, BlockPos pos2, AxisAlignedBB bb) {

	int actualMinX = (int)bb.maxX,
			actualMinY = (int)bb.maxY,
			actualMinZ = (int)bb.maxZ,
			actualMaxX = (int)bb.minX,
			actualMaxY = (int)bb.minY,
			actualMaxZ = (int)bb.minZ;


	for(int xCurr = (int)bb.minX; xCurr <= bb.maxX; xCurr++) {
		for(int zCurr = (int)bb.minZ; zCurr <= bb.maxZ; zCurr++) {
			for(int yCurr = (int)bb.minY; yCurr<= bb.maxY; yCurr++) {

				BlockPos posCurr = new BlockPos(xCurr, yCurr, zCurr);

				if(!world.isAirBlock(posCurr)) {
					if(xCurr < actualMinX)
						actualMinX = xCurr;
					if(yCurr < actualMinY)
						actualMinY = yCurr;
					if(zCurr < actualMinZ)
						actualMinZ = zCurr;
					if(xCurr > actualMaxX)
						actualMaxX = xCurr;
					if(yCurr > actualMaxY)
						actualMaxY = yCurr;
					if(zCurr > actualMaxZ)
						actualMaxZ = zCurr;
				}
			}
		}
	}

	status = ErrorCodes.SUCCESS_STATION;
}
 
Example #29
Source File: BlockSmallVessel.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end)
{
	List<RayTraceResult> list = Lists.<RayTraceResult>newArrayList();

	for (AxisAlignedBB axisalignedbb : getCollisionBoxList((TileSmallVessel)worldIn.getTileEntity(pos)))
	{
		list.add(this.rayTrace(pos, start, end, axisalignedbb));
	}

	RayTraceResult raytraceresult1 = null;
	double d1 = 0.0D;

	for (RayTraceResult raytraceresult : list)
	{
		if (raytraceresult != null)
		{
			double d0 = raytraceresult.hitVec.squareDistanceTo(end);

			if (d0 > d1)
			{
				raytraceresult1 = raytraceresult;
				d1 = d0;
			}
		}
	}

	return raytraceresult1;
}
 
Example #30
Source File: BlockStoneStalac.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{
	state = this.getActualState(state, source, pos);
	int size = state.getValue(SIZE_PROPERTY);
	if(size== 0)
		return AABB_0;
	else if(size == 1)
		return AABB_1;
	else if(size == 2)
		return AABB_2;
	return NULL_AABB;
}