Search in sources :

Example 1 with PacketPlaySound

use of pneumaticCraft.common.network.PacketPlaySound 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 2 with PacketPlaySound

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

the class BlockCreeperPlant method executeFullGrownEffect.

@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
    if (world.getBlockMetadata(x, y, z) == 14) {
        if (!world.isRemote) {
            world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 0.5F, false);
            EntityItem item = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE));
            item.motionX = (rand.nextGaussian() - 0.5D) / 2;
            item.motionY = rand.nextDouble();
            item.motionZ = (rand.nextGaussian() - 0.5D) / 2;
            item.lifespan = 300;
            ItemPlasticPlants.markInactive(item);
            world.spawnEntityInWorld(item);
            world.setBlock(x, y, z, this, world.getBlockMetadata(x, y, z) - 2, 3);
        }
    } else {
        world.setBlockMetadataWithNotify(x, y, z, 14, 3);
        NetworkHandler.sendToAllAround(new PacketPlaySound("creeper.primed", x + 0.5D, y + 0.5D, z + 0.5D, 1.0F, 1.0F, true), world);
        world.scheduleBlockUpdate(x, y, z, this, 60);
    }
}
Also used : PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 3 with PacketPlaySound

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

the class HeatBehaviourLiquidTransition method onLiquidTransition.

protected void onLiquidTransition(int x, int y, int z) {
    NetworkHandler.sendToAllAround(new PacketPlaySound("random.fizz", x + 0.5, y + 0.5, z + 0.5, 0.5F, 2.6F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.8F, true), getWorld());
    for (int i = 0; i < 8; i++) {
        double randX = x + getWorld().rand.nextDouble();
        double randZ = z + getWorld().rand.nextDouble();
        NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", randX, y + 1, randZ, 0, 0, 0), getWorld());
    }
}
Also used : PacketSpawnParticle(pneumaticCraft.common.network.PacketSpawnParticle) PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound)

Example 4 with PacketPlaySound

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

the class ItemPneumaticWrench method onItemUseFirst.

/**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ) {
    if (!world.isRemote) {
        Block block = world.getBlock(x, y, z);
        IPneumaticWrenchable wrenchable = null;
        if (block instanceof IPneumaticWrenchable) {
            wrenchable = (IPneumaticWrenchable) block;
        } else {
            wrenchable = ModInteractionUtils.getInstance().getWrenchable(world.getTileEntity(x, y, z));
        }
        if (wrenchable != null && ((ItemPneumaticWrench) Itemss.pneumaticWrench).getPressure(stack) > 0) {
            if (wrenchable.rotateBlock(world, player, x, y, z, ForgeDirection.getOrientation(side))) {
                if (!player.capabilities.isCreativeMode)
                    ((ItemPneumaticWrench) Itemss.pneumaticWrench).addAir(stack, -PneumaticValues.USAGE_PNEUMATIC_WRENCH);
                NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
                return true;
            }
        } else if (block != null) {
            //rotating normal blocks doesn't cost energy.
            if (block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
                NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
                return true;
            }
        }
        return false;
    } else {
        return false;
    }
}
Also used : PacketPlaySound(pneumaticCraft.common.network.PacketPlaySound) Block(net.minecraft.block.Block) IPneumaticWrenchable(pneumaticCraft.api.block.IPneumaticWrenchable)

Example 5 with PacketPlaySound

use of pneumaticCraft.common.network.PacketPlaySound 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

PacketPlaySound (pneumaticCraft.common.network.PacketPlaySound)6 PacketSpawnParticle (pneumaticCraft.common.network.PacketSpawnParticle)4 EntityItem (net.minecraft.entity.item.EntityItem)2 TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)1 Random (java.util.Random)1 Block (net.minecraft.block.Block)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 TileEntity (net.minecraft.tileentity.TileEntity)1 IPneumaticWrenchable (pneumaticCraft.api.block.IPneumaticWrenchable)1 PacketSetEntityMotion (pneumaticCraft.common.network.PacketSetEntityMotion)1