Search in sources :

Example 21 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project MineFactoryReloaded by powercrystals.

the class BlockRedNetCable method getParts.

private AxisAlignedBB[] getParts(TileEntityRedNetCable cable) {
    RedNetConnectionType csu = cable.getConnectionState(ForgeDirection.UP);
    RedNetConnectionType csd = cable.getConnectionState(ForgeDirection.DOWN);
    RedNetConnectionType csn = cable.getConnectionState(ForgeDirection.NORTH);
    RedNetConnectionType css = cable.getConnectionState(ForgeDirection.SOUTH);
    RedNetConnectionType csw = cable.getConnectionState(ForgeDirection.WEST);
    RedNetConnectionType cse = cable.getConnectionState(ForgeDirection.EAST);
    AxisAlignedBB[] parts = new AxisAlignedBB[15];
    parts[0] = AxisAlignedBB.getBoundingBox(csw != RedNetConnectionType.None ? 0 : _wireStart, _wireStart, _wireStart, cse != RedNetConnectionType.None ? 1 : _wireEnd, _wireEnd, _wireEnd);
    parts[1] = AxisAlignedBB.getBoundingBox(_wireStart, csd != RedNetConnectionType.None ? 0 : _wireStart, _wireStart, _wireEnd, csu != RedNetConnectionType.None ? 1 : _wireEnd, _wireEnd);
    parts[2] = AxisAlignedBB.getBoundingBox(_wireStart, _wireStart, csn != RedNetConnectionType.None ? 0 : _wireStart, _wireEnd, _wireEnd, css != RedNetConnectionType.None ? 1 : _wireEnd);
    parts[3] = csw != RedNetConnectionType.PlateSingle && csw != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(0, _plateStart, _plateStart, _plateDepth, _plateEnd, _plateEnd);
    parts[4] = cse != RedNetConnectionType.PlateSingle && cse != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(1.0F - _plateDepth, _plateStart, _plateStart, 1.0F, _plateEnd, _plateEnd);
    parts[5] = csd != RedNetConnectionType.PlateSingle && csd != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, 0, _plateStart, _plateEnd, _plateDepth, _plateEnd);
    parts[6] = csu != RedNetConnectionType.PlateSingle && csu != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, 1.0F - _plateDepth, _plateStart, _plateEnd, 1.0F, _plateEnd);
    parts[7] = csn != RedNetConnectionType.PlateSingle && csn != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, _plateStart, 0, _plateEnd, _plateEnd, _plateDepth);
    parts[8] = css != RedNetConnectionType.PlateSingle && css != RedNetConnectionType.PlateAll ? null : AxisAlignedBB.getBoundingBox(_plateStart, _plateStart, 1.0F - _plateDepth, _plateEnd, _plateEnd, 1.0F);
    parts[9] = csw != RedNetConnectionType.PlateSingle && csw != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandDepthStart, _bandWidthStart, _bandWidthStart, _bandDepthEnd, _bandWidthEnd, _bandWidthEnd);
    parts[10] = cse != RedNetConnectionType.PlateSingle && cse != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(1.0F - _bandDepthEnd, _bandWidthStart, _bandWidthStart, 1.0F - _bandDepthStart, _bandWidthEnd, _bandWidthEnd);
    parts[11] = csd != RedNetConnectionType.PlateSingle && csd != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandDepthStart, _bandWidthStart, _bandWidthEnd, _bandDepthEnd, _bandWidthEnd);
    parts[12] = csu != RedNetConnectionType.PlateSingle && csu != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, 1.0F - _bandDepthEnd, _bandWidthStart, _bandWidthEnd, 1.0F - _bandDepthStart, _bandWidthEnd);
    parts[13] = csn != RedNetConnectionType.PlateSingle && csn != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandWidthStart, _bandDepthStart, _bandWidthEnd, _bandWidthEnd, _bandDepthEnd);
    parts[14] = css != RedNetConnectionType.PlateSingle && css != RedNetConnectionType.CableSingle ? null : AxisAlignedBB.getBoundingBox(_bandWidthStart, _bandWidthStart, 1.0F - _bandDepthEnd, _bandWidthEnd, _bandWidthEnd, 1.0F - _bandDepthStart);
    return parts;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) RedNetConnectionType(powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType)

Example 22 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class AxisAlignedMultiBB method getSurroundingAABB.

/**
	 * Calculates and returns an AxisAlignedBB instance that encapsulates all bounding box parts of the given List.
	 */
