Search in sources :

Example 1 with PacketCPlaySoundAtPos

use of net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos in project SecurityCraft by Geforce132.

the class ItemTaser method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (!worldIn.isRemote) {
        if (!itemStackIn.isItemDamaged()) {
            worldIn.spawnEntityInWorld(new EntityTaserBullet(worldIn, playerIn));
            mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(playerIn.posX, playerIn.posY, playerIn.posZ, SCSounds.TASERFIRED.path, 1.0F));
            if (!playerIn.capabilities.isCreativeMode) {
                itemStackIn.damageItem(150, playerIn);
            }
        }
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStackIn);
}
Also used : PacketCPlaySoundAtPos(net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos) EntityTaserBullet(net.geforcemods.securitycraft.entity.EntityTaserBullet)

Example 2 with PacketCPlaySoundAtPos

use of net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos in project SecurityCraft by Geforce132.

the class TileEntityAlarm method updateEntity.

public void updateEntity() {
    super.updateEntity();
    if (this.worldObj.isRemote) {
        return;
    } else {
        if (cooldown > 0) {
            cooldown--;
        }
        if (isPowered && cooldown == 0) {
            mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(xCoord, yCoord, zCoord, SCSounds.ALARM.path, mod_SecurityCraft.configHandler.alarmSoundVolume));
            setCooldown((mod_SecurityCraft.configHandler.alarmTickDelay * 20));
        }
    }
}
Also used : PacketCPlaySoundAtPos(net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos)

Example 3 with PacketCPlaySoundAtPos

use of net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos in project SecurityCraft by Geforce132.

the class ItemTaser method onItemRightClick.

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (!par2World.isRemote) {
        if (!par1ItemStack.isItemDamaged()) {
            par2World.spawnEntityInWorld(new EntityTaserBullet(par2World, par3EntityPlayer));
            mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, SCSounds.TASERFIRED.path, 1.0F));
            if (!par3EntityPlayer.capabilities.isCreativeMode) {
                par1ItemStack.damageItem(150, par3EntityPlayer);
            }
        }
    }
    return par1ItemStack;
}
Also used : PacketCPlaySoundAtPos(net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos) EntityTaserBullet(net.geforcemods.securitycraft.entity.EntityTaserBullet)

Example 4 with PacketCPlaySoundAtPos

use of net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos in project SecurityCraft by Geforce132.

the class TileEntityAlarm method update.

@Override
public void update() {
    if (this.worldObj.isRemote) {
        return;
    } else {
        if (cooldown > 0) {
            cooldown--;
            if (cooldown == 0) {
                mod_SecurityCraft.log("Cooldown is 0");
            }
        }
        if (isPowered && cooldown == 0) {
            TileEntityAlarm TEA = (TileEntityAlarm) this.worldObj.getTileEntity(pos);
            mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(pos.getX(), pos.getY(), pos.getZ(), SCSounds.ALARM.path, mod_SecurityCraft.configHandler.alarmSoundVolume));
            TEA.setCooldown((mod_SecurityCraft.configHandler.alarmTickDelay * 20));
            //TODO
            this.worldObj.setBlockState(pos, this.worldObj.getBlockState(pos).withProperty(BlockAlarm.FACING, this.worldObj.getBlockState(pos).getValue(BlockAlarm.FACING)), 2);
            this.worldObj.setTileEntity(pos, TEA);
        }
    }
}
Also used : PacketCPlaySoundAtPos(net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos)

Example 5 with PacketCPlaySoundAtPos

use of net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos in project SecurityCraft by Geforce132.

the class TileEntityIMS method launchMine.

/**
	 * Create a bounding box around the IMS, and fire a mine if a mob or player is found.
	 */
private void launchMine() {
    boolean launchedMine = false;
    if (bombsRemaining > 0) {
        double d0 = mod_SecurityCraft.configHandler.imsRange;
        AxisAlignedBB axisalignedbb = BlockUtils.fromBounds(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1).expand(d0, d0, d0);
        List<?> list1 = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
        List<?> list2 = this.worldObj.getEntitiesWithinAABB(EntityMob.class, axisalignedbb);
        Iterator<?> iterator1 = list1.iterator();
        Iterator<?> iterator2 = list2.iterator();
        while (targetingOption == EnumIMSTargetingMode.PLAYERS_AND_MOBS && iterator2.hasNext()) {
            EntityLivingBase entity = (EntityLivingBase) iterator2.next();
            int launchHeight = this.getLaunchHeight();
            if (WorldUtils.isPathObstructed(worldObj, pos.getX() + 0.5D, pos.getY() + (((launchHeight - 1) / 3) + 0.5D), pos.getZ() + 0.5D, entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ)) {
                continue;
            }
            if (hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(worldObj, pos, EnumCustomModules.WHITELIST).contains(entity.getName().toLowerCase())) {
                continue;
            }
            double d5 = entity.posX - (pos.getX() + 0.5D);
            double d6 = entity.getEntityBoundingBox().minY + entity.height / 2.0F - (pos.getY() + 1.25D);
            double d7 = entity.posZ - (pos.getZ() + 0.5D);
            this.spawnMine(entity, d5, d6, d7, launchHeight);
            if (worldObj.isRemote) {
                mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(pos.getX(), pos.getY(), pos.getZ(), "random.bow", 1.0F));
            }
            this.bombsRemaining--;
            if (bombsRemaining == 0) {
                worldObj.scheduleUpdate(pos, BlockUtils.getBlock(worldObj, pos), 140);
            }
            launchedMine = true;
            updateBombCount = true;
            break;
        }
        while (!launchedMine && iterator1.hasNext()) {
            EntityPlayer entity = (EntityPlayer) iterator1.next();
            int launchHeight = this.getLaunchHeight();
            if (entity != null && getOwner().isOwner((entity))) {
                continue;
            }
            if (WorldUtils.isPathObstructed(worldObj, pos.getX() + 0.5D, pos.getY() + (((launchHeight - 1) / 3) + 0.5D), pos.getZ() + 0.5D, entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ)) {
                continue;
            }
            if (hasModule(EnumCustomModules.WHITELIST) && ModuleUtils.getPlayersFromModule(worldObj, pos, EnumCustomModules.WHITELIST).contains(entity.getName())) {
                continue;
            }
            double d5 = entity.posX - (pos.getX() + 0.5D);
            double d6 = entity.getEntityBoundingBox().minY + entity.height / 2.0F - (pos.getY() + 1.25D);
            double d7 = entity.posZ - (pos.getZ() + 0.5D);
            this.spawnMine(entity, d5, d6, d7, launchHeight);
            if (worldObj.isRemote) {
                mod_SecurityCraft.network.sendToAll(new PacketCPlaySoundAtPos(pos.getX(), pos.getY(), pos.getZ(), "random.bow", 1.0F));
            }
            this.bombsRemaining--;
            if (bombsRemaining == 0) {
                worldObj.scheduleUpdate(pos, BlockUtils.getBlock(worldObj, pos), 140);
            }
            updateBombCount = true;
            break;
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PacketCPlaySoundAtPos(net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

PacketCPlaySoundAtPos (net.geforcemods.securitycraft.network.packets.PacketCPlaySoundAtPos)5 EntityTaserBullet (net.geforcemods.securitycraft.entity.EntityTaserBullet)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1