Search in sources :

Example 1 with PacketSpawnParticle

use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.

the class BlockEnderPlant method executeFullGrownEffect.

@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
    if (!world.isRemote) {
        for (int i = 0; i < 50; i++) {
            int randX = x + rand.nextInt(30) - 15;
            int randY = y + rand.nextInt(8);
            int randZ = z + rand.nextInt(30) - 15;
            Block block = world.getBlock(randX, randY, randZ);
            if (!block.getMaterial().blocksMovement()) {
                ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE);
                EntityItem plant = new EntityItem(world, randX + 0.5D, randY + 0.5D, randZ + 0.5D, seed);
                // plant.motionX = plant.motionY = plant.motionZ = 0;
                plant.lifespan = 300;
                ItemPlasticPlants.markInactive(plant);
                world.spawnEntityInWorld(plant);
                plant.playSound("mob.endermen.portal", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
                short short1 = 128;
                for (int j = 0; j < short1; ++j) {
                    double d6 = j / (short1 - 1.0D);
                    float f = (rand.nextFloat() - 0.5F) * 0.2F;
                    float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
                    float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
                    double d7 = x + 0.5D + (plant.posX - (x + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
                    double d8 = y + 0.5D + (plant.posY - (y + 0.5D)) * d6 + rand.nextDouble();
                    double d9 = z + 0.5D + (plant.posZ - (z + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
                    NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), world);
                }
                world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
                break;
            }
        }
    }
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with PacketSpawnParticle

use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.

the class EntityPathNavigateDrone method teleport.

public void teleport() {
    Random rand = pathfindingEntity.getRNG();
    double width = pathfindingEntity.width;
    double height = pathfindingEntity.height;
    short short1 = 128;
    for (int l = 0; l < short1; ++l) {
        double d6 = l / (short1 - 1.0D);
        float f = (rand.nextFloat() - 0.5F) * 0.2F;
        float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
        float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
        double d7 = pathfindingEntity.posX + (telX + 0.5 - pathfindingEntity.posX) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
        double d8 = pathfindingEntity.posY + (telY - pathfindingEntity.posY) * d6 + rand.nextDouble() * height;
        double d9 = pathfindingEntity.posZ + (telZ + 0.5 - pathfindingEntity.posZ) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
        NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), pathfindingEntity.worldObj);
    }
    pathfindingEntity.worldObj.playSoundEffect(pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
    pathfindingEntity.playSound("mob.endermen.portal", 1.0F, 1.0F);
    pathfindingEntity.setPosition(telX + 0.5, telY + 0.5, telZ + 0.5);
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) Random(java.util.Random) PathPoint(net.minecraft.pathfinding.PathPoint)

Example 3 with PacketSpawnParticle

use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.

the class EntityPathNavigateDrone method onUpdateNavigation.

@Override
public void onUpdateNavigation() {
    if (isGoingToTeleport()) {
        if (teleportCounter == 0 || teleportCounter == 60) {
            NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.HUD_INIT, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, 0.1F, teleportCounter == 0 ? 0.7F : 1F, true), pathfindingEntity.worldObj);
        }
        if (teleportCounter < TELEPORT_TICKS - 40) {
            Random rand = pathfindingEntity.getRNG();
            float f = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
            float f1 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
            float f2 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
            NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, f, f1, f2), pathfindingEntity.worldObj);
        }
        if (++teleportCounter > TELEPORT_TICKS) {
            if (pathfindingEntity.isBlockValidPathfindBlock(telX, telY, telZ)) {
                teleport();
            }
            teleportCounter = -1;
            setPath(null, 0);
            pathfindingEntity.getMoveHelper().setMoveTo(telX, telY, telZ, pathfindingEntity.getSpeed());
            pathfindingEntity.addAir(null, -10000);
        }
    } else {
        super.onUpdateNavigation();
    }
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) Random(java.util.Random) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound)

Example 4 with PacketSpawnParticle

use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.

the class TileEntityPneumaticBase method airLeak.

/**
 * Method to release air in the air. It takes air from a specific side, plays a sound effect, and spawns smoke particles.
 * @param side
 */
