Search in sources :

Example 16 with Location

use of com.builtbroken.mc.imp.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.

the class Blast method doDamageEntities.

protected void doDamageEntities(float radius, float power, boolean destroyItem) {
    // Step 2: Damage all entities
    radius *= 2.0F;
    Location minCoord = position.add(-radius - 1);
    Location maxCoord = position.add(radius + 1);
    List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(minCoord.xi(), minCoord.yi(), minCoord.zi(), maxCoord.xi(), maxCoord.yi(), maxCoord.zi()));
    Vec3 var31 = Vec3.createVectorHelper(position.x(), position.y(), position.z());
    for (int i = 0; i < allEntities.size(); ++i) {
        Entity entity = allEntities.get(i);
        if (this.onDamageEntity(entity)) {
            continue;
        }
        if (entity instanceof EntityMissile) {
            ((EntityMissile) entity).setExplode();
            continue;
        }
        if (entity instanceof EntityItem && !destroyItem) {
            continue;
        }
        double distance = entity.getDistance(position.x(), position.y(), position.z()) / radius;
        if (distance <= 1.0D) {
            double xDifference = entity.posX - position.x();
            double yDifference = entity.posY - position.y();
            double zDifference = entity.posZ - position.z();
            double var35 = MathHelper.sqrt_double(xDifference * xDifference + yDifference * yDifference + zDifference * zDifference);
            xDifference /= var35;
            yDifference /= var35;
            zDifference /= var35;
            double var34 = world().getBlockDensity(var31, entity.boundingBox);
            double var36 = (1.0D - distance) * var34;
            int damage = 0;
            damage = (int) ((var36 * var36 + var36) / 2.0D * 8.0D * power + 1.0D);
            entity.attackEntityFrom(DamageSource.setExplosionSource(this), damage);
            entity.motionX += xDifference * var36;
            entity.motionY += yDifference * var36;
            entity.motionZ += zDifference * var36;
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityMissile(icbm.classic.content.entity.EntityMissile) EntityItem(net.minecraft.entity.item.EntityItem) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 17 with Location

use of com.builtbroken.mc.imp.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.

the class BlastAntimatter method doExplode.

@Override
public void doExplode() {
    if (!this.world().isRemote) {
        for (int x = (int) -this.getRadius(); x < this.getRadius(); x++) {
            for (int y = (int) -this.getRadius(); y < this.getRadius(); y++) {
                for (int z = (int) -this.getRadius(); z < this.getRadius(); z++) {
                    Location targetPosition = this.position.add(new Pos(x, y, z));
                    double dist = position.distance(targetPosition);
                    if (dist < this.getRadius()) {
                        Block block = targetPosition.getBlock(world());
                        if (block != null && !block.isAir(this.world(), x, y, x)) {
                            if (!this.destroyBedrock && block.getBlockHardness(this.world(), x, y, x) < 0) {
                                continue;
                            }
                            if (dist < this.getRadius() - 1 || world().rand.nextFloat() > 0.7) {
                                targetPosition.setBlockToAir();
                            }
                        }
                    }
                }
            }
        }
    }
// TODO: Render antimatter shockwave
/*
         * else if (ZhuYao.proxy.isGaoQing()) { for (int x = -this.getRadius(); x <
         * this.getRadius(); x++) { for (int y = -this.getRadius(); y < this.getRadius(); y++) { for
         * (int z = -this.getRadius(); z < this.getRadius(); z++) { Vector3 targetPosition =
         * Vector3.add(position, new Vector3(x, y, z)); double distance =
         * position.distanceTo(targetPosition);
         * if (targetPosition.getBlockID(worldObj) == 0) { if (distance < this.getRadius() &&
         * distance > this.getRadius() - 1 && worldObj.rand.nextFloat() > 0.5) {
         * ParticleSpawner.spawnParticle("antimatter", worldObj, targetPosition); } } } } } }
         */
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) Block(net.minecraft.block.Block) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 18 with Location

use of com.builtbroken.mc.imp.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.

the class BlastBeam method doExplode.

@Override
public void doExplode() {
    if (!this.world().isRemote) {
        if (this.callCount > 100 / this.proceduralInterval() && this.thread.isComplete) {
            this.controller.endExplosion();
        }
        if (this.canFocusBeam(this.world(), position)) {
            Pos currentPos;
            int blockID;
            int metadata;
            double dist;
            int r = radius;
            for (int x = -r; x < r; x++) {
                for (int y = -r; y < r; y++) {
                    for (int z = -r; z < r; z++) {
                        dist = MathHelper.sqrt_double((x * x + y * y + z * z));
                        if (dist > r || dist < r - 3) {
                            continue;
                        }
                        currentPos = new Pos(position.x() + x, position.y() + y, position.z() + z);
                        Block block = currentPos.getBlock(world());
                        if (block == null || block.isAir(this.world(), x, y, z) || block.getBlockHardness(this.world(), x, y, x) < 0) {
                            continue;
                        }
                        metadata = this.world().getBlockMetadata(currentPos.xi(), currentPos.yi(), currentPos.zi());
                        if (this.world().rand.nextInt(2) > 0) {
                            this.world().setBlockToAir(currentPos.xi(), currentPos.yi(), currentPos.zi());
                            currentPos = currentPos.add(0.5D);
                            EntityFlyingBlock entity = new EntityFlyingBlock(this.world(), currentPos, block, metadata);
                            this.world().spawnEntityInWorld(entity);
                            this.feiBlocks.add(entity);
                            entity.pitchChange = 50 * this.world().rand.nextFloat();
                        }
                    }
                }
            }
        } else {
            this.controller.endExplosion();
        }
        for (EntityFlyingBlock entity : this.feiBlocks) {
            Pos entityPosition = new Pos(entity);
            Pos centeredPosition = entityPosition.add(this.position.multiply(-1));
            centeredPosition.rotate(2);
            Location newPosition = this.position.add(centeredPosition);
            entity.motionX /= 3;
            entity.motionY /= 3;
            entity.motionZ /= 3;
            entity.addVelocity((newPosition.x() - entityPosition.x()) * 0.5 * this.proceduralInterval(), 0.09 * this.proceduralInterval(), (newPosition.z() - entityPosition.z()) * 0.5 * this.proceduralInterval());
            entity.yawChange += 3 * this.world().rand.nextFloat();
        }
    }
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) Block(net.minecraft.block.Block) EntityFlyingBlock(icbm.classic.content.entity.EntityFlyingBlock) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 19 with Location

use of com.builtbroken.mc.imp.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.

the class BlastNuclear method doPreExplode.

@Override
public void doPreExplode() {
    if (!this.world().isRemote) {
        this.thread = new ThreadLargeExplosion(this.position, (int) this.getRadius(), this.energy, this.exploder);
        this.thread.start();
    } else if (this.spawnMoreParticles && ICBMClassic.proxy.isGaoQing()) {
        // Spawn nuclear cloud.
        for (int y = 0; y < 26; y++) {
            int r = 4;
            if (y < 8) {
                r = Math.max(Math.min((8 - y) * 2, 10), 4);
            } else if (y > 15) {
                r = Math.max(Math.min((y - 15) * 2, 15), 5);
            }
            for (int x = -r; x < r; x++) {
                for (int z = -r; z < r; z++) {
                    double distance = MathHelper.sqrt_double(x * x + z * z);
                    if (r > distance && r - 3 < distance) {
                        Location spawnPosition = position.add(new Pos(x * 2, (y - 2) * 2, z * 2));
                        float xDiff = (float) (spawnPosition.x() - position.x());
                        float zDiff = (float) (spawnPosition.z() - position.z());
                        ICBMClassic.proxy.spawnParticle("smoke", world(), spawnPosition, xDiff * 0.3 * world().rand.nextFloat(), -world().rand.nextFloat(), zDiff * 0.3 * world().rand.nextFloat(), (float) (distance / this.getRadius()) * world().rand.nextFloat(), 0, 0, 8F, 1.2F);
                    }
                }
            }
        }
    }
    this.doDamageEntities(this.getRadius(), this.energy * 1000);
    this.world().playSoundEffect(this.position.x(), this.position.y(), this.position.z(), ICBMClassic.PREFIX + "explosion", 7.0F, (1.0F + (this.world().rand.nextFloat() - this.world().rand.nextFloat()) * 0.2F) * 0.7F);
}
Also used : ThreadLargeExplosion(icbm.classic.content.explosive.thread.ThreadLargeExplosion) Pos(com.builtbroken.mc.imp.transform.vector.Pos) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 20 with Location

use of com.builtbroken.mc.imp.transform.vector.Location in project ICBM-Classic by BuiltBrokenModding.

the class ItemRadarGun method read.

@Override
public void read(ByteBuf buf, EntityPlayer player, PacketType packet) {
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack != null && stack.getItem() == this) {
        setLocation(stack, new Location(player.worldObj, buf.readInt(), buf.readInt(), buf.readInt()));
        player.addChatComponentMessage(new ChatComponentText("GPS data set"));
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) Location(com.builtbroken.mc.imp.transform.vector.Location)

Aggregations

Location (com.builtbroken.mc.imp.transform.vector.Location)30 Pos (com.builtbroken.mc.imp.transform.vector.Pos)11 Block (net.minecraft.block.Block)7 TileEntity (net.minecraft.tileentity.TileEntity)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 HashMap (java.util.HashMap)5 IMultiTile (com.builtbroken.mc.api.tile.multiblock.IMultiTile)4 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)4 ByteBuf (io.netty.buffer.ByteBuf)4 Map (java.util.Map)4 World (net.minecraft.world.World)4 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)4 IPacketIDReceiver (com.builtbroken.mc.core.network.IPacketIDReceiver)3 IPacketReceiver (com.builtbroken.mc.core.network.IPacketReceiver)3 PacketIDException (com.builtbroken.mc.core.network.ex.PacketIDException)3 PacketTileReadException (com.builtbroken.mc.core.network.ex.PacketTileReadException)3 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)3 Entity (net.minecraft.entity.Entity)3 Test (org.junit.Test)3 AbstractTest (com.builtbroken.mc.testing.junit.AbstractTest)2