public static <T extends IMultiBoundingBoxPart> AxisAlignedBB getSurroundingAABB(List<T> boundingBoxParts) {
    AxisAlignedBB aabb;
    double minX = 0.0D;
    double minY = 0.0D;
    double minZ = 0.0D;
    double maxX = 0.0D;
    double maxY = 0.0D;
    double maxZ = 0.0D;
    for (T part : boundingBoxParts) {
        if (!part.containInParentBox()) {
            continue;
        }
        aabb = part.getBoundingBox();
        if (minX == 0.0D || aabb.minX < minX) {
            minX = aabb.minX;
        }
        if (minY == 0.0D || aabb.minY < minY) {
            minY = aabb.minY;
        }
        if (minZ == 0.0D || aabb.minZ < minZ) {
            minZ = aabb.minZ;
        }
        if (maxX == 0.0D || aabb.maxX > maxX) {
            maxX = aabb.maxX;
        }
        if (maxY == 0.0D || aabb.maxY > maxY) {
            maxY = aabb.maxY;
        }
        if (maxZ == 0.0D || aabb.maxZ > maxZ) {
            maxZ = aabb.maxZ;
        }
    }
    return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB)

Example 23 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project ArsMagica2 by Mithion.

the class AffinityHelper method applyReverseWaterMovement.