@Override
public void airLeak(ForgeDirection side) {
    if (worldObj.isRemote || Math.abs(getPressure(side)) < 0.01F)
        return;
    double motionX = side.offsetX;
    double motionY = side.offsetY;
    double motionZ = side.offsetZ;
    if (soundCounter <= 0) {
        soundCounter = 20;
        NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.LEAKING_GAS_SOUND, xCoord, yCoord, zCoord, 0.1F, 1.0F, true), worldObj);
    }
    if (getPressure(side) < 0) {
        double speed = getPressure(side) * 0.1F - 0.1F;
        NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
        int dispersedAmount = -(int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
        if (getCurrentAir(side) > dispersedAmount)
            dispersedAmount = -getCurrentAir(side);
        onAirDispersion(dispersedAmount, side);
        addAir(dispersedAmount, side);
    } else {
        double speed = getPressure(side) * 0.1F + 0.1F;
        // if(DateEventHandler.isEvent()) {
        // DateEventHandler.spawnFirework(worldObj, xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D);
        // } else {
        NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
        // }
        int dispersedAmount = (int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
        if (dispersedAmount > getCurrentAir(side))
            dispersedAmount = getCurrentAir(side);
        onAirDispersion(-dispersedAmount, side);
        addAir(-dispersedAmount, side);
    }
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound)

Example 5 with PacketSpawnParticle

use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.

the class TileEntityAirCannon method fire.

private synchronized boolean fire() {
    Entity itemShot = getCloseEntityIfUpgraded();
    if (getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_AIR_CANNON && (itemShot != null || inventory[0] != null)) {
        double[] velocity = getVelocityVector(heightAngle, rotationAngle, getForce());
        addAir((int) (-500 * getForce()), ForgeDirection.UNKNOWN);
        boolean shootingInventory = false;
        if (itemShot == null) {
            shootingInventory = true;
            itemShot = getPayloadEntity();
            if (itemShot instanceof EntityItem) {
                inventory[0] = null;
                if (getUpgrades(ItemMachineUpgrade.UPGRADE_BLOCK_TRACKER) > 0) {
                    trackedItems.add((EntityItem) itemShot);
                }
            } else {
                inventory[0].stackSize--;
                if (inventory[0].stackSize <= 0)
                    inventory[0] = null;
            }
        } else if (itemShot instanceof EntityPlayer) {
            EntityPlayerMP entityplayermp = (EntityPlayerMP) itemShot;
            if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen()) {
                entityplayermp.setPositionAndUpdate(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
            }
        }
        if (itemShot.isRiding()) {
            itemShot.mountEntity((Entity) null);
        }
        itemShot.setPosition(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
        NetworkHandler.sendToAllAround(new PacketSetEntityMotion(itemShot, velocity[0], velocity[1], velocity[2]), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));
        if (itemShot instanceof EntityFireball) {
            velocity[0] *= 0.05D;
            velocity[1] *= 0.05D;
            velocity[2] *= 0.05D;
        }
        itemShot.motionX = velocity[0];
        itemShot.motionY = velocity[1];
        itemShot.motionZ = velocity[2];
        itemShot.onGround = false;
        itemShot.isCollided = false;
        itemShot.isCollidedHorizontally = false;
        itemShot.isCollidedVertically = false;
        if (itemShot instanceof EntityLivingBase)
            ((EntityLivingBase) itemShot).setJumping(true);
        if (shootingInventory && !worldObj.isRemote)
            worldObj.spawnEntityInWorld(itemShot);
        for (int i = 0; i < 10; i++) {
            double velX = velocity[0] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velY = velocity[1] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velZ = velocity[2] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", xCoord + 0.5D, yCoord + 0.7D, zCoord + 0.5D, velX, velY, velZ), worldObj);
        }
        NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.CANNON_SOUND, xCoord, yCoord, zCoord, 1.0F, rand.nextFloat() / 4F + 0.75F, true), worldObj);
        return true;
    } else {
        return false;
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityItem(net.minecraft.entity.item.EntityItem) PacketSetEntityMotion(pneumaticCraft.common.network.PacketSetEntityMotion) EntityFireball(net.minecraft.entity.projectile.EntityFireball)

Aggregations

PacketSpawnParticle (pneumaticCraft.common.network.PacketSpawnParticle)7 PacketPlaySound (pneumaticCraft.common.network.PacketPlaySound)4 Random (java.util.Random)2 Block (net.minecraft.block.Block)2 EntityItem (net.minecraft.entity.item.EntityItem)2 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 EntityFireball (net.minecraft.entity.projectile.EntityFireball)1 ItemStack (net.minecraft.item.ItemStack)1 PathPoint (net.minecraft.pathfinding.PathPoint)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPneumaticPlantBase (pneumaticCraft.common.block.pneumaticPlants.BlockPneumaticPlantBase)1 PacketSetEntityMotion (pneumaticCraft.common.network.PacketSetEntityMotion)1