Search in sources :

Example 66 with Pos

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

the class ThreadSky method run.

@Override
public void run() {
    int steps = (int) Math.ceil(Math.PI / Math.atan(1.0D / this.radius));
    for (int phi_n = 0; phi_n < 2 * steps; phi_n++) {
        for (int theta_n = 0; theta_n < steps; theta_n++) {
            double phi = Math.PI * 2 / steps * phi_n;
            double theta = Math.PI / steps * theta_n;
            Pos delta = new Pos(sin(theta) * cos(phi), cos(theta), sin(theta) * sin(phi));
            float power = this.energy - (this.energy * this.position.world().rand.nextFloat() / 2);
            Location targetPosition = this.position;
            for (float var21 = 0.3F; power > 0f; power -= var21 * 0.75F * 10) {
                if (targetPosition.distance(position) > this.radius) {
                    break;
                }
                Block blockID = this.position.world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());
                if (blockID != Blocks.air) {
                    if (blockID == Blocks.bedrock) {
                        break;
                    }
                    float resistance = this.callBack.getResistance(this.position.world(), position.toPos(), targetPosition.toPos(), source, blockID);
                    power -= resistance;
                    if (power > 0f) {
                        this.results.add(targetPosition.add(new Pos(0, 1, 0)).toPos());
                    }
                }
                targetPosition = targetPosition.add(delta);
            }
        }
    }
    super.run();
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) Location(com.builtbroken.mc.imp.transform.vector.Location)

Example 67 with Pos

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

the class EntityExplosive method onUpdate.

/** Called to update the entity's position/logic. */
@Override
public void onUpdate() {
    if (!this.worldObj.isRemote) {
        ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(worldObj, posX, posY, posZ, ExplosiveType.BLOCK, explosiveID.handler);
        MinecraftForge.EVENT_BUS.post(evt);
        if (evt.isCanceled()) {
            ICBMClassic.blockExplosive.dropBlockAsItem(this.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ, this.explosiveID.ordinal(), 0);
            this.setDead();
            return;
        }
    }
    this.prevPosX = this.posX;
    this.prevPosY = this.posY;
    this.prevPosZ = this.posZ;
    this.motionX *= 0.95;
    this.motionY -= 0.045D;
    this.motionZ *= 0.95;
    this.moveEntity(this.motionX, this.motionY, this.motionZ);
    if (this.fuse < 1) {
        this.explode();
    } else {
        this.explosiveID.handler.onYinZha(this.worldObj, new Pos(this.posX, this.posY, this.posZ), this.fuse);
    }
    this.fuse--;
    super.onUpdate();
}
Also used : ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Example 68 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos 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 69 with Pos

use of com.builtbroken.mc.imp.transform.vector.Pos 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 70 with Pos

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

the class BlastChemical method doExplode.

@Override
public void doExplode() {
    float radius = this.getRadius();
    if (this.world().isRemote) {
        for (int i = 0; i < 200; i++) {
            Pos diDian = new Pos(Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4, Math.random() * radius / 2 - radius / 4);
            diDian = diDian.multiply(Math.min(radius, callCount) / 10);
            if (diDian.magnitude() <= radius) {
                diDian = diDian.add(this.position);
                ICBMClassic.proxy.spawnParticle("smoke", this.world(), diDian, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, (Math.random() - 0.5) / 2, this.red, this.green, this.blue, 7.0F, 8);
            }
        }
    }
    AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
    List<EntityLivingBase> allEntities = world().getEntitiesWithinAABB(EntityLivingBase.class, bounds);
    for (EntityLivingBase entity : allEntities) {
        if (this.isContagious) {
            ICBMClassic.contagios_potion.poisonEntity(position.toPos(), entity);
        }
        if (this.isPoisonous) {
            ICBMClassic.poisonous_potion.poisonEntity(position.toPos(), entity);
        }
        if (this.isConfuse) {
            entity.addPotionEffect(new CustomPotionEffect(Potion.confusion.id, 18 * 20, 0));
            entity.addPotionEffect(new CustomPotionEffect(Potion.digSlowdown.id, 20 * 60, 0));
            entity.addPotionEffect(new CustomPotionEffect(Potion.moveSlowdown.id, 20 * 60, 2));
        }
    }
    if (this.isMutate) {
        new BlastMutation(world(), this.exploder, position.x(), position.y(), position.z(), this.getRadius()).explode();
    }
    if (this.playShortSoundFX) {
        world().playSoundEffect(position.x() + 0.5D, position.y() + 0.5D, position.z() + 0.5D, ICBMClassic.PREFIX + "gasleak", 4.0F, (1.0F + (world().rand.nextFloat() - world().rand.nextFloat()) * 0.2F) * 1F);
    }
    if (this.callCount > this.duration) {
        this.controller.endExplosion();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Pos(com.builtbroken.mc.imp.transform.vector.Pos) EntityLivingBase(net.minecraft.entity.EntityLivingBase) CustomPotionEffect(icbm.classic.content.potion.CustomPotionEffect)

Aggregations

Pos (com.builtbroken.mc.imp.transform.vector.Pos)105 Block (net.minecraft.block.Block)25 TileEntity (net.minecraft.tileentity.TileEntity)13 Location (com.builtbroken.mc.imp.transform.vector.Location)11 Entity (net.minecraft.entity.Entity)11 Cube (com.builtbroken.mc.imp.transform.region.Cube)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)7 Test (org.junit.Test)7 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)6 EntityMissile (icbm.classic.content.entity.EntityMissile)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 IPos3D (com.builtbroken.jlib.data.vector.IPos3D)5 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)5 EntityFlyingBlock (icbm.classic.content.entity.EntityFlyingBlock)5 ItemStack (net.minecraft.item.ItemStack)5 EulerAngle (com.builtbroken.mc.imp.transform.rotation.EulerAngle)4 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)4 Tile (com.builtbroken.mc.prefab.tile.Tile)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4