Search in sources :

Example 6 with Cube

use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.

the class RadioMap method getReceiversInRange.

/**
 * Gets a list of all receivers in the range
 *
 * @param range       - range to check inside
 * @param excludeList - tiles to ignore
 * @return list of receivers, or empty list
 */
public List<IRadioWaveReceiver> getReceiversInRange(Cube range, List excludeList) {
    List<IRadioWaveReceiver> receivers = new ArrayList();
    receivers.addAll(fullMapRangeReceives);
    if (range != null) {
        for (IRadioWaveReceiver receiver : receive_to_chunks.keySet()) {
            if (receiver != null && (excludeList == null || !excludeList.contains(receiver))) {
                Cube receiverRange = receiver.getRadioReceiverRange();
                if (receiverRange != null && range.doesOverlap(receiverRange)) {
                    receivers.add(receiver);
                }
            }
        }
    }
    return receivers;
}
Also used : IRadioWaveReceiver(icbm.classic.api.tile.IRadioWaveReceiver) Cube(icbm.classic.lib.transform.region.Cube) ArrayList(java.util.ArrayList)

Example 7 with Cube

use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.

the class BlastRedmatter method doEntityEffects.

protected void doEntityEffects() {
    final float entityRadius = this.getBlastRadius() * 1.5f;
    // TODO Cache, recalc on movement only
    final Cube cube = new Cube(location.add(0.5).sub(entityRadius), location.add(0.5).add(entityRadius));
    final AxisAlignedBB bounds = cube.getAABB();
    // Get all entities in the cube area
    this.world().getEntitiesWithinAABB(Entity.class, bounds).stream().filter(this::shouldHandleEntity).forEach(this::handleEntities);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Cube(icbm.classic.lib.transform.region.Cube)

Example 8 with Cube

use of icbm.classic.lib.transform.region.Cube in project ICBM-Classic by BuiltBrokenModding.

the class BlastTNT method pushEntities.

public // TODO convert to delay action
void pushEntities(// TODO convert to delay action
float radius, // TODO convert to delay action
float force, // TODO convert to delay action
PushType type) {
    // Step 2: Damage all entities
    Pos minCoord = location.toPos();
    minCoord = minCoord.add(-radius - 1);
    Pos maxCoord = location.toPos();
    maxCoord = maxCoord.add(radius + 1);
    Cube region = new Cube(minCoord, maxCoord);
    List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, region.getAABB());
    for (Entity entity : entities) {
        double var13 = entity.getDistance(location.x(), location.y(), location.z()) / radius;
        if (var13 <= 1.0D) {
            // Get delta
            double xDifference = entity.posX - location.x();
            double yDifference = entity.posY - location.y();
            double zDifference = entity.posZ - location.z();
            // Get magnitude
            double mag = MathHelper.sqrt(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
            // Normalize difference
            xDifference /= mag;
            yDifference /= mag;
            zDifference /= mag;
            if (type == PushType.ATTRACT) {
                double modifier = var13 * force * (entity instanceof EntityPlayer ? 0.5 : 1);
                entity.addVelocity(-xDifference * modifier, -yDifference * modifier, -zDifference * modifier);
            } else if (type == PushType.REPEL) {
                double modifier = (1.0D - var13) * force * (entity instanceof EntityPlayer ? 0.5 : 1);
                entity.addVelocity(xDifference * modifier, yDifference * modifier, zDifference * modifier);
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) Pos(icbm.classic.lib.transform.vector.Pos) BlockPos(net.minecraft.util.math.BlockPos) Cube(icbm.classic.lib.transform.region.Cube) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

Cube (icbm.classic.lib.transform.region.Cube)8 IRadioWaveReceiver (icbm.classic.api.tile.IRadioWaveReceiver)4 ArrayList (java.util.ArrayList)3 Entity (net.minecraft.entity.Entity)2 IRadioWaveSender (icbm.classic.api.tile.IRadioWaveSender)1 Pos (icbm.classic.lib.transform.vector.Pos)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkPos (net.minecraft.util.math.ChunkPos)1