private void applyReverseWaterMovement(EntityLivingBase entity) {
    AxisAlignedBB par1AxisAlignedBB = entity.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D);
    int i = MathHelper.floor_double(par1AxisAlignedBB.minX);
    int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D);
    int k = MathHelper.floor_double(par1AxisAlignedBB.minY);
    int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D);
    int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ);
    int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D);
    if (!entity.worldObj.checkChunksExist(i, k, i1, j, l, j1)) {
        return;
    } else {
        boolean flag = false;
        Vec3 vec3 = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
        for (int k1 = i; k1 < j; ++k1) {
            for (int l1 = k; l1 < l; ++l1) {
                for (int i2 = i1; i2 < j1; ++i2) {
                    Block block = entity.worldObj.getBlock(k1, l1, i2);
                    if (block != null && block.getMaterial() == Material.water) {
                        double d0 = l1 + 1 - BlockLiquid.getLiquidHeightPercent(entity.worldObj.getBlockMetadata(k1, l1, i2));
                        if (l >= d0) {
                            flag = true;
                            block.velocityToAddToEntity(entity.worldObj, k1, l1, i2, entity, vec3);
                        }
                    }
                }
            }
        }
        if (vec3.lengthVector() > 0.0D && entity.isInWater()) {
            vec3 = vec3.normalize();
            double d1 = -0.014D;
            entity.motionX += vec3.xCoord * d1;
            entity.motionY += vec3.yCoord * d1;
            entity.motionZ += vec3.zCoord * d1;
        //AMCore.proxy.packetSender.SendVelocityAddPacket(entity.worldObj, entity, vec3.xCoord * d1, vec3.yCoord * d1, vec3.zCoord * d1);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Vec3(net.minecraft.util.Vec3) Block(net.minecraft.block.Block)

Example 24 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Engine by VoltzEngine-Project.

the class BlockBase method addCollisionBoxesToList.

@Override
@SuppressWarnings("unchecked")
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
    super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
    ListenerIterator it = new ListenerIterator(world, x, y, z, this, "bounds");
    while (it.hasNext()) {
        ITileEventListener next = it.next();
        if (next instanceof IBoundListener) {
            List collect = new ArrayList();
            ((IBoundListener) next).addCollisionBoxesToList(aabb, collect, entity);
            for (Object object : list) {
                if (object instanceof AxisAlignedBB && aabb.intersectsWith((AxisAlignedBB) object)) {
                    list.add(object);
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) ListenerIterator(com.builtbroken.mc.prefab.tile.listeners.ListenerIterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IJsonGenObject(com.builtbroken.mc.lib.json.imp.IJsonGenObject)

Example 25 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project ICBM-Classic by BuiltBrokenModding.

the class CommandICBM method processCommand.

@Override
public void processCommand(ICommandSender sender, String[] args) {
    try {
        EntityPlayer entityPlayer = (EntityPlayer) sender;
        int dimension = entityPlayer.worldObj.provider.dimensionId;
        if (args == null || args.length == 0 || args[0].equalsIgnoreCase("help")) {
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc help"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc lag <radius>"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc remove <All/Missile/Explosion> <radius>"));
            ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("/icbmc emp <radius>"));
            return;
        } else if (args.length >= 2 && args[0].equalsIgnoreCase("lag")) {
            int radius = parseInt(sender, args[1]);
            if (radius > 0) {
                AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(entityPlayer.posX - radius, entityPlayer.posY - radius, entityPlayer.posZ - radius, entityPlayer.posX + radius, entityPlayer.posY + radius, entityPlayer.posZ + radius);
                List<Entity> entitiesNearby = entityPlayer.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
                for (Entity entity : entitiesNearby) {
                    if (entity instanceof EntityFlyingBlock) {
                        ((EntityFlyingBlock) entity).setBlock();
                    } else if (entity instanceof EntityMissile) {
                        entity.setDead();
                    } else if (entity instanceof EntityExplosion) {
                        entity.setDead();
                    }
                }
                ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM lag sources within " + radius + " radius."));
                return;
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        } else if (args.length >= 3 && args[0].equalsIgnoreCase("remove")) {
            int radius = parseInt(sender, args[2]);
            boolean all = args[1].equalsIgnoreCase("all");
            boolean missile = args[1].equalsIgnoreCase("missiles");
            boolean explosion = args[1].equalsIgnoreCase("explosion");
            String str = "entities";
            if (missile) {
                str = "missiles";
            }
            if (explosion) {
                str = "explosions";
            }
            if (radius > 0) {
                EntityPlayer player = (EntityPlayer) sender;
                AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(player.posX - radius, player.posY - radius, player.posZ - radius, player.posX + radius, player.posY + radius, player.posZ + radius);
                List<Entity> entitiesNearby = player.worldObj.getEntitiesWithinAABB(Entity.class, bounds);
                for (Entity entity : entitiesNearby) {
                    if ((all || explosion) && entity instanceof EntityFlyingBlock) {
                        ((EntityFlyingBlock) entity).setBlock();
                    } else if ((all || missile) && entity instanceof EntityMissile) {
                        entity.setDead();
                    } else if ((all || explosion) && entity instanceof EntityExplosion) {
                        entity.setDead();
                    }
                }
                ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Removed all ICBM " + str + " within " + radius + " radius."));
                return;
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        } else if (args.length >= 2 && args[0].equalsIgnoreCase("emp")) {
            int radius = parseInt(sender, args[1]);
            if (radius > 0) {
                new BlastEMP(entityPlayer.worldObj, null, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, radius).setEffectBlocks().setEffectEntities().doExplode();
                switch(entityPlayer.worldObj.rand.nextInt(20)) {
                    case 0:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Did you pay the power bill?"));
                        return;
                    case 1:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("See them power their toys now!"));
                        return;
                    case 2:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Hey who turned the lights out."));
                        return;
                    case 3:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Ha! I run on steam power!"));
                        return;
                    case 4:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("The power of lighting at my finger tips!"));
                        return;
                    default:
                        ((EntityPlayer) sender).addChatComponentMessage(new ChatComponentText("Zap!"));
                        return;
                }
            } else {
                throw new WrongUsageException("Radius needs to be higher than zero");
            }
        }
    } catch (Exception e) {
    }
    throw new WrongUsageException(this.getCommandUsage(sender));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityExplosion(icbm.classic.content.entity.EntityExplosion) EntityMissile(icbm.classic.content.entity.EntityMissile) BlastEMP(icbm.classic.content.explosive.blast.BlastEMP) WrongUsageException(net.minecraft.command.WrongUsageException) WrongUsageException(net.minecraft.command.WrongUsageException) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) EntityPlayer(net.minecraft.entity.player.EntityPlayer) List(java.util.List) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

AxisAlignedBB (net.minecraft.util.AxisAlignedBB)74 Entity (net.minecraft.entity.Entity)24 EntityPlayer (net.minecraft.entity.player.EntityPlayer)20 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)18 ItemStack (net.minecraft.item.ItemStack)15 TileEntity (net.minecraft.tileentity.TileEntity)14 ArrayList (java.util.ArrayList)13 Vec3 (net.minecraft.util.Vec3)13 List (java.util.List)11 EntityItem (net.minecraft.entity.item.EntityItem)11 Block (net.minecraft.block.Block)10 EntityLivingBase (net.minecraft.entity.EntityLivingBase)9 Pos (com.builtbroken.mc.imp.transform.vector.Pos)7 SideOnly (cpw.mods.fml.relauncher.SideOnly)7 Iterator (java.util.Iterator)4 LPPositionSet (logisticspipes.utils.LPPositionSet)4 World (net.minecraft.world.World)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3