Search in sources :

Example 76 with Pos

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

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

the class TileCruiseLauncherClient method readDescPacket.

@Override
public void readDescPacket(ByteBuf buf) {
    super.readDescPacket(buf);
    if (buf.readBoolean()) {
        cachedMissileStack = ByteBufUtils.readItemStack(buf);
    } else {
        cachedMissileStack = null;
    }
    setTarget(new Pos(buf.readInt(), buf.readInt(), buf.readInt()));
}
Also used : Pos(com.builtbroken.mc.imp.transform.vector.Pos)

Example 78 with Pos

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

the class TileLauncherBase method launchMissile.

/**
     * Launches the missile
     *
     * @param target - The target in which the missile will land in
     */
public boolean launchMissile(Pos target, int gaoDu) {
    final ItemStack stack = getMissileStack();
    if (stack != null && stack.getItem() == ICBMClassic.itemMissile) {
        Explosive ex = Explosives.get(stack.getItemDamage()).handler;
        if (ex.hasMissileForm()) {
            // Apply inaccuracy
            int inaccuracy = 30;
            //Get value from support frame
            if (this.supportFrame != null) {
                inaccuracy = this.supportFrame.getInaccuracy();
            }
            //Randomize distance
            inaccuracy = world().rand.nextInt(inaccuracy);
            //Randomize radius drop
            angle.setYaw(world().rand.nextFloat() * 360);
            //Update target
            target = target.add(angle.x() * inaccuracy, 0, angle.z() * inaccuracy);
            if (isServer()) {
                EntityMissile missile = new EntityMissile(world());
                missile.explosiveID = Explosives.get(stack.getItemDamage());
                missile.launcherPos = new Pos((TileEntity) this);
                missile.setPosition(xi(), yi() + 3, zi());
                missile.launch(target, gaoDu);
                world().spawnEntityInWorld(missile);
                this.decrStackSize(0, 1);
            }
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Explosive(icbm.classic.content.explosive.Explosive) Pos(com.builtbroken.mc.imp.transform.vector.Pos) ItemStack(net.minecraft.item.ItemStack) EntityMissile(icbm.classic.content.entity.EntityMissile)

Example 79 with Pos

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

the class TileLauncherBase method update.

/**
     * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner
     * uses this to count ticks and creates a new spawn inside its implementation.
     */
@Override
public void update() {
    super.update();
    if (ticks % 20 == 0) {
        if (this.supportFrame == null || launchScreen == null || launchScreen.isInvalid() || this.supportFrame.isInvalid()) {
            this.supportFrame = null;
            this.launchScreen = null;
            for (byte i = 2; i < 6; i++) {
                Pos position = new Pos(this.xCoord, this.yCoord, this.zCoord).add(ForgeDirection.getOrientation(i));
                TileEntity tileEntity = this.worldObj.getTileEntity(position.xi(), position.yi(), position.zi());
                if (tileEntity instanceof TileLauncherFrame) {
                    this.supportFrame = (TileLauncherFrame) tileEntity;
                    if (isServer()) {
                        this.supportFrame.setFacing(getDirection());
                    }
                } else if (tileEntity instanceof TileLauncherScreen) {
                    this.launchScreen = (TileLauncherScreen) tileEntity;
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Pos(com.builtbroken.mc.imp.transform.vector.Pos) TileLauncherFrame(icbm.classic.content.machines.launcher.frame.TileLauncherFrame) TileLauncherScreen(icbm.classic.content.machines.launcher.screen.TileLauncherScreen)

Example 80 with Pos

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

the class TileCruiseLauncher method update.

@Override
public void update() {
    super.update();
    // time / time_tick, client uses different value
    deltaTime = (System.nanoTime() - lastRotationUpdate) / 100000000.0;
    lastRotationUpdate = System.nanoTime();
    if (getTarget() != null && !getTarget().isZero()) {
        Pos aimPoint = getTarget();
        Pos center = toPos().add(0.5);
        if (Engine.runningAsDev) {
            sendPacket(new PacketSpawnParticleStream(world().provider.dimensionId, center, aimPoint));
        }
        aim.set(center.toEulerAngle(aimPoint).clampTo360());
        currentAim.moveTowards(aim, ROTATION_SPEED, deltaTime).clampTo360();
        if (!this.worldObj.isRemote) {
            if (this.ticks % 40 == 0 && this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
                this.launch();
            }
        }
    }
}
Also used : PacketSpawnParticleStream(com.builtbroken.mc.core.network.packet.PacketSpawnParticleStream) Pos(com.builtbroken.mc.imp.transform.vector.Pos)